gidget 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,20 +1,20 @@
1
- Copyright (c) 2010 hasmanytrees
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright (c) 2010 hasmanytrees
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,83 +1,83 @@
1
- = gidget
2
-
3
- _The smallest taco-loving blog engine in the world!_ (anyone remember 'Yo quiero Taco Bell'?)
4
-
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
-
7
- == Basic Structure
8
-
9
- * Sinatra based server
10
- * A singleton array containing post information (the body of a post is lazily-loaded)
11
- * A class to handle post information
12
-
13
- == Routing
14
-
15
- * / - an index template with access to the full array of posts
16
- * /2010 - an archive template with all access to all posts from the specified year
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
19
- * /2010/11/19/first-post - a post template with access to the full array of posts and the current post index
20
- * /some-special-page - a page template with access to the full array of posts
21
-
22
- == Post Creation
23
-
24
- Posts are simply .txt files located under a folder named posts located off the root of the web app. Text files contain two sections of data. The first is metadata including at least a title and date as such:
25
-
26
- title: My great post title
27
- date: 2010-11-19
28
-
29
- _Hello World!_ This is my first blog post!
30
-
31
- The second section is the body of the post and uses markdown as it's markup language. The two sections should be separated by an empty line.
32
-
33
- 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
-
35
- == Getting Started
36
-
37
- The following comands install the Gidget gem, create a Gidget app, and then start the app:
38
-
39
- gem install gidget
40
- gidget my-gidget-app
41
- cd my-gidget-app
42
- rackup
43
-
44
- At this point you should be able to view your blog by visiting: http://localhost:9292
45
-
46
- == Adding Source Control
47
-
48
- Before you can host yoru app on Heroku, you must be using Git for source control. Run the following from your app directory to create a new git repository and add all your app code to it:
49
-
50
- git init
51
- git add *
52
- git commit -a -m "Initial load"
53
-
54
- == Deploy To Heroku
55
-
56
- In order to deploy an app to Heroku you must have an account with them. Once you have your account, deploying to Heroku is super easy thanks to their gem:
57
-
58
- gem install heroku
59
- heroku create
60
- git push heroku master
61
- heroku open
62
-
63
- Congrats! You now have your own blog running on the internets!
64
-
65
- == TO BE DONE
66
-
67
- * Possibly add a paging route to allow /page/1 type usage. Need to determine best way of handling options/setting such as page_size.
68
-
69
- == Contributing to gidget
70
-
71
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
72
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
73
- * Fork the project
74
- * Start a feature/bugfix branch
75
- * Commit and push until you are happy with your contribution
76
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
77
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
78
-
79
- == Copyright
80
-
81
- Copyright (c) 2010 hasmanytrees. See LICENSE.txt for
82
- further details.
83
-
1
+ = gidget
2
+
3
+ _The smallest taco-loving blog engine in the world!_ (anyone remember 'Yo quiero Taco Bell'?)
4
+
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
+
7
+ == Basic Structure
8
+
9
+ * Sinatra based server
10
+ * A singleton array containing post information (the body of a post is lazily-loaded)
11
+ * A class to handle post information
12
+
13
+ == Routing
14
+
15
+ * / - an index template with access to the full array of posts
16
+ * /2010 - an archive template with all access to all posts from the specified year
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
19
+ * /2010/11/19/first-post - a post template with access to the full array of posts and the current post index
20
+ * /some-special-page - a page template with access to the full array of posts
21
+
22
+ == Post Creation
23
+
24
+ Posts are simply .txt files located under a folder named posts located off the root of the web app. Text files contain two sections of data. The first is metadata including at least a title and date as such:
25
+
26
+ title: My great post title
27
+ date: 2010-11-19
28
+
29
+ _Hello World!_ This is my first blog post!
30
+
31
+ The second section is the body of the post and uses markdown as it's markup language. The two sections should be separated by an empty line.
32
+
33
+ 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
+
35
+ == Getting Started
36
+
37
+ The following comands install the Gidget gem, create a Gidget app, and then start the app:
38
+
39
+ gem install gidget
40
+ gidget my-gidget-app
41
+ cd my-gidget-app
42
+ rackup
43
+
44
+ At this point you should be able to view your blog by visiting: http://localhost:9292
45
+
46
+ == Adding Source Control
47
+
48
+ Before you can host yoru app on Heroku, you must be using Git for source control. Run the following from your app directory to create a new git repository and add all your app code to it:
49
+
50
+ git init
51
+ git add *
52
+ git commit -a -m "Initial load"
53
+
54
+ == Deploy To Heroku
55
+
56
+ In order to deploy an app to Heroku you must have an account with them. Once you have your account, deploying to Heroku is super easy thanks to their gem:
57
+
58
+ gem install heroku
59
+ heroku create
60
+ git push heroku master
61
+ heroku open
62
+
63
+ Congrats! You now have your own blog running on the internets!
64
+
65
+ == TO BE DONE
66
+
67
+ * Possibly add a paging route to allow /page/1 type usage. Need to determine best way of handling options/setting such as page_size.
68
+
69
+ == Contributing to gidget
70
+
71
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
72
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
73
+ * Fork the project
74
+ * Start a feature/bugfix branch
75
+ * Commit and push until you are happy with your contribution
76
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
77
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
78
+
79
+ == Copyright
80
+
81
+ Copyright (c) 2010 hasmanytrees. See LICENSE.txt for
82
+ further details.
83
+
@@ -1,2 +1,2 @@
1
- source "http://rubygems.org"
2
- gem "gidget"
1
+ source "http://rubygems.org"
2
+ gem "gidget"
@@ -1,6 +1,6 @@
1
- require 'rubygems'
2
- require 'bundler'
3
-
4
- Bundler.require
5
-
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ Bundler.require
5
+
6
6
  run Gidget::Server
