gidget 0.0.12 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +25 -6
- data/_stub_/config.ru +8 -8
- data/_stub_/posts/first-post.txt +1 -1
- data/_stub_/views/about.haml +7 -7
- data/_stub_/views/archive.haml +7 -7
- data/_stub_/views/index.haml +8 -8
- data/_stub_/views/page.haml +9 -0
- data/_stub_/views/post.haml +8 -8
- data/bin/gidget +15 -15
- data/lib/gidget/server.rb +20 -2
- metadata +4 -3
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= gidget
|
2
2
|
|
3
|
-
|
3
|
+
The smallest taco-loving blog engine in the world!
|
4
4
|
|
5
5
|
Gidget is a minimalist blog engine designed to run on Heroku with a Git-based workflow. It is built upon Sinatra and uses haml and rdiscount for templating and markup. It was largely inspired by Toto, however Gidget is built on top of a DSL to minimize and simplify the code.
|
6
6
|
|
@@ -13,11 +13,10 @@ Gidget is a minimalist blog engine designed to run on Heroku with a Git-based wo
|
|
13
13
|
== Routing
|
14
14
|
|
15
15
|
* / - an index template with access to the full array of posts
|
16
|
-
* /2010 - an archive template with
|
17
|
-
* /2010/11 - an archive template with access to all posts from the specified year/month
|
18
|
-
* /2010/11/19 - an archive template with access to all posts from the specified year/month/day
|
16
|
+
* /2010/11/19 - an archive template with access to all posts from the specified year/month/day as well as what year, month, and day it is for (month and day are optional)
|
19
17
|
* /2010/11/19/first-post - a post template with access to the full array of posts and the current post index
|
20
|
-
* /
|
18
|
+
* /page/1 - a paging template with access to posts for the specified day as well as the current page number and total number of pages
|
19
|
+
* /some-special-page - a custom template with access to the full array of posts
|
21
20
|
|
22
21
|
== Post Creation
|
23
22
|
|
@@ -32,6 +31,26 @@ The second section is the body of the post and uses markdown as it's markup lang
|
|
32
31
|
|
33
32
|
File name and structure (other than the .txt extension) don't matter. Gidget will determine request paths based on the date and title metadata and sort them accordingly.
|
34
33
|
|
34
|
+
== Settings
|
35
|
+
|
36
|
+
Gidget uses Sinatra's built-in setting support. Settings can be set in your config.ru during creation of the Gidget server:
|
37
|
+
|
38
|
+
gidget = Gidget::Server.new do
|
39
|
+
set :title, "My Awesome Blog"
|
40
|
+
set :author, "Your Name Goes Here"
|
41
|
+
set :summary_size, 100
|
42
|
+
set :page_size, 10
|
43
|
+
end
|
44
|
+
|
45
|
+
run gidget
|
46
|
+
|
47
|
+
Settings can then be accessed from within templates by using the settings object:
|
48
|
+
|
49
|
+
!!! 5
|
50
|
+
%html
|
51
|
+
%head
|
52
|
+
%title= settings.title
|
53
|
+
|
35
54
|
== Getting Started
|
36
55
|
|
37
56
|
The following comands install the Gidget gem, create a Gidget app, and then start the app:
|
@@ -64,7 +83,7 @@ Congrats! You now have your own blog running on the internets!
|
|
64
83
|
|
65
84
|
== TO BE DONE
|
66
85
|
|
67
|
-
*
|
86
|
+
* Come up with a decent base theme
|
68
87
|
|
69
88
|
== Contributing to gidget
|
70
89
|
|
data/_stub_/config.ru
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler'
|
3
3
|
|
4
|
-
Bundler.require
|
4
|
+
#Bundler.require
|
5
5
|
|
6
6
|
# The following lines are used for debug during gem development
|
7
7
|
# Comment out previous Bundler.require line to avoid conflicts during development
|
8
|
-
|
9
|
-
|
8
|
+
$: << File.expand_path("../lib")
|
9
|
+
require 'gidget'
|
10
10
|
|
11
|
-
gidget =
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
gidget = Gidget::Server.new do
|
12
|
+
set :title, "My Awesome Blog"
|
13
|
+
set :author, "Your Name Goes Here"
|
14
|
+
set :summary_size, 100
|
15
|
+
set :page_size, 10
|
16
16
|
end
|
17
17
|
|
18
18
|
run gidget
|
data/_stub_/posts/first-post.txt
CHANGED
data/_stub_/views/about.haml
CHANGED
data/_stub_/views/archive.haml
CHANGED
data/_stub_/views/index.haml
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
!!! 5
|
2
2
|
%html
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
%head
|
4
|
+
%title= settings.title
|
5
|
+
%body
|
6
|
+
%header
|
7
|
+
%h1 My Blog
|
8
|
+
%article
|
9
|
+
%h1= posts[0].title
|
10
|
+
= posts[0].body
|
data/_stub_/views/post.haml
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
!!! 5
|
2
2
|
%html
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
%head
|
4
|
+
%title= settings.title
|
5
|
+
%body
|
6
|
+
%header
|
7
|
+
%h1 My Blog
|
8
|
+
%article
|
9
|
+
%h1= posts[index].title
|
10
|
+
= posts[index].body
|
data/bin/gidget
CHANGED
@@ -3,16 +3,16 @@ require 'FileUtils'
|
|
3
3
|
|
4
4
|
|
5
5
|
class App
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
6
|
+
def initialize(arguments, stdin)
|
7
|
+
@arguments = arguments
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
def run
|
12
|
+
source = File.expand_path(File.join(File.dirname(__FILE__), '../_stub_'))
|
13
|
+
destination = File.expand_path(File.join(Dir.pwd, @arguments[0]))
|
14
|
+
|
15
|
+
puts "Creating gidget app stub in destination '#{destination}'"
|
16
16
|
|
17
17
|
if (!File.directory? destination)
|
18
18
|
print " Creating destination ... "
|
@@ -23,11 +23,11 @@ class App
|
|
23
23
|
end
|
24
24
|
|
25
25
|
print " Copying stub ... "
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
FileUtils.cp_r(source + "/.", destination)
|
27
|
+
puts "done."
|
28
|
+
|
29
|
+
puts "Done."
|
30
|
+
end
|
31
31
|
end
|
32
32
|
|
33
33
|
|
data/lib/gidget/server.rb
CHANGED
@@ -36,12 +36,30 @@ module Gidget
|
|
36
36
|
end
|
37
37
|
|
38
38
|
|
39
|
-
get %r{
|
39
|
+
get %r{^\/(\d{4})(\/(\d{2})(\/(\d{2}))?)?$} do
|
40
|
+
year = params[:captures][0]
|
41
|
+
month = params[:captures][2]
|
42
|
+
day = params[:captures][4]
|
43
|
+
|
40
44
|
posts = PostIndex.instance.select { |p|
|
41
45
|
p.request_path =~ %r{^#{request.path}}
|
42
46
|
}
|
43
47
|
|
44
|
-
render_view(:archive, { :posts => posts })
|
48
|
+
render_view(:archive, { :posts => posts, :year => year, :month => month, :day => day })
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
get %r{^\/page\/(\d+$)} do
|
53
|
+
current_page = params[:captures][0].to_i
|
54
|
+
total_pages = (PostIndex.instance.size + settings.page_size - 1) / settings.page_size
|
55
|
+
|
56
|
+
if (current_page <= total_pages)
|
57
|
+
posts = PostIndex.instance[(current_page - 1) * settings.page_size, settings.page_size]
|
58
|
+
|
59
|
+
render_view(:page, { :posts => posts, :current_page => current_page, :total_pages => total_pages })
|
60
|
+
else
|
61
|
+
pass
|
62
|
+
end
|
45
63
|
end
|
46
64
|
|
47
65
|
|
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: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.12
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Forrest Robertson
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- _stub_/views/about.haml
|
143
143
|
- _stub_/views/archive.haml
|
144
144
|
- _stub_/views/index.haml
|
145
|
+
- _stub_/views/page.haml
|
145
146
|
- _stub_/views/post.haml
|
146
147
|
- lib/gidget.rb
|
147
148
|
- lib/gidget/ext.rb
|