amiba 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/amiba/all.rb CHANGED
@@ -11,3 +11,4 @@ require 'amiba/page'
11
11
  require 'amiba/entry'
12
12
  require 'amiba/site'
13
13
  require 'amiba/scope'
14
+ require 'webrick'
data/lib/amiba/entry.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'etc'
2
+
1
3
  module Amiba
2
4
  module Entry
3
5
 
@@ -11,6 +13,7 @@ module Amiba
11
13
  class_option :title, :required => true
12
14
  class_option :state, :default => 'draft'
13
15
  class_option :layout, :default => 'default'
16
+ class_option :author, :default => Etc.getpwnam(ENV["USER"])["gecos"].split(",")[0]
14
17
  class_option :slug
15
18
 
16
19
  def init_source
@@ -18,7 +21,7 @@ module Amiba
18
21
  name,
19
22
  format,
20
23
  options,
21
- "h1. New post\n")
24
+ "# New post\n")
22
25
  end
23
26
 
24
27
  def should_not_exist
data/lib/amiba/page.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'amiba/source'
2
+ require 'etc'
2
3
 
3
4
  module Amiba
4
5
  module Page
@@ -17,6 +18,7 @@ module Amiba
17
18
  class_option :description, :required => true
18
19
  class_option :category, :default => "plain"
19
20
  class_option :state, :default => "draft"
21
+ class_option :author, :default => Etc.getpwnam(ENV["USER"])["gecos"].split(",")[0]
20
22
 
21
23
  def init_source
22
24
  @source = Amiba::Source::Page.new(name, format, options, Templates.send(format.to_sym))
data/lib/amiba/scope.rb CHANGED
@@ -29,14 +29,18 @@ module Amiba
29
29
  end
30
30
 
31
31
  def site_name
32
+ Amiba::Configuration.site_name.nil? ? "" : Amiba::Configuration.site_name
33
+ end
34
+
35
+ def site_url
32
36
  Amiba::Configuration.site_name.nil? ? "" : "http://#{Amiba::Configuration.site_name}/"
33
37
  end
34
38
 
35
39
  def full_url(frag)
36
- if site_name.empty?
40
+ if site_url.empty?
37
41
  frag
38
42
  else
39
- URI.join(site_name, frag).to_s
43
+ URI.join(site_url, frag).to_s
40
44
  end
41
45
  end
42
46
 
data/lib/amiba/site.rb CHANGED
@@ -1,6 +1,34 @@
1
1
  module Amiba
2
2
  module Site
3
3
 
4
+ class Preview < Thor::Group
5
+ include Amiba::Generator
6
+
7
+ namespace :"site:preview"
8
+ class_option :port, :default => 4321
9
+
10
+ def create
11
+ invoke Amiba::Site::Generate
12
+ end
13
+
14
+ def preview
15
+ root = File.expand_path(File.join(Amiba::Configuration.site_dir, "public"))
16
+ logger = WEBrick::Log.new($stderr, WEBrick::Log::ERROR)
17
+ server = WEBrick::HTTPServer.new({:Port => options[:port], :DocumentRoot => root, :Logger => logger})
18
+
19
+ ['INT', 'TERM'].each {|signal|
20
+ trap(signal) {server.shutdown}
21
+ }
22
+
23
+ say ""
24
+ say ""
25
+ say "Preview available at http://localhost:#{options[:port]}/"
26
+ say "To end, press Ctrl+C"
27
+
28
+ server.start
29
+ end
30
+ end
31
+
4
32
  class S3Upload < Thor::Group
5
33
  include Amiba::Generator
6
34
 
@@ -4,6 +4,10 @@ module Amiba
4
4
  extend Amiba::Source::EntryFinder
5
5
  include Amiba::Source
6
6
 
7
+ ActiveSupport::Inflector.inflections do |inflect|
8
+ inflect.uncountable "blog"
9
+ end
10
+
7
11
  attr_accessor :category
8
12
  metadata_fields :title, :slug, :state, :layout
9
13
 
data/lib/amiba.rb CHANGED
@@ -57,14 +57,18 @@ module Amiba
57
57
  empty_directory File.join(target, dirname)
58
58
  end
59
59
  end
60
-
60
+
61
+ def create_default_feeds
62
+ directory File.join("templates", "feeds"), File.join(target, dirname)
63
+ end
64
+
61
65
  def create_default_page
62
66
  inside(target, :verbose => true) do
63
67
  invoke(Amiba::Page::Create,
64
68
  [options[:default_page]],
65
69
  :title => name.titleize,
66
70
  :description => "#{name.titleize} Homepage. Please change this to be more descriptive")
67
- end
71
+ end
68
72
  end
69
73
 
70
74
  def commit_to_git
