gidget 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +3 -4
- data/_stub_/views/post.haml +2 -2
- data/bin/gidget +16 -5
- data/lib/gidget/post_index.rb +0 -3
- data/lib/gidget/server.rb +18 -17
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -16,7 +16,7 @@ Gidget is a minimalist blog engine designed to run on Heroku with a Git-based wo
|
|
16
16
|
* /2010 - an archive template with all access to all posts from the specified year
|
17
17
|
* /2010/11 - an archive template with access to all posts from the specified year/month
|
18
18
|
* /2010/11/19 - an archive template with access to all posts from the specified year/month/day
|
19
|
-
* /2010/11/19/first-post - a post template with access to the
|
19
|
+
* /2010/11/19/first-post - a post template with access to the full array of posts and the current post index
|
20
20
|
* /some-special-page - a page template with access to the full array of posts
|
21
21
|
|
22
22
|
== Post Creation
|
@@ -44,15 +44,14 @@ Once them gem is installed you can use the gidget generator to create a stub for
|
|
44
44
|
|
45
45
|
gidget blog
|
46
46
|
|
47
|
-
This would create a stub in a directory named blog. To run the site simply run rackup from the root:
|
47
|
+
This would create a stub in a directory named blog (it will create the directory if it doesn't already exist). To run the site simply run rackup from the root:
|
48
48
|
|
49
49
|
cd blog
|
50
50
|
rackup
|
51
51
|
|
52
52
|
== TO BE DONE
|
53
53
|
|
54
|
-
* Add a paging route to allow /page/1 type usage.
|
55
|
-
* Update the post route to pass the array of all posts and the current post index. This allows for previous/next links for each post to be created by the template.
|
54
|
+
* Add a paging route to allow /page/1 type usage. Need to determine best way of handling options/setting such as page_size.
|
56
55
|
|
57
56
|
== Contributing to gidget
|
58
57
|
|
data/_stub_/views/post.haml
CHANGED
data/bin/gidget
CHANGED
@@ -9,13 +9,24 @@ class App
|
|
9
9
|
|
10
10
|
|
11
11
|
def run
|
12
|
-
|
13
|
-
|
14
|
-
source = File.expand_path(File.join(File.dirname(__FILE__), '../_stub_'))
|
12
|
+
source = File.expand_path(File.join(File.dirname(__FILE__), '../_stub_'))
|
15
13
|
destination = File.expand_path(File.join(Dir.pwd, @arguments[0]))
|
16
|
-
|
17
|
-
|
14
|
+
|
15
|
+
puts "Creating gidget app stub in destination '#{destination}'"
|
16
|
+
|
17
|
+
if (!File.directory? destination)
|
18
|
+
print " Creating destination ... "
|
19
|
+
FileUtils.mkdir_p(destination)
|
20
|
+
puts "done."
|
21
|
+
else
|
22
|
+
puts " Destination exists."
|
23
|
+
end
|
24
|
+
|
25
|
+
print " Copying stub ... "
|
18
26
|
FileUtils.cp_r(source + "/.", destination)
|
27
|
+
puts "done."
|
28
|
+
|
29
|
+
puts "Done."
|
19
30
|
end
|
20
31
|
end
|
21
32
|
|
data/lib/gidget/post_index.rb
CHANGED
data/lib/gidget/server.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'sinatra/base'
|
2
|
+
require 'haml'
|
3
|
+
require 'rdiscount'
|
2
4
|
require 'gidget/post_index'
|
3
5
|
|
4
6
|
|
@@ -7,27 +9,23 @@ module Gidget
|
|
7
9
|
set :haml, :format => :html5
|
8
10
|
|
9
11
|
|
10
|
-
get '/' do
|
11
|
-
|
12
|
-
|
13
|
-
haml :index, :locals => { :posts => PostIndex.instance }
|
12
|
+
get '/' do
|
13
|
+
render_view(:index, { :posts => PostIndex.instance })
|
14
14
|
end
|
15
15
|
|
16
16
|
|
17
17
|
get %r{^\/\d{4}\/\d{2}\/\d{2}\/\w+} do
|
18
|
-
|
18
|
+
index = nil
|
19
19
|
|
20
|
-
PostIndex.instance.
|
20
|
+
PostIndex.instance.each_with_index { |p, i|
|
21
21
|
if (p[:request_path] == request.path)
|
22
|
-
|
22
|
+
index = i
|
23
23
|
break
|
24
24
|
end
|
25
25
|
}
|
26
26
|
|
27
|
-
if (
|
28
|
-
|
29
|
-
|
30
|
-
haml :post, :locals => { :post => post }
|
27
|
+
if (index != nil)
|
28
|
+
render_view(:post, { :posts => PostIndex.instance, :index => index })
|
31
29
|
end
|
32
30
|
end
|
33
31
|
|
@@ -36,21 +34,24 @@ module Gidget
|
|
36
34
|
posts = PostIndex.instance.select { |p|
|
37
35
|
p[:request_path] =~ %r{^#{request.path}}
|
38
36
|
}
|
39
|
-
|
40
|
-
expires(86400, :public)
|
41
37
|
|
42
|
-
|
38
|
+
render_view(:archive, { :posts => posts })
|
43
39
|
end
|
44
40
|
|
45
41
|
|
46
42
|
get %r{^\/\w+} do
|
47
43
|
begin
|
48
|
-
|
49
|
-
|
50
|
-
haml request.path.to_sym, :locals => { :posts => PostIndex.instance }
|
44
|
+
render_view(request.path.to_sym, { :posts => PostIndex.instance })
|
51
45
|
rescue
|
52
46
|
pass
|
53
47
|
end
|
54
48
|
end
|
49
|
+
|
50
|
+
|
51
|
+
def render_view(view, locals)
|
52
|
+
expires(86400, :public)
|
53
|
+
|
54
|
+
haml view, :locals => locals
|
55
|
+
end
|
55
56
|
end
|
56
57
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gidget
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 8
|
10
|
+
version: 0.0.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Forrest Robertson
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-22 00:00:00 -07:00
|
19
19
|
default_executable: gidget
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|