glinda 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -14,3 +14,7 @@ group :development do
14
14
  gem 'jeweler'
15
15
  gem 'gemcutter'
16
16
  end
17
+
18
+ group :test, :development do
19
+ gem 'pry'
20
+ end
data/Gemfile.lock CHANGED
@@ -12,6 +12,7 @@ GEM
12
12
  xpath (~> 0.1.4)
13
13
  childprocess (0.3.5)
14
14
  ffi (~> 1.0, >= 1.0.6)
15
+ coderay (1.0.6)
15
16
  diff-lcs (1.1.3)
16
17
  ffi (1.1.5)
17
18
  fuubar (1.0.0)
@@ -28,9 +29,14 @@ GEM
28
29
  json (1.7.5)
29
30
  libwebsocket (0.1.5)
30
31
  addressable
32
+ method_source (0.7.1)
31
33
  mime-types (1.19)
32
34
  multi_json (1.3.6)
33
35
  nokogiri (1.5.5)
36
+ pry (0.9.8.4)
37
+ coderay (~> 1.0.5)
38
+ method_source (~> 0.7.1)
39
+ slop (>= 2.4.4, < 3)
34
40
  rack (1.4.1)
35
41
  rack-test (0.6.1)
36
42
  rack (>= 1.0)
@@ -54,6 +60,7 @@ GEM
54
60
  libwebsocket (~> 0.1.3)
55
61
  multi_json (~> 1.0)
56
62
  rubyzip
63
+ slop (2.4.4)
57
64
  xpath (0.1.4)
58
65
  nokogiri (~> 1.3)
59
66
 
@@ -66,6 +73,7 @@ DEPENDENCIES
66
73
  fuubar
67
74
  gemcutter
68
75
  jeweler
76
+ pry
69
77
  rake
70
78
  rdiscount
71
79
  rspec
data/Glinda.gemspec CHANGED
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = "glinda"
8
- s.version = "0.1.0"
7
+ s.name = %q{glinda}
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["rschmukler"]
12
- s.date = "2012-09-05"
13
- s.description = "Toto, expanded"
14
- s.email = "ryan@slingingcode.com"
12
+ s.date = %q{2012-09-08}
13
+ s.description = %q{Toto, expanded}
14
+ s.email = %q{ryan@slingingcode.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
17
  "README.md"
@@ -42,12 +42,13 @@ Gem::Specification.new do |s|
42
42
  "spec/templates/index.builder",
43
43
  "spec/templates/index.rhtml",
44
44
  "spec/templates/layout.rhtml",
45
- "spec/templates/repo.rhtml"
45
+ "spec/templates/repo.rhtml",
46
+ "spec/templates/tags.rhtml"
46
47
  ]
