- The primary view template at
app/views/layouts/application.html.erb
loads: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.erb
calls all initializers related to page dataapp/assets/javascripts/initializers/initializeBaseUserData.js
- involved in prepping data for home page
config/routes.rb
handles 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:index
action for main feed, which calls:- 'handle_base_index`, which renders:
articles/index
view/template, which is located at:app/views/articles/index.html.erb
, which usesjavascript_pack_tag
to load Preact components:app/javascript/packs/homePage.jsx
, homePage component, which in turn imports:app/javascript/packs/homePageFeed.jsx
which renders the articles.
app/views/articles/index.html.erb
also 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.rb
handles HTTP GET request, and on line 403:get "/:username/:slug/:view" => "stories#show"
routes to:app/controllers/stories_controller.rb
, specifically the:show
action, 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
show
action also declares an@article
instance 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
.decorate
on 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 (