Skip to content

Commit af4d271

Browse files
committed
API layout
1 parent 9431399 commit af4d271

7 files changed

Lines changed: 19 additions & 8 deletions

File tree

app/controllers/api_controller.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
class ApiController < ApplicationController
2-
layout false
32
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
class ApplicationController < ActionController::Base
22
protect_from_forgery
3+
helper_method :title
4+
5+
def title t=nil
6+
@title = t unless t.blank?
7+
@title
8+
end
39
end

app/controllers/static_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class StaticController < ApplicationController
22
def root; end
3-
def api_root; render :layout => false; end
3+
def api_root; render :layout => "api"; end
44
def newest_version
55
render :json => {:version => "1.0.0"}
66
end

app/views/api/rels/index.html.haml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
%h1 All rels
1+
- title "All rels"
22

33
%p Here's a list of all of the relations the API supports:
44

55
%ul
66
- @rels.each do |rel|
77
%li= link_to rel.slug, rel
8-
9-
%p= link_to "Back to API root", root_path, :rel => "root"

app/views/api/rels/show.html.haml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
%h1= "The '#{@rel.slug}' Relation"
1+
- title "The '#{@rel.slug}' Relation"
22

33
%p= @rel.description
44

55
%p= link_to "Back to list of all rels", rels_path, :rel => "/rels/rel-index"
6-
%p= link_to "Back to API root", root_path, :rel => "root"

app/views/layouts/api.html.haml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
!!! 5
2+
%html
3+
%head
4+
%title Hackety Hack API: #{title}
5+
%body
6+
%h1 Hackety Hack API: #{title}
7+
= yield
8+
%footer
9+
You can go #{link_to "back to the API root", root_path}

app/views/static/api_root.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
%h1 Welcome to the Hackety Hack API!
1+
= title "Welcome"
22

33
%p!= "For a list of the relations we've defined for this API, go " + link_to("here", rels_path, :rel => "/rels/rel-index")
44
%p!= "You can find the latest released version of Hackety Hack " + link_to("here", newest_version_path, :rel => "/rels/current-application-version") + "."

0 commit comments

Comments
 (0)