@@ -0,0 +1,21 @@
1
+ xml.instruct!
2
+ xml.feed "xml:lang" => "en-GB", "xmlns" => 'http://www.w3.org/2005/Atom' do
3
+ xml.id "tag:#{site_name},2005:/index.atom"
4
+ xml.link(:rel => 'alternate', :type => 'text/html', :href => full_url("/"))
5
+ xml.link(:rel => 'self', :type => 'application/atom+xml', :href => full_url("/index.atom"))
6
+ xml.title "Template atom feed"
7
+ xml.updated entries.first.pubdate.xmlschema
8
+
9
+ entries.each do |entry|
10
+ xml.item do |item|
11
+ item.title entry.title
12
+ item.link(:rel => 'alternate', :type => 'text/html', :href => full_url(entry.link))
13
+ item.id "tag:#{site_name},2005:#{entry.link}"
14
+ item.published entry.pubdate.xmlschema
15
+ item.author do |author|
16
+ author.name entry.author
17
+ end
18
+ item.content(entry.render, :type => "html")
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,19 @@
1
+ xml.instruct!
2
+ xml.rss "version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do
3
+ xml.channel do
4
+ xml.title "Template RSS Feed"
5
+ xml.link full_url "/index.rss2"
6
+ xml.pubDate Time.now.rfc822
7
+ xml.description ""
8
+ entries.published.each do |entry|
9
+ xml.item do
10
+ xml.title entry.title
11
+ xml.link full_url entry.link
12
+ xml.description entry.render
13
+ xml.pubDate entry.pubdate.rfc822
14
+ xml.guid full_url entry.link
15
+ xml.author entry.author
16
+ end
17
+ end
18
+ end
19
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amiba
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Steven Mohapi-Banks
@@ -147,9 +147,25 @@ dependencies:
147
147
  type: :runtime
148
148
  version_requirements: *id008
149
149
  - !ruby/object:Gem::Dependency
150
- name: rspec
150
+ name: grit
151
151
  prerelease: false
152
152
  requirement: &id009 !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ hash: 29
158
+ segments:
159
+ - 2
160
+ - 4
161
+ - 1
162
+ version: 2.4.1
163
+ type: :runtime
164
+ version_requirements: *id009
165
+ - !ruby/object:Gem::Dependency
166
+ name: rspec
167
+ prerelease: false
168
+ requirement: &id010 !ruby/object:Gem::Requirement
153
169
  none: false
154
170
  requirements:
155
171
  - - ">="
@@ -159,11 +175,11 @@ dependencies:
159
175
  - 0
160
176
  version: "0"
161
177
  type: :development
162
- version_requirements: *id009
178
+ version_requirements: *id010
163
179
  - !ruby/object:Gem::Dependency
164
180
  name: rspec_tag_matchers
165
181
  prerelease: false
166
- requirement: &id010 !ruby/object:Gem::Requirement
182
+ requirement: &id011 !ruby/object:Gem::Requirement
167
183
  none: false
168
184
  requirements:
169
185
  - - ">="
@@ -173,11 +189,11 @@ dependencies:
173
189
  - 0
174
190
  version: "0"
175
191
  type: :development
176
- version_requirements: *id010
192
+ version_requirements: *id011
177
193
  - !ruby/object:Gem::Dependency
178
194
  name: autotest
179
195
  prerelease: false
180
- requirement: &id011 !ruby/object:Gem::Requirement
196
+ requirement: &id012 !ruby/object:Gem::Requirement
181
197
  none: false
182
198
  requirements:
183
199
  - - ">="
@@ -187,11 +203,11 @@ dependencies:
187
203
  - 0
188
204
  version: "0"
189
205
  type: :development
190
- version_requirements: *id011
206
+ version_requirements: *id012
191
207
  - !ruby/object:Gem::Dependency
192
208
  name: factory_girl
193
209
  prerelease: false
194
- requirement: &id012 !ruby/object:Gem::Requirement
210
+ requirement: &id013 !ruby/object:Gem::Requirement
195
211
  none: false
196
212
  requirements:
197
213
  - - ">="
@@ -205,7 +221,7 @@ dependencies:
205
221
  - 1
206
222
  version: 2.0.0.beta1
207
223
  type: :development
208
- version_requirements: *id012
224
+ version_requirements: *id013
209
225
  description: Description TBD
210
226
  email:
211
227
  - s.mohapi-banks@digital-science.com
@@ -234,6 +250,8 @@ files:
234
250
  - lib/amiba/source/partial.rb
235
251
  - lib/amiba/source.rb
236
252
  - lib/amiba.rb
253
+ - templates/feeds/index.atom.builder
254
+ - templates/feeds/index.rss2.builder
237
255
  - templates/layouts/default.haml.tt
238
256
  - templates/skeletons/page.haml.tt
239
257
  - templates/skeletons/page.md.tt