@@ -1,4 +1,4 @@
1
- title: This is the awesome title to a post
2
- date: 2010-11-15
3
-
1
+ title: This is the awesome title to a post
2
+ date: 2010-11-15
3
+
4
4
  Hello world!
@@ -1,9 +1,9 @@
1
- !!! 5
2
- %html
3
- %head
4
- %title My Awesome Site
5
- %body
6
- %header
7
- %h1 About
8
- %article
1
+ !!! 5
2
+ %html
3
+ %head
4
+ %title My Awesome Site
5
+ %body
6
+ %header
7
+ %h1 About
8
+ %article
9
9
  %p This blog is run by Gidget.
@@ -1,9 +1,9 @@
1
- !!! 5
2
- %html
3
- %head
4
- %title My Awesome Site
5
- %body
6
- %header
7
- %h1 My Blog
8
- %article
1
+ !!! 5
2
+ %html
3
+ %head
4
+ %title My Awesome Site
5
+ %body
6
+ %header
7
+ %h1 My Blog
8
+ %article
9
9
  %h1= "I found #{posts.size} posts!"
@@ -1,10 +1,10 @@
1
- !!! 5
2
- %html
3
- %head
4
- %title My Awesome Site
5
- %body
6
- %header
7
- %h1 My Blog
8
- %article
9
- %h1= posts[0][:title]
1
+ !!! 5
2
+ %html
3
+ %head
4
+ %title My Awesome Site
5
+ %body
6
+ %header
7
+ %h1 My Blog
8
+ %article
9
+ %h1= posts[0][:title]
10
10
  = markdown(posts[0][:body])
@@ -1,10 +1,10 @@
1
- !!! 5
2
- %html
3
- %head
4
- %title My Awesome Site
5
- %body
6
- %header
7
- %h1 My Blog
8
- %article
9
- %h1= posts[index][:title]
1
+ !!! 5
2
+ %html
3
+ %head
4
+ %title My Awesome Site
5
+ %body
6
+ %header
7
+ %h1 My Blog
8
+ %article
9
+ %h1= posts[index][:title]
10
10
  = markdown(posts[index][:body])