47
- s.homepage = "http://github.com/rschmukler/glinda"
48
+ s.homepage = %q{http://github.com/rschmukler/glinda}
48
49
  s.require_paths = ["lib"]
49
- s.rubygems_version = "1.8.24"
50
- s.summary = "Toto, expanded"
50
+ s.rubygems_version = %q{1.6.2}
51
+ s.summary = %q{Toto, expanded}
51
52
 
52
53
  if s.respond_to? :specification_version then
53
54
  s.specification_version = 3
@@ -59,6 +60,7 @@ Gem::Specification.new do |s|
59
60
  s.add_development_dependency(%q<rake>, [">= 0"])
60
61
  s.add_development_dependency(%q<jeweler>, [">= 0"])
61
62
  s.add_development_dependency(%q<gemcutter>, [">= 0"])
63
+ s.add_development_dependency(%q<pry>, [">= 0"])
62
64
  s.add_development_dependency(%q<rspec>, [">= 0"])
63
65
  s.add_runtime_dependency(%q<builder>, [">= 0"])
64
66
  s.add_runtime_dependency(%q<rack>, [">= 0"])
@@ -70,6 +72,7 @@ Gem::Specification.new do |s|
70
72
  s.add_dependency(%q<rake>, [">= 0"])
71
73
  s.add_dependency(%q<jeweler>, [">= 0"])
72
74
  s.add_dependency(%q<gemcutter>, [">= 0"])
75
+ s.add_dependency(%q<pry>, [">= 0"])
73
76
  s.add_dependency(%q<rspec>, [">= 0"])
74
77
  s.add_dependency(%q<builder>, [">= 0"])
75
78
  s.add_dependency(%q<rack>, [">= 0"])
@@ -82,6 +85,7 @@ Gem::Specification.new do |s|
82
85
  s.add_dependency(%q<rake>, [">= 0"])
83
86
  s.add_dependency(%q<jeweler>, [">= 0"])
84
87
  s.add_dependency(%q<gemcutter>, [">= 0"])
88
+ s.add_dependency(%q<pry>, [">= 0"])
85
89
  s.add_dependency(%q<rspec>, [">= 0"])
86
90
  s.add_dependency(%q<builder>, [">= 0"])
87
91
  s.add_dependency(%q<rack>, [">= 0"])
data/README.md CHANGED
@@ -21,6 +21,29 @@ blog in 10 seconds
21
21
  $ heroku create myblog
22
22
  $ git push heroku master
23
23
 
24
+ differences from toto
25
+ ---------------------
26
+
27
+ ### 1. Tagging Support
28
+
29
+ Glinda supports tagging on articles. You may specify tags in articles by
30
+ passing in a comma delimited list of tags.
31
+
32
+ title: the wizard of oz
33
+ date: 12/10/1932
34
+ tags: wizards, bears
35
+
36
+ This is a test
37
+
38
+ After that, you may access a few variables.
39
+
40
+ You may access a list of tags in all articles by using
41
+ `tag_list` in any view.
42
+
43
+ If a tag is passed such as: `/tags/wizards` you can access the tag in
44
+ the `tags.rhtml` view by calling the variable `tag`. You may access all
45
+ articles tagged with the specified tag by calling `archives`
46
+
24
47
  philosophy
25
48
  ----------
26
49
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/lib/glinda.rb CHANGED
@@ -4,6 +4,7 @@ require 'erb'
4
4
  require 'rack'
5
5
  require 'digest'
6
6
  require 'open-uri'
7
+ require 'pry'
7
8
 
8
9
  if RUBY_PLATFORM =~ /win32/
9
10
  require 'maruku'
@@ -75,10 +76,11 @@ module Glinda
75
76
  articles = type == :html ? self.articles.reverse : self.articles
76
77
  {:articles => articles.map do |article|
77
78
  Article.new article, @config
78
- end}.merge archives
79
+ end}.merge(archives)
79
80
  end
80
81
 
81
- def archives filter = ""
82
+
83
+ def archives filter = "", tag = nil
82
84
  entries = ! self.articles.empty??
83
85
  self.articles.select do |a|
84
86
  filter !~ /^\d{4}/ || File.basename(a) =~ /^#{filter}/
@@ -86,7 +88,20 @@ module Glinda
86
88
  Article.new article, @config
87
89
  end : []
88
90
 
89
- return :archives => Archives.new(entries, @config)
91
+ if tag.nil?
92
+ return :archives => Archives.new(entries, @config)
93
+ else
94
+ tagged_entries = entries.select do |e|
95
+ if e[:tags]
96
+ tags = e[:tags].split(',').map(&:strip).map(&:slugize)
97
+ tags.include? tag.slugize
98
+ else
99
+ false
100
+ end
101
+ end
102
+
103
+ return :archives => Archives.new(tagged_entries, @config), :tag => tag
104
+ end
90
105
  end
91
106
 
92
107
  def article route
@@ -113,6 +128,13 @@ module Glinda
113
128
  context[article(route), :article]
114
129
  else http 400
115
130
  end
131
+ elsif route.first == 'tags'
132
+ data = {}
133
+ if route.length == 2
134
+ context[archives("", route[1]), :tags]
135
+ else
136
+ context[{tag: nil}, :tags]
137
+ end
116
138
  elsif respond_to?(path)
