This repository has been archived by the owner on Apr 4, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move different parts of Crankypants into their own router classes.
- Loading branch information
Showing
6 changed files
with
75 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
require "kilt" | ||
require "kilt/slang" | ||
|
||
require "./assets" | ||
|
||
module Crankypants | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require "../../../crappy" | ||
require "../../../crappy/authentication" | ||
|
||
module Crankypants::Web::Routers | ||
class App < Crappy::Router | ||
include Helpers | ||
include Crappy::Authentication | ||
|
||
def call | ||
within "app" do | ||
protect_with ENV["CRANKY_LOGIN"], ENV["CRANKY_PASSWORD"] do | ||
render text: Kilt.render("src/crankypants/web/views/app.slang"), content_type: "text/html" | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require "../../../crappy" | ||
require "../../../crappy/authentication" | ||
|
||
module Crankypants::Web::Routers | ||
class Assets < Crappy::Router | ||
include Helpers | ||
include Crappy::Authentication | ||
|
||
def call | ||
{% if flag?(:release) %} | ||
within "assets" do | ||
within :version do | ||
get :filename do |params| | ||
serve_static_asset "assets/#{params["filename"]}" | ||
end | ||
end | ||
end | ||
{% end %} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require "../../../crappy" | ||
require "../../../crappy/authentication" | ||
|
||
module Crankypants::Web::Routers | ||
class Blog < Crappy::Router | ||
include Helpers | ||
include Crappy::Authentication | ||
|
||
def call | ||
get do | ||
render html: PostView.index(Data.load_posts) | ||
end | ||
|
||
within "posts" do | ||
get :id do |params| | ||
post_id = params["id"].not_nil!.to_i | ||
render html: PostView.show(Data.load_post(post_id)) | ||
end | ||
end | ||
end | ||
end | ||
end |