data/bin/gidget CHANGED
@@ -1,35 +1,35 @@
1
- #!/usr/bin/env ruby
2
- require 'FileUtils'
3
-
4
-
5
- class App
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
-
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 ... "
26
- FileUtils.cp_r(source + "/.", destination)
27
- puts "done."
28
-
29
- puts "Done."
30
- end
31
- end
32
-
33
-
34
- app = App.new(ARGV, STDIN)
1
+ #!/usr/bin/env ruby
2
+ require 'FileUtils'
3
+
4
+
5
+ class App
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
+
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 ... "
26
+ FileUtils.cp_r(source + "/.", destination)
27
+ puts "done."
28
+
29
+ puts "Done."
30
+ end
31
+ end
32
+
33
+
34
+ app = App.new(ARGV, STDIN)
35
35
  app.run
@@ -1,10 +1,10 @@
1
- class String
2
- def slugize
3
- self.downcase.gsub(/&/, 'and').gsub(/\s+/, '-').gsub(/[^a-z0-9-]/, '')
4
- end
5
-
6
-
7
- def humanize
8
- self.capitalize.gsub(/[-_]+/, ' ')
9
- end
1
+ class String
2
+ def slugize
3
+ self.downcase.gsub(/&/, 'and').gsub(/\s+/, '-').gsub(/[^a-z0-9-]/, '')
4
+ end
5
+
6
+
7
+ def humanize
8
+ self.capitalize.gsub(/[-_]+/, ' ')
9
+ end
10
10
  end
@@ -1,34 +1,34 @@
1
- require 'yaml'
2
- require 'gidget/ext'
3
-
4
-
5
- module Gidget
6
- class Post < Hash
7
- def initialize(file_path)
8
- file = File.open(file_path, "r")
9
-
10
- # read the first paragraph and load it into a Hash with symbols as keys
11
- self.update(YAML.load(file.gets("")).inject({}) { |h, (k,v)| h.merge(k.to_sym => v) })
12
-
13
- file.close()
14
-
15
- self[:file_path] = file_path
16
-
17
- self[:request_path] = self[:date].strftime("/%Y/%m/%d/") + self[:title].slugize
18
-
19
- self[:body] = lambda {
20
- file = File.open(file_path, "r")
21
-
22
- # ignore the first paragraph
23
- file.gets("")
24
-
25
- # capture the rest of the file
26
- body = file.gets(nil)
27
-
28
- file.close()
29
-
30
- return body
31
- }
32
- end
33
- end
1
+ require 'yaml'
2
+ require 'gidget/ext'
3
+
4
+
5
+ module Gidget
6
+ class Post < Hash
7
+ def initialize(file_path)
8
+ file = File.open(file_path, "r")
9
+
10
+ # read the first paragraph and load it into a Hash with symbols as keys
11
+ self.update(YAML.load(file.gets("")).inject({}) { |h, (k,v)| h.merge(k.to_sym => v) })
12
+
13
+ file.close()
14
+
15
+ self[:file_path] = file_path
16
+
17
+ self[:request_path] = self[:date].strftime("/%Y/%m/%d/") + self[:title].slugize
18
+
19
+ self[:body] = lambda {
20
+ file = File.open(file_path, "r")
21
+
22
+ # ignore the first paragraph
23
+ file.gets("")
24
+
25
+ # capture the rest of the file
26
+ body = file.gets(nil)
27
+
28
+ file.close()
29
+
30
+ return body
31
+ }
32
+ end
33
+ end
34
34
  end
@@ -1,22 +1,22 @@
1
- require 'singleton'
2
- require 'gidget/post'
3
-
4
-
5
- module Gidget
6
- class PostIndex < Array
7
- include Singleton
8
-
9
-
10
- def initialize
11
- paths = Dir.glob("posts/**/*.txt")
12
-
13
- paths.each { |file_path|
14
- self << Post.new(file_path)
15
- }
16
-
17
- self.replace self.sort_by { |p| p[:request_path] }.reverse!
18
-
19
- puts "Post Index created, size = " + self.size.to_s
20
- end
21
- end
1
+ require 'singleton'
2
+ require 'gidget/post'
3
+
4
+
5
+ module Gidget
6
+ class PostIndex < Array
7
+ include Singleton
8
+
9
+
10
+ def initialize
11
+ paths = Dir.glob("posts/**/*.txt")
12
+
13
+ paths.each { |file_path|
14
+ self << Post.new(file_path)
15
+ }
16
+
17
+ self.replace self.sort_by { |p| p[:request_path] }.reverse!
18
+
19
+ puts "Post Index created, size = " + self.size.to_s
20
+ end
21
+ end
22
22
  end
