Class: RailsWayback::PagesController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- RailsWayback::PagesController
- Defined in:
- app/controllers/rails_wayback/pages_controller.rb
Overview
JSON endpoints consumed by the bar's JavaScript to populate the branch and commit selectors. All rendering of the actual UI lives in the middleware; this controller only exposes git metadata.
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
Instance Method Details
#branches ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/rails_wayback/pages_controller.rb', line 8 def branches current_branch = safe_call { git.current_branch } current_commit = safe_call { git.current_commit } branches = safe_call { git.branches } render json: { current_branch: current_branch.value, current_commit: current_commit.value, branches: branches.value || [], errors: [branches.error].compact } end |
#commits ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/rails_wayback/pages_controller.rb', line 21 def commits branch = params[:branch].to_s.sub(/\.json\z/, "") result = safe_call { git.commits(branch) } list = (result.value || []).map do |commit| { sha: commit.sha, short_sha: commit.short_sha, subject: commit.subject, author: commit., date: commit.date } end render json: { branch: branch, commits: list, error: result.error } end |