Skip to content
Browse files

Fixed some minor issues in the sample app.

  • Loading branch information...
1 parent 255f555 commit 3d18b1a19303c6a8c39134b6c2177e591f629fbd @cowboy committed
Showing with 61 additions and 21 deletions.
  1. +17 −2 README.md
  2. +41 −18 sample_app/app.rb
  3. +3 −1 sample_app/views/index.haml
View
19 README.md
@@ -6,11 +6,26 @@ Ruby + Git + Content = Gaucho
Warning, this is a work in progress, so YMMV. Tested with Ruby 1.9.2p174 and Git 1.7.2.
-Run this code in your shell:
-
+Run this code in your shell (ignore any # comment lines):
+
+ # clone the repo
+ git clone https://cowboy@github.com/cowboy/gaucho.git
+
+ # install bundler
+ gem install bundler
+
+ # build gem and install all dependencies
+ cd gaucho
+ rake install
+
+ # build test content repo
cd sample_app
ruby create_test_repo.rb
+
+ # install sample app gems
gem install sinatra diffy
+
+ # run sample app
ruby app.rb
And then visit this page: <http://localhost:4567/>
View
59 sample_app/app.rb
@@ -83,9 +83,25 @@ def render_diff(diff)
@title = %Q{Stuff tagged &ldquo;#{tag}&rdquo;}
@tags = [tag]
@cats = @pages.collect {|cat| cat.categories}.flatten.uniq.sort
+ @subindex = true
haml :index
end
+ # CATEGORIES
+ # /{category}
+ get %r{^/([-\w]+)} do |cat|
+ p ['cat', params[:captures]]
+ @pages = $pageset.reset_shown
+ @pages.reject! {|p| p.categories.index(cat).nil?}.sort
+ pass if @pages.empty?
+ @title = %Q{Stuff categorized &ldquo;#{cat}&rdquo;}
+ @tags = @pages.collect {|tag| tag.tags}.flatten.uniq.sort
+ @cats = [cat]
+ @subindex = true
+ haml :index
+ end
+
+=begin
# RECENT CHANGES
# /recent-changes
get '/recent-changes' do
@@ -94,8 +110,10 @@ def render_diff(diff)
@pages.each {|page| p page.commits.last.message}
@tags = []
@cats = []
+ @subindex = true
haml :index
end
+=end
# DATE LISTING
# /{YYYY}
@@ -103,9 +121,12 @@ def render_diff(diff)
# /{YYYY}/{MM}/{DD}
get %r{^/(\d{4})(?:/(\d{2}))?(?:/(\d{2}))?/?$} do |year, month, day|
p ['date', params[:captures]]
- @pages = $all_pages.select {|page| page.date?([year, month, day].compact)}
+ date_arr = [year, month, day].compact
+ @pages = $pageset.reset_shown.select {|page| page.date?(date_arr)}
+ @title = %Q{Stuff dated &ldquo;#{date_arr.join('-')}&rdquo;}
@tags = []
@cats = []
+ @subindex = true
haml :index
end
@@ -121,27 +142,29 @@ def render_diff(diff)
get %r{^(?:/([0-9a-f]{7}))?/((?:\d{4}(?:/\d{2}){0,2}/)?[-\w]+)(?:/(.+))?$} do |sha, name, file|
p ['page', params[:captures]]
- @page = $pageset[name]
- @page.check_local_mods if development?
- @page.shown = sha
+ begin
+ @page = $pageset[name]
+ @page.check_local_mods if development?
+ @page.shown = sha
- if sha && production?
- # cache heavily
- end
+ if sha && production?
+ # cache heavily
+ end
- if file
- content_type File.extname(file) rescue content_type :txt
- @page/file
- else
- @commit = @page.commit
- @commits = @page.commits
- @title = @page.title
- @content = @page.render(@page.content, {no_highlight: true})
+ if file
+ content_type File.extname(file) rescue content_type :txt
+ @page/file
+ else
+ @commit = @page.commit
+ @commits = @page.commits
+ @title = @page.title
+ @content = @page.render(@page.content, {no_highlight: true})
- haml(@page.layout || :page)
+ haml(@page.layout || :page)
+ end
+ rescue
+ raise Sinatra::NotFound
end
- #rescue
- # raise Sinatra::NotFound
end
end
end
View
4 sample_app/views/index.haml
@@ -1,5 +1,7 @@
-%h1= @title
+- if @subindex
+ %a{ href: '/' } &laquo; Index
+%h1= @title
Recent content:
%ul#all_content

0 comments on commit 3d18b1a

Please sign in to comment.
Something went wrong with that request. Please try again.