- The primary view template at
app/views/layouts/application.html.erbloads:app/assets/javascripts/application.js, which loads all JS files.
- Instant Click loads data in the background when users mouse over links, using:
app/assets/javascripts/base.js.erb- calls various initializersapp/assets/javascripts/initializePage.js.erbcalls all initializers related to page dataapp/assets/javascripts/initializers/initializeBaseUserData.js- involved in prepping data for home page
config/routes.rbhandles HTTP GET requests, and on line 415:- default '/' root URI routes to
stories_controller#index, which is here:app/controllers/stories_controller.rb, specifically the:indexaction for main feed, which calls:- 'handle_base_index`, which renders:
articles/indexview/template, which is located at:app/views/articles/index.html.erb, which usesjavascript_pack_tagto load Preact components:app/javascript/packs/homePage.jsx, homePage component, which in turn imports:app/javascript/packs/homePageFeed.jsxwhich renders the articles.
app/views/articles/index.html.erbalso renders these partials:app/views/articles/_sidebar.html.erb, which in turn renders:app/views/articles/_sidebar_nav.html.erb, which contains the area we want to link to Collections.
- 'handle_base_index`, which renders:
- default '/' root URI routes to
config/routes.rbhandles HTTP GET request, and on line 403:get "/:username/:slug/:view" => "stories#show"routes to:app/controllers/stories_controller.rb, specifically the:showaction, which calls:handle_article_show, which renders:app/views/articles/show.html.erb, which has bulk of content and also renders:app/views/articles/_actions.html.erb, which has the social media buttons.
- the
showaction also declares an@articleinstance variable (passed toshow.html.erb) which:- runs an ActiveRecord query against the Article model (
app/models/article.rb):Article.find_by(path: "/#{params[:username].downcase}/#{params[:slug]}")- it then calls
.decorateon the found article object, which gives it methods from:app/decorators/article_decorator.rb, a "Decorator" file using the Draper gem/library.
- it then calls
- runs an ActiveRecord query against the Article model (