Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
tgxworld committed Apr 9, 2024
1 parent a677b33 commit 62031a7
Show file tree
Hide file tree
Showing 6 changed files with 364 additions and 72 deletions.
19 changes: 11 additions & 8 deletions javascripts/discourse/components/custom-footer.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,29 @@
</div>
<div class="second-box">
<div class="links">
{{#each this.linkSections as |section|}}
<div class="list" data-easyfooter-section={{section.dataName}}>
{{#each (theme-setting "sections") as |section|}}
<div
class="list"
data-easyfooter-section={{dasherize section.name}}
>
<span title={{section.title}}>
{{section.text}}
{{section.name}}
</span>

<ul>
{{#each section.childLinks as |link|}}
{{#each section.links as |link|}}
<li
class="footer-section-link-wrapper"
data-easyfooter-link={{link.dataName}}
data-easyfooter-link={{dasherize link.name}}
>
<a
class="footer-section-link"
title={{link.title}}
href={{link.href}}
href={{link.url}}
target={{link.target}}
referrerpolicy={{link.referrerpolicy}}
referrerpolicy={{link.referrer_policy}}
>
{{link.text}}
{{link.name}}
</a>
</li>
{{/each}}
Expand Down
45 changes: 0 additions & 45 deletions javascripts/discourse/components/custom-footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,6 @@ export default class extends Component {
mainHeading = settings.heading;
blurb = settings.blurb;

linkArray = settings.links
.split("|")
.filter(Boolean)
.map((link) => {
const fragments = link.split(",").map((fragment) => fragment.trim());
const parent = fragments[0].toLowerCase();
const text = fragments[1];
const dataName = dasherize(text);
const href = fragments[2];
const target = fragments[3] === "blank" ? "_blank" : "";
const title = fragments[4];
const referrerpolicy = fragments[5];

return {
parent,
text,
dataName,
href,
target,
title,
referrerpolicy,
};
});

linkSections = settings.link_sections
.split("|")
.filter(Boolean)
.map((section) => {
const fragments = section.split(",").map((fragment) => fragment.trim());
const parentFor = fragments[0].toLowerCase();
const text = fragments[0];
const title = fragments[1];
const dataName = dasherize(text);
const childLinks = this.linkArray.filter(
(link) => link.parent === parentFor
);

return {
text,
title,
dataName,
childLinks,
};
});

smallLinks = settings.small_links
.split("|")
.filter(Boolean)
Expand Down
74 changes: 74 additions & 0 deletions migrations/settings/0002-migrate-settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
export default function migrate(settings) {
const oldLinkSections = settings.get("link_sections");

if (oldLinkSections) {
const newLinkSections = oldLinkSections.split("|").map((linkSection) => {
const [linkSectionName, linkSectionTitle] = linkSection
.split(",")
.map((value) => value.trim());

return {
name: linkSectionName,
title: linkSectionTitle,
};
});

const oldLinkSectionLinks = settings.get("links");

if (oldLinkSectionLinks) {
oldLinkSectionLinks.split("|").map((linkSectionLink) => {
const [
linkSectionName,
linkName,
linkUrl,
linkTarget,
linkTitle,
linkReferralPolicy,
] = linkSectionLink.split(",").map((value) => value.trim());

const linkSection = newLinkSections.find(
(section) => section.name === linkSectionName
);

if (linkSection) {
if (!linkSection.links) {
linkSection.links = [];
}

let target;

switch (linkTarget) {
case "blank":
target = "_blank";
break;
case "self":
target = "_self";
break;
default:
break;
}

const link = {
name: linkName,
url: linkUrl,
title: linkTitle,
};

if (target) {
link.target = target;
}

if (linkReferralPolicy) {
link.referral_policy = linkReferralPolicy;
}

linkSection.links.push(link);
}
});
}

settings.set("sections", newLinkSections);
}

return settings;
}
162 changes: 154 additions & 8 deletions settings.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,173 @@
heading:
default: "This is a header"
max: 25

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
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"
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"

sections:
type: objects
default:
- name: Design
title: Get inspired!
links:
- name: Design process
url: "#"
title: Learn the basics
- name: Blog design
url: "#"
title: What makes for a great blog?
- name: Photoshop tutorials
url: "#"
title: Photoshop for beginners
- name: Design trends
url: "#"
title: Stay on top of the current trends!
- name: Code
title: Learn new things!
links:
- name: Wordpress
url: "#"
title: Wordpress code examples
- name: Tools
url: "#"
title: Tools that will make your life easier!
- name: Tutorials
url: "#"
title: Just starting out? We'll guide you through the basics
- name: Business
title: Start a new career!
links:
- name: Blogging
url: "#"
title: Why not start a blog?
- name: Social media
url: "#"
title: Learn how to leverage Social media and make it work for your business
- name: Make money
url: "#"
title: Everyone likes to be paid!
- name: Marketing
url: "#"
title: No business will survive without customers...Here's how to get'em!
- name: Shop
title: Buy cool stuff!
links:
- name: Vectors
url: "#"
title: buy vectors
- name: Textures
url: "#"
title: buy textures
- name: UI kits
url: "#"
title: buy UI kits
- name: PSDs
url: "#"
title: Ready-made PSD's
- name: Community
title: The latest news about the people you care about!
links:
- name: Your corner
url: "#"
title: Tell us how you feel!
- name: Questions
url: "#"
title: Feel like answering some questions?
- name: Members
url: "#"
title: Say hi to new members
- name: trending
url: "#"
title: Catch up with the latest trending topics!
- name: World
title: Check out what's happening
links:
- name: Politics
url: "#"
title: Stay up to date
- name: Education
url: "#"
title: The latest research
- name: Automotive
url: "#"
title: We cover the latest models!
- name: Sports
url: "#"
title: The latest scores
- name: Tech
url: "#"
title: Never miss a new gadget
schema:
name: link section
properties:
name:
type: string
required: true
validations:
min: 1
max: 1000
title:
type: string
required: true
validations:
min: 1
max: 1000
links:
type: objects
schema:
name: link
properties:
name:
type: string
required: true
validations:
min: 1
max: 1000
url:
type: string
required: true
validations:
min: 1
max: 2048
target:
type: enum
default: _blank
choices:
- _blank
- _self
- _parent
- _top
title:
type: string
required: true
validations:
min: 1
max: 1000
referrer_policy:
type: enum
default: no-referrer-when-downgrade
choices:
- no-referrer
- no-referrer-when-downgrade
- origin
- origin-when-cross-origin
- unsafe-url

small_links:
type: list
list_type: simple
default: "Privacy, #, self|Terms of service, #, self| About, #, self"

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"

show_footer_on_login_required_page:
default: true

svg_icons:
default: "fab-facebook|fab-twitter|fab-youtube"
type: "list"
Expand Down
Loading

0 comments on commit 62031a7

Please sign in to comment.