@@ -1,57 +1,80 @@
1
- require 'sinatra/base'
2
- require 'haml'
3
- require 'rdiscount'
4
- require 'gidget/post_index'
5
-
6
-
7
- module Gidget
8
- class Server < Sinatra::Base
9
- set :haml, :format => :html5
10
-
11
-
12
- get '/' do
13
- render_view(:index, { :posts => PostIndex.instance })
14
- end
15
-
16
-
17
- get %r{^\/\d{4}\/\d{2}\/\d{2}\/\w+} do
18
- index = nil
19
-
20
- PostIndex.instance.each_with_index { |p, i|
21
- if (p[:request_path] == request.path)
22
- index = i
23
- break
24
- end
25
- }
26
-
27
- if (index != nil)
28
- render_view(:post, { :posts => PostIndex.instance, :index => index })
29
- end
30
- end
31
-
32
-
33
- get %r{^\/\d{4}(\/\d{2}(\/\d{2})?)?$} do
34
- posts = PostIndex.instance.select { |p|
35
- p[:request_path] =~ %r{^#{request.path}}
36
- }
37
-
38
- render_view(:archive, { :posts => posts })
39
- end
40
-
41
-
42
- get %r{^\/\w+} do
43
- begin
44
- render_view(request.path.to_sym, { :posts => PostIndex.instance })
45
- rescue
46
- pass
47
- end
48
- end
49
-
50
-
51
- def render_view(view, locals)
52
- expires(86400, :public)
53
-
54
- haml view, :locals => locals
55
- end
56
- end
1
+ require 'sinatra/base'
2
+ require 'haml'
3
+ require 'rdiscount'
4
+ require 'gidget/post_index'
5
+
6
+
7
+ module Gidget
8
+ class Server < Sinatra::Base
9
+ set :haml, :format => :html5
10
+
11
+ set :page_size, 5
12
+
13
+ def initialize(app=nil, &block)
14
+ super(app, &block)
15
+ instance_eval(&block) if block_given?
16
+ end
17
+
18
+
19
+ def set(option, value=self, &block)
20
+ self.class.set(option, value, &block)
21
+ end
22
+
23
+
24
+ def enable(*opts)
25
+ self.class.enable(*opts)
26
+ end
27
+
28
+
29
+ def disable(*opts)
30
+ self.class.disable(*opts)
31
+ end
32
+
33
+
34
+ get '/' do
35
+ puts "Page Size: #{settings.page_size}"
36
+ render_view(:index, { :posts => PostIndex.instance })
37
+ end
38
+
39
+
40
+ get %r{^\/\d{4}\/\d{2}\/\d{2}\/\w+} do
41
+ index = nil
42
+
43
+ PostIndex.instance.each_with_index { |p, i|
44
+ if (p[:request_path] == request.path)
45
+ index = i
46
+ break
47
+ end
48
+ }
49
+
50
+ if (index != nil)
51
+ render_view(:post, { :posts => PostIndex.instance, :index => index })
52
+ end
53
+ end
54
+
55
+
56
+ get %r{^\/\d{4}(\/\d{2}(\/\d{2})?)?$} do
57
+ posts = PostIndex.instance.select { |p|
58
+ p[:request_path] =~ %r{^#{request.path}}
59
+ }
60
+
61
+ render_view(:archive, { :posts => posts })
62
+ end
63
+
64
+
65
+ get %r{^\/\w+} do
66
+ begin
67
+ render_view(request.path.to_sym, { :posts => PostIndex.instance })
68
+ rescue
69
+ pass
70
+ end
71
+ end
72
+
73
+
74
+ def render_view(view, locals)
75
+ expires(86400, :public)
76
+
77
+ haml view, :locals => locals
78
+ end
79
+ end
57
80
  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: 13
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 9
10
- version: 0.0.9
9
+ - 10
10
+ version: 0.0.10
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-22 00:00:00 -07:00
18
+ date: 2010-11-27 00:00:00 -07:00
19
19
  default_executable: gidget
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency