question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Epic] Frontend Refactor (Channels)

See original GitHub issue

This is a WIP epic - I’m still working out the steps needed to get from A-B and I’ll break it down into sub tasks/sub issues as and when, in the meantime, the goal is clear and documented here.


The frontend of Ghost - that is the server side code which renders a blog using the active theme - has been somewhat unloved for a little while now. It essentially consists of some hard coded routes in /routes/frontend.js, which in turn call the monolithic functions in /controllers/frontend.js. It’s time for this part of Ghost to be refactored into something more elegant, and importantly, something more extensible.

On the wiki you’ll find a new document, titled Channels 101, which introduces and explains the concept of Channels for the frontend. In short channels are the abstracted concept of a list of posts, i.e. the homepage, the tag archive, the author archive or any other group of posts you could conceive of.

And the very end of the document it talks about working to slowly remove hardcoded bits of the fontend and refactor it into configuration & generation code, before finally moving towards making channels a model & API endpoint just like Posts, Tags and Users.

This issue is the ‘epic’ where we’ll keep track of our progress towards achieving this New World Order.

  • Refactor out the hardcoded slug keywords #4519
  • Convert sitemaps & rpc pings to use events #5069
  • Move RSS from frontend controller & refactor to use events
  • Move post-processing of author data out of the frontend controller #5159
  • Refactor frontend controller #5192

Need to solve:

  • Dynamic routing for channels
  • Pagination when in channel
  • meta data for channels
  • sitemap for channels
  • Improve the channels API

Maybe later:

  • add a channel registration mechanism that works whilst Ghost is running
  • Support offset, rather than page, in the API #2896
  • RSS feeds for each channel linked in that channel
  • Post urls & next/prev post when in channel

Updates: Aug 2017

The current state of channels is that it the functionality is largely refactored and in place, but can only be accessed by modifying the core file channels-config.js. This is because, although the basics are working, advanced behaviour of Ghost isn’t yet properly linked to channels.

Examples of missing pieces (some listed above) are:

  • Sitemaps
  • Meta data
  • RSS feed (URLs only)
  • Next/prev post when in a channel
  • Deep customisation, e.g. disabling RSS feeds

There is also some pure-refactoring that needs to be done: E.g.

  • moving channels to a proper home
  • moving non-channel pieces from controllers/frontend.js to a proper home
  • strengthening the implementation to make channels more of a first class object
  • better/clearer default configuration
  • proper use of express
  • exposing channels without core modification

Basically, we need to iron out a few more of the major pieces, and then expose this config. Short term, we’re going to start publishing blog posts on how to use the functionality that is there by hacking core.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:10
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
RaringCodercommented, Jan 17, 2018

How far off completion is this? I’d love to contribute but I’m no Node developer lol

0reactions
ErisDScommented, Apr 24, 2018

Closing in favour of #9601

Read more comments on GitHub >

github_iconTop Results From Across the Web

React: Refactoring Components - Live Streaming with Jesse
I am going to go through all of my React components and refactor as needed.See a professional front-end developer at work. Unscripted.
Read more >
Refactor Flash Implementation to Use GlAlert (#227846) - GitLab
I have opened !76136 (merged) as a possible solution to this. I'll communicate the MR in the frontend channel and call to gather...
Read more >
Unreal Frontend
UnrealFrontend (UFE) is a tool intended to simplify and speed up daily video game development and testing tasks, such as preparing game builds,...
Read more >
Frontend Quick Tips #10 Refactor - How to Find the Time ...
A refactor is not a Jira task ... Just like tests in your codebase - refactoring is a process that should be implemented...
Read more >
Type annotation via automated refactoring | by Jimmy Lai
The life cycle of a code change starts with applying a refactoring application on a code path and creating a pull request. A...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found