diff --git a/javascripts/discourse/components/custom-footer.js b/javascripts/discourse/components/custom-footer.js
index 69300bb..79edfed 100644
--- a/javascripts/discourse/components/custom-footer.js
+++ b/javascripts/discourse/components/custom-footer.js
@@ -2,10 +2,11 @@ import Component from "@glimmer/component";
import { dasherize } from "@ember/string";
export default class extends Component {
- mainHeading = settings.Heading;
- blurb = settings.Blurb;
+ mainHeading = settings.heading;
+ blurb = settings.blurb;
- linkArray = settings.Links.split("|")
+ linkArray = settings.links
+ .split("|")
.filter(Boolean)
.map((link) => {
const fragments = link.split(",").map((fragment) => fragment.trim());
@@ -26,7 +27,8 @@ export default class extends Component {
};
});
- linkSections = settings.Link_sections.split("|")
+ linkSections = settings.link_sections
+ .split("|")
.filter(Boolean)
.map((section) => {
const fragments = section.split(",").map((fragment) => fragment.trim());
@@ -46,7 +48,8 @@ export default class extends Component {
};
});
- smallLinks = settings.Small_links.split("|")
+ smallLinks = settings.small_links
+ .split("|")
.filter(Boolean)
.map((link) => {
const fragments = link.split(",").map((fragment) => fragment.trim());
@@ -63,7 +66,8 @@ export default class extends Component {
};
});
- socialLinks = settings.Social_links.split("|")
+ socialLinks = settings.social_links
+ .split("|")
.filter(Boolean)
.map((link) => {
const fragments = link.split(",").map((fragment) => fragment.trim());
diff --git a/migrations/settings/0001-rename-settings.js b/migrations/settings/0001-rename-settings.js
new file mode 100644
index 0000000..996c792
--- /dev/null
+++ b/migrations/settings/0001-rename-settings.js
@@ -0,0 +1,41 @@
+export default function migrate(settings) {
+ if (settings.has("Heading")) {
+ settings.set("heading", settings.get("Heading"));
+ settings.delete("Heading");
+ }
+
+ if (settings.has("Blurb")) {
+ settings.set("blurb", settings.get("Blurb"));
+ settings.delete("Blurb");
+ }
+
+ if (settings.has("Link_sections")) {
+ settings.set("link_sections", settings.get("Link_sections"));
+ settings.delete("Link_sections");
+ }
+
+ if (settings.has("Links")) {
+ settings.set("links", settings.get("Links"));
+ settings.delete("Links");
+ }
+
+ if (settings.has("Small_links")) {
+ settings.set("small_links", settings.get("Small_links"));
+ settings.delete("Small_links");
+ }
+
+ if (settings.has("Social_links")) {
+ settings.set("social_links", settings.get("Social_links"));
+ settings.delete("Social_links");
+ }
+
+ if (settings.has("Show_footer_on_login_required_page")) {
+ settings.set(
+ "show_footer_on_login_required_page",
+ settings.get("Show_footer_on_login_required_page")
+ );
+ settings.delete("Show_footer_on_login_required_page");
+ }
+
+ return settings;
+}
diff --git a/settings.yml b/settings.yml
index 1b1f46f..5310347 100644
--- a/settings.yml
+++ b/settings.yml
@@ -1,38 +1,38 @@
-Heading:
+heading:
default: "This is a header"
max: 25
description:
en: "Text for the heading in the footer - you can use your site name for example - Max length 25 characters"
-Blurb:
+blurb:
default: "Ius vitae ornatus at, ei mea sumo quot dicant. Ei tale democritum eos, in mea timeam accumsan forensibus. Ei his aperiam suavitate. Et debitis convenire sea, viris dictas latine."
max: 180
description:
en: "Enter a short blurb about your community - Max length 180 characters"
-Link_sections:
+link_sections:
type: list
list_type: simple
default: "Design, Get inspired!|Code, Learn new things!|Business, Start a new career!|Shop, Buy cool stuff!|Community, The latest news about the people you care about!|World, Check out what's happening"
description:
en: "Add link sections. The ideal number of sections is six. One item per line in this order:
Text, title
Text: what appears on in the footer
Title: the text that appears when the item is hovered."
-Links:
+links:
type: list
list_type: simple
default: "Design, Design process, #, blank, Learn the basics|Design, Blog design, #, blank, What makes for a great blog?|Design, Photoshop tutorials, #, blank, Photoshop for beginners|Design, Design trends, #, blank, Stay on top of the current trends!|Code, Wordpress, #, blank, Wordpress code examples|Code, Tools, #, blank, Tools that will make your life easier!|Code, Tutorials, #, blank, Just starting out? We'll guide you through the basics|Business, Blogging, #, blank, Why not start a blog?|Business, Social media, #, blank, Learn how to leverage Social media and make it work for your business|Business, Make money, #, blank, Everyone likes to be paid!|Business, Marketing, #, blank, No business will survive without customers...Here's how to get'em!|Shop, Vectors, #, blank, buy vectors|Shop, Textures, #, blank, buy textures|Shop, UI kits, #, blank, buy UI kits|Shop, PSDs, #, blank, Ready-made PSD's|Community, Your corner, #, blank, Tell us how you feel!|Community, Questions, #, blank, Feel like answering some questions?|Community, Members, #, blank, Say hi to new members|Community, trending, #, blank, Catch up with the latest trending topics!|World, Politics, #, blank, Stay up to date|World, Education, #, blank, The latest research|World, Automotive, #, blank, We cover the latest models!|World, Sports, #, The latest scores|World, Tech, #, Never miss a new gadget"
description:
en: "Add links to link sections. One item per line in this order:
Parent, text, URL, target, title
It is a good idea to keep the number of links under each section similar
Parent: the name of the parent section which this link shows under. Use the `text` value from the list above
Text: the text that shows for this link
URL: the path this item links to. You can use relative paths as well.
Target: Choose whether this item will open in a new tab or in the same tab. Use blank to open the link in a new tab, or use self to open it in the same tab.
Title: the text that shows when the link is hovered."
-Small_links:
+small_links:
type: list
list_type: simple
default: "Privacy, #, self|Terms of service, #, self| About, #, self"
description:
en: "You can add small links at the bottom of the footer like Terms of Service and Privacy. One item per line in this order:
Text, URL, target
Text: The text that shows for the small link
URL: The path of the link
Target: Use blank to open the link in a new tab and use self to open it in the same tab"
-Social_links:
+social_links:
type: list
list_type: simple
default: "Facebook, Join us on Facebook, #, blank,fab-facebook|Twitter, show some love on Twitter, #, blank,fab-twitter| Youtube, Check out our latest videos on Youtube, #, blank,fab-youtube"
description:
en: "Enter the social links you'd like to add to the footer in this format:
provider, title, URL, target
Provider: is the name of the provider like Facebook or Twitter
Title: The text that shows when the link is hovered
URL: The path you'd like the link to have
Target: Use blank to open the link in a new tab and use self to open it in the same tab
Icon: use a FontAwesome5 icon name (brand icons need a 'fab-' prefix)."
-Show_footer_on_login_required_page:
+show_footer_on_login_required_page:
default: true
description:
en: "Check this setting if you want the footer to be displayed on the login-required page (only applies if your site is private)"
diff --git a/spec/system/footer_spec.rb b/spec/system/footer_spec.rb
index 87c1d32..60054b2 100644
--- a/spec/system/footer_spec.rb
+++ b/spec/system/footer_spec.rb
@@ -4,9 +4,9 @@
let!(:theme) { upload_theme_component }
it "should display the footer" do
- theme.update_setting(:Link_sections, "Section 1, Section 1 title|Section 2, Section 2 title")
+ theme.update_setting(:link_sections, "Section 1, Section 1 title|Section 2, Section 2 title")
theme.update_setting(
- :Links,
+ :links,
"Section 1, Section 1 Link, http://some.url.com/section1/link1, blank, Section 1 Link Title|Section 1, Section 1 Link 2, http://some.url.com/section1/link2, blank, Section 1 Link 2 Title|Section 2, Section 2 Link, http://some.url.com/section2/link1, blank, Section 2 Link Title|Section 2, Section 2 Link 2, http://some.url.com/section2/link2, blank, Section 2 Link 2 Title",
)
theme.save!
@@ -14,8 +14,8 @@
visit("/")
expect(page).to have_css(".below-footer-outlet.custom-footer")
- expect(page).to have_css(".below-footer-outlet .heading", text: theme.get_setting(:Heading))
- expect(page).to have_css(".below-footer-outlet .blurb", text: theme.get_setting(:Blurb))
+ expect(page).to have_css(".below-footer-outlet .heading", text: theme.get_setting(:heading))
+ expect(page).to have_css(".below-footer-outlet .blurb", text: theme.get_setting(:blurb))
within(".below-footer-outlet .links .list[data-easyfooter-section='section-1']") do
expect(page).to have_css("span[title='Section 1 title']", text: "Section 1")
@@ -77,7 +77,7 @@
it "should not display the footer to anon users when `Show_footer_on_login_required_page` is false" do
SiteSetting.login_required = true
- theme.update_setting(:Show_footer_on_login_required_page, false)
+ theme.update_setting(:show_footer_on_login_required_page, false)
theme.save!
visit("/")
diff --git a/test/unit/migrations/settings/0001-rename-settings-test.js b/test/unit/migrations/settings/0001-rename-settings-test.js
new file mode 100644
index 0000000..d3f0a5e
--- /dev/null
+++ b/test/unit/migrations/settings/0001-rename-settings-test.js
@@ -0,0 +1,37 @@
+import { module, test } from "qunit";
+import migrate from "../../../../migrations/settings/0001-rename-settings";
+
+module("Unit | Migrations | Settings | 0001-rename-settings", function () {
+ test("migrate", function (assert) {
+ const settings = new Map(
+ Object.entries({
+ Heading: "some header",
+ Blurb: "some blurb",
+ Link_sections: "section1|section2",
+ Links: "some_links",
+ Small_links: "some,small,links",
+ Social_links: "some,social,links",
+ Show_footer_on_login_required_page: true,
+ })
+ );
+
+ const result = migrate(settings);
+
+ assert.deepEqual(
+ Array.from(result),
+ Array.from(
+ new Map(
+ Object.entries({
+ heading: "some header",
+ blurb: "some blurb",
+ link_sections: "section1|section2",
+ links: "some_links",
+ small_links: "some,small,links",
+ social_links: "some,social,links",
+ show_footer_on_login_required_page: true,
+ })
+ )
+ )
+ );
+ });
+});