117
139
  context[send(path, type), path.to_sym]
118
140
  elsif (repo = @config[:github][:repos].grep(/#{path}/).first) &&
@@ -145,6 +167,20 @@ module Glinda
145
167
  Dir["#{Paths[:articles]}/*.#{ext}"].sort_by {|entry| File.basename(entry) }
146
168
  end
147
169
 
170
+ def self.tag_list(ext)
171
+ tag_list = []
172
+ if !self.articles(ext).empty?
173
+ entries = self.articles(ext).map do |article|
174
+ Article.new(article, @config)
175
+ end
176
+
177
+ entries.map(&:tags).each do |tags|
178
+ tag_list += tags
179
+ end
180
+ end
181
+ return tag_list
182
+ end
183
+
148
184
  class Context
149
185
  include Template
150
186
  attr_reader :env
@@ -160,6 +196,10 @@ module Glinda
160
196
  end
161
197
  end
162
198
 
199
+ def tag_list
200
+ @tag_list ||= Site.tag_list(@config[:ext])
201
+ end
202
+
163
203
  def title
164
204
  @config[:title]
165
205
  end
@@ -275,6 +315,14 @@ module Glinda
275
315
  "/#{@config[:prefix]}#{self[:date].strftime("/%Y/%m/%d/#{slug}/")}".squeeze('/')
276
316
  end
277
317
 
318
+ def tags
319
+ if self[:tags]
320
+ self[:tags].split(',').map(&:strip)
321
+ else
322
+ []
323
+ end
324
+ end
325
+
278
326
  def title() self[:title] || "an article" end
279
327
  def date() @config[:date].call(self[:date]) end
280
328
  def author() self[:author] || @config[:author] end
@@ -1,5 +1,6 @@
1
1
  title: the wizard of oz
2
2
  date: 12/10/1932
3
+ tags: lions, tigers, bears
3
4
 
4
5
  Once upon a time...
5
6
 
@@ -1,5 +1,6 @@
1
1
  title: the wizard of oz
2
2
  date: 12/10/1932
3
+ tags: wizards, bears
3
4
 
4
5
  Once upon a time...
5
6
 
data/spec/glinda_spec.rb CHANGED
@@ -14,6 +14,7 @@ describe Glinda do
14
14
  Glinda::Paths[:articles] = "spec/articles"
15
15
  Glinda::Paths[:pages] = "spec/templates"
16
16
  Glinda::Paths[:templates] = "spec/templates"
17
+ Glinda.env = 'test'
17
18
  end
18
19
 
19
20
  describe "GET /" do
@@ -41,6 +42,11 @@ describe Glinda do
41
42
  page.all('#archives li').count.should == 2
42
43
  end
43
44
 
45
+ it "should have access to the tag_list" do
46
+ visit '/'
47
+ page.all('#tag_list li').count.should >= 2
48
+ end
49
+
44
50
  context "with no articles" do
45
51
  let(:response) { Rack::MockRequest.new(Glinda::Server.new(@config.merge(:ext => 'oxo'))).get('/') }
46
52
 
@@ -93,6 +99,42 @@ describe Glinda do
93
99
  end
94
100
  end
95
101
 
102
+ context "GET /tags" do
103
+ context "with a tag passed" do
104
+ let(:response) { @glinda.get '/tags/wizards' }
105
+
106
+ it "should return status code 200" do
107
+ response.status.should == 200
108
+ end
109
+
110
+ it "should set the content-type" do
111
+ response.content_type.should == "text/html"
112
+ end
113
+
114
+ it "should set the body to not enty" do
115
+ response.body.should_not be_empty
116
+ end
117
+
118
+ it "should include articles with the right tag" do
119
+ visit '/tags/wizards'
120
+ page.all('#articles li').count.should == 1
121
+ end
122
+
123
+
124
+ it "should have access to the tag passed in" do
125
+ visit '/tags/wizards'
126
+ page.find('#tag').should have_content 'wizards'
127
+ end
128
+ end
129
+
130
+ context "without a tag passed" do
131
+ it "should have access to a list of all tags" do
132
+ visit '/tags'
133
+ page.find('#tags').all('li').count.should >= 2
134
+ end
135
+ end
136
+ end
137
+
96
138
  context "GET /about" do
97
139
  let(:response) { @glinda.get('/about') }
98
140
  it "should return status code 200" do
@@ -3,6 +3,11 @@
3
3
  <li><%= article %></li>
4
4
  <% end %>
5
5
  </ul>
6
+ <ul id="tag_list">
7
+ <% tag_list.each do |tag| %>
8
+ <li><%= tag %></li>
9
+ <% end %>
10
+ </ul>
6
11
  <div id="archives">
7
12
  <%= archives[3...5] %>
8
13
  </div>
@@ -0,0 +1,13 @@
1
+ <% if !tag.nil? %>
2
+ <span id="tag"><%= tag %></span>
3
+ <ul id="articles">
4
+ <% archives.each do |a| %>
5
+ <li><%= a.title %></li>
6
+ <% end %>
7
+ </ul>
8
+ <% else %>
9
+ <ul id="tags">
10
+ <% tag_list.each do |t| %>
11
+ <li><%= t %></li>
12
+ <% end %>
13
+ <% end %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glinda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-05 00:00:00.000000000 Z
12
+ date: 2012-09-08 00:00:00.000000000 -05:00
13
+ default_executable:
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: rdiscount
16
- requirement: !ruby/object:Gem::Requirement
17
+ requirement: &2157562360 !ruby/object:Gem::Requirement
17
18
  none: false
18
19
  requirements:
19
20
  - - ! '>='
@@ -21,15 +22,10 @@ dependencies:
21
22
  version: '0'
22
23
  type: :runtime
23
24
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
25
+ version_requirements: *2157562360
30
26
  - !ruby/object:Gem::Dependency
31
27
  name: builder
32
- requirement: !ruby/object:Gem::Requirement
28
+ requirement: &2157559960 !ruby/object:Gem::Requirement
33
29
  none: false
34
30
  requirements:
35
31
  - - ! '>='
@@ -37,15 +33,10 @@ dependencies:
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
36
+ version_requirements: *2157559960
46
37
  - !ruby/object:Gem::Dependency
47
38
  name: fuubar
48
- requirement: !ruby/object:Gem::Requirement
39
+ requirement: &2157558040 !ruby/object:Gem::Requirement
49
40
  none: false
50
41
  requirements:
51
42
  - - ! '>='
@@ -53,15 +44,10 @@ dependencies:
53
44
  version: '0'
54
45
  type: :development
55
46
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
47
+ version_requirements: *2157558040
62
48
  - !ruby/object:Gem::Dependency
63
49
  name: rake
64
- requirement: !ruby/object:Gem::Requirement
50
+ requirement: &2157555200 !ruby/object:Gem::Requirement
65
51
  none: false
66
52
  requirements:
67
53
  - - ! '>='
@@ -69,15 +55,10 @@ dependencies:
69
55
  version: '0'
70
56
  type: :development
71
57
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
58
+ version_requirements: *2157555200
78
59
  - !ruby/object:Gem::Dependency
79
60
  name: jeweler
80
- requirement: !ruby/object:Gem::Requirement
61
+ requirement: &2157553100 !ruby/object:Gem::Requirement
81
62
  none: false
82
63
  requirements:
83
64
  - - ! '>='
@@ -85,15 +66,10 @@ dependencies:
85
66
  version: '0'
86
67
  type: :development
87
68
  prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
69
+ version_requirements: *2157553100
94
70
  - !ruby/object:Gem::Dependency
95
71
  name: gemcutter
96
- requirement: !ruby/object:Gem::Requirement
72
+ requirement: &2157550360 !ruby/object:Gem::Requirement
97
73
  none: false
98
74
  requirements:
99
75
  - - ! '>='
@@ -101,15 +77,21 @@ dependencies:
101
77
  version: '0'
102
78
  type: :development
103
79
  prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
80
+ version_requirements: *2157550360
81
+ - !ruby/object:Gem::Dependency
82
+ name: pry
83
+ requirement: &2157548980 !ruby/object:Gem::Requirement
105
84
  none: false
106
85
  requirements:
107
86
  - - ! '>='
108
87
  - !ruby/object:Gem::Version
109
88
  version: '0'
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: *2157548980
110
92
  - !ruby/object:Gem::Dependency
111
93
  name: rspec
112
- requirement: !ruby/object:Gem::Requirement
94
+ requirement: &2157547300 !ruby/object:Gem::Requirement
113
95
  none: false
114
96
  requirements:
115
97
  - - ! '>='
@@ -117,15 +99,10 @@ dependencies:
117
99
  version: '0'
118
100
  type: :development
119
101
  prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
- requirements:
123
- - - ! '>='
124
- - !ruby/object:Gem::Version
125
- version: '0'
102
+ version_requirements: *2157547300
126
103
  - !ruby/object:Gem::Dependency
127
104
  name: builder
128
- requirement: !ruby/object:Gem::Requirement
105
+ requirement: &2157544480 !ruby/object:Gem::Requirement
129
106
  none: false
130
107
  requirements:
131
108
  - - ! '>='
@@ -133,15 +110,10 @@ dependencies:
133
110
  version: '0'
134
111
  type: :runtime
135
112
  prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
- requirements:
139
- - - ! '>='
140
- - !ruby/object:Gem::Version
141
- version: '0'
113
+ version_requirements: *2157544480
142
114
  - !ruby/object:Gem::Dependency
143
115
  name: rack
144
- requirement: !ruby/object:Gem::Requirement
116
+ requirement: &2157539800 !ruby/object:Gem::Requirement
145
117
  none: false
146
118
  requirements:
147
119
  - - ! '>='
@@ -149,15 +121,10 @@ dependencies:
149
121
  version: '0'
150
122
  type: :runtime
151
123
  prerelease: false
152
- version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
- requirements:
155
- - - ! '>='
156
- - !ruby/object:Gem::Version
157
- version: '0'
124
+ version_requirements: *2157539800
158
125
  - !ruby/object:Gem::Dependency
159
126
  name: rdiscount
160
- requirement: !ruby/object:Gem::Requirement
127
+ requirement: &2157536780 !ruby/object:Gem::Requirement
161
128
  none: false
162
129
  requirements:
163
130
  - - ! '>='
@@ -165,12 +132,7 @@ dependencies:
165
132
  version: '0'
166
133
  type: :runtime
167
134
  prerelease: false
168
- version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
- requirements:
171
- - - ! '>='
172
- - !ruby/object:Gem::Version
173
- version: '0'
135
+ version_requirements: *2157536780
174
136
  description: Toto, expanded
175
137
  email: ryan@slingingcode.com
176
138
  executables: []
@@ -205,6 +167,8 @@ files:
205
167
  - spec/templates/index.rhtml
206
168
  - spec/templates/layout.rhtml
207
169
  - spec/templates/repo.rhtml
170
+ - spec/templates/tags.rhtml
171
+ has_rdoc: true
208
172
  homepage: http://github.com/rschmukler/glinda
209
173
  licenses: []
210
174
  post_install_message:
@@ -219,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
219
183
  version: '0'
220
184
  segments:
221
185
  - 0
222
- hash: -1161747196556854221
186
+ hash: 2552251103154411482
223
187
  required_rubygems_version: !ruby/object:Gem::Requirement
224
188
  none: false
225
189
  requirements:
@@ -228,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
192
  version: '0'
229
193
  requirements: []
230
194
  rubyforge_project:
231
- rubygems_version: 1.8.24
195
+ rubygems_version: 1.6.2
232
196
  signing_key:
233
197
  specification_version: 3
234
198
  summary: Toto, expanded