amiba 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +28 -0
- data/Thorfile +2 -0
- data/bin/amiba +15 -0
- data/bin/amiba-wp-import +113 -0
- data/lib/amiba/all.rb +13 -0
- data/lib/amiba/configuration.rb +40 -0
- data/lib/amiba/core_ext/file.rb +7 -0
- data/lib/amiba/core_ext/symbol.rb +11 -0
- data/lib/amiba/entry.rb +108 -0
- data/lib/amiba/page.rb +139 -0
- data/lib/amiba/repo.rb +28 -0
- data/lib/amiba/reverse_markdown.rb +199 -0
- data/lib/amiba/scope.rb +49 -0
- data/lib/amiba/site.rb +166 -0
- data/lib/amiba/source/entry.rb +42 -0
- data/lib/amiba/source/entry_finder.rb +136 -0
- data/lib/amiba/source/feed.rb +34 -0
- data/lib/amiba/source/partial.rb +22 -0
- data/lib/amiba/source.rb +148 -0
- data/lib/amiba.rb +90 -0
- data/templates/.amiba +4 -0
- data/templates/entries/.empty_directory +0 -0
- data/templates/layouts/default.haml.tt +6 -0
- data/templates/pages/.empty_directory +0 -0
- data/templates/skeletons/page.haml.tt +9 -0
- data/templates/skeletons/page.md.tt +8 -0
- metadata +282 -0
data/lib/amiba/source.rb
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
module Amiba
|
2
|
+
module Source
|
3
|
+
|
4
|
+
def self.included(base)
|
5
|
+
base.send :include, InstanceMethods
|
6
|
+
base.send :extend, ClassMethods
|
7
|
+
base.send :attr_reader, :name
|
8
|
+
base.send :include, ActiveModel::Validations
|
9
|
+
end
|
10
|
+
|
11
|
+
module ClassMethods
|
12
|
+
|
13
|
+
def metadata_fields(*names)
|
14
|
+
names.each do |name|
|
15
|
+
define_metadata_accessor(name)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def pluralized_name
|
20
|
+
name.demodulize.tableize
|
21
|
+
end
|
22
|
+
|
23
|
+
def define_metadata_accessor(name)
|
24
|
+
module_eval <<-STR
|
25
|
+
def #{name}
|
26
|
+
metadata[:#{name.to_s}]
|
27
|
+
end
|
28
|
+
|
29
|
+
def #{name}=(val)
|
30
|
+
metadata[:#{name.to_s}] = val
|
31
|
+
end
|
32
|
+
STR
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
module InstanceMethods
|
38
|
+
include Amiba::Repo
|
39
|
+
|
40
|
+
attr_accessor :format
|
41
|
+
|
42
|
+
def initialize(name, format='haml', metadata = nil, content = nil)
|
43
|
+
ext = File.extname name
|
44
|
+
fn = File.basename(name, ext)
|
45
|
+
dn = File.dirname name
|
46
|
+
f = dn == "." ? fn : File.join(dn, fn)
|
47
|
+
|
48
|
+
self.name = f
|
49
|
+
self.format = format
|
50
|
+
self.metadata = metadata
|
51
|
+
self.content = content
|
52
|
+
end
|
53
|
+
|
54
|
+
def filename
|
55
|
+
@filename ||= File.join(self.class.pluralized_name, "#{name}.#{format}")
|
56
|
+
end
|
57
|
+
|
58
|
+
def staged_filename
|
59
|
+
File.join Amiba::Configuration.staged_dir, filename
|
60
|
+
end
|
61
|
+
|
62
|
+
def new?
|
63
|
+
!File.exist?(filename)
|
64
|
+
end
|
65
|
+
|
66
|
+
def metadata_and_content
|
67
|
+
YAML.dump(metadata.to_hash) + YAML.dump(content)
|
68
|
+
end
|
69
|
+
|
70
|
+
def save(&block)
|
71
|
+
return false unless valid?
|
72
|
+
yield filename, metadata_and_content
|
73
|
+
true
|
74
|
+
end
|
75
|
+
|
76
|
+
def content
|
77
|
+
@content
|
78
|
+
end
|
79
|
+
|
80
|
+
def metadata
|
81
|
+
@metadata ||= source_valid? ? documents.first : {}
|
82
|
+
end
|
83
|
+
|
84
|
+
def pubdate
|
85
|
+
@metadata["pubdate"] ||= last_commit_date filename
|
86
|
+
end
|
87
|
+
|
88
|
+
protected
|
89
|
+
|
90
|
+
def method_missing(method_sym, *args, &block)
|
91
|
+
md = method_sym.to_s.gsub(/=$/,'')
|
92
|
+
if !metadata[md.to_s].nil?
|
93
|
+
self.class.define_metadata_accessor(md)
|
94
|
+
send(method_sym, *args, &block)
|
95
|
+
else
|
96
|
+
super
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def name=(n)
|
101
|
+
@name = n
|
102
|
+
end
|
103
|
+
|
104
|
+
def metadata=(meta)
|
105
|
+
m = meta ? metadata.merge(meta) : metadata
|
106
|
+
@metadata = HashWithIndifferentAccess.new(m)
|
107
|
+
end
|
108
|
+
|
109
|
+
def content=(c)
|
110
|
+
return @content unless @content.nil?
|
111
|
+
@content = self.new? ? c : documents.last
|
112
|
+
end
|
113
|
+
|
114
|
+
def documents
|
115
|
+
@documents ||= YAML.load_stream(File.read(filename)).documents
|
116
|
+
rescue
|
117
|
+
nil
|
118
|
+
end
|
119
|
+
|
120
|
+
def source_valid?
|
121
|
+
documents.first && documents.last
|
122
|
+
rescue
|
123
|
+
false
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
class Page
|
129
|
+
include Amiba::Source
|
130
|
+
metadata_fields :layout, :title, :description, :category, :state
|
131
|
+
|
132
|
+
VALID_FORMATS = %w{haml markdown}
|
133
|
+
validates_presence_of :layout, :title, :description, :category, :state
|
134
|
+
|
135
|
+
def output_filename
|
136
|
+
File.join(Amiba::Configuration.site_dir, "public/#{name}.html")
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
class Layout
|
141
|
+
include Amiba::Source
|
142
|
+
|
143
|
+
def content=(c)
|
144
|
+
@content ||= self.new? ? c : File.read(filename)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
data/lib/amiba.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
module Amiba
|
2
|
+
|
3
|
+
class Util
|
4
|
+
def self.in_amiba_application?
|
5
|
+
File.exist? ".amiba"
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
module Generator
|
10
|
+
|
11
|
+
def self.included(base)
|
12
|
+
base.send :include, Thor::Actions
|
13
|
+
base.send :extend, ClassMethods
|
14
|
+
end
|
15
|
+
|
16
|
+
module ClassMethods
|
17
|
+
def source_root(path = nil)
|
18
|
+
default_source_root
|
19
|
+
end
|
20
|
+
|
21
|
+
def default_source_root
|
22
|
+
File.dirname(File.expand_path(File.join(__FILE__, "..")))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class Create < Thor::Group
|
28
|
+
include Generator
|
29
|
+
|
30
|
+
namespace :create
|
31
|
+
|
32
|
+
argument :name
|
33
|
+
class_option :path
|
34
|
+
class_option :default_page, :default => "index"
|
35
|
+
|
36
|
+
def init_git
|
37
|
+
@repo = Grit::Repo.init(target)
|
38
|
+
end
|
39
|
+
|
40
|
+
def create_gitignore
|
41
|
+
copy_file File.join("templates",'.gitignore'), File.join(target, '.gitignore')
|
42
|
+
end
|
43
|
+
|
44
|
+
def create_gemfile
|
45
|
+
copy_file 'Gemfile', File.join(target, 'Gemfile')
|
46
|
+
end
|
47
|
+
|
48
|
+
def create_project_structure
|
49
|
+
copy_file File.join('templates', '.amiba'), File.join(target, ".amiba")
|
50
|
+
%w{entries pages layouts}.each {|dirname|
|
51
|
+
directory File.join("templates", dirname), File.join(target, dirname)
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
def create_assets_structure
|
56
|
+
%w{public/js public/css public/images}.each do |dirname|
|
57
|
+
empty_directory File.join(target, dirname)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def create_default_page
|
62
|
+
inside(target, :verbose => true) do
|
63
|
+
invoke(Amiba::Page::Create,
|
64
|
+
[options[:default_page]],
|
65
|
+
:title => name.titleize,
|
66
|
+
:description => "#{name.titleize} Homepage. Please change this to be more descriptive")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def commit_to_git
|
71
|
+
Dir.chdir(@repo.working_dir) do
|
72
|
+
@repo.add %w{.amiba Gemfile layouts pages}
|
73
|
+
@repo.commit_all("Initial commit of #{name} project.")
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def target
|
80
|
+
if options[:path]
|
81
|
+
File.expand_path(File.join(options[:path], name))
|
82
|
+
else
|
83
|
+
name
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
|
data/templates/.amiba
ADDED
File without changes
|
File without changes
|
metadata
ADDED
@@ -0,0 +1,282 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: amiba
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Steven Mohapi-Banks
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-03-18 00:00:00 +00:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: thor
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 43
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 14
|
33
|
+
- 6
|
34
|
+
version: 0.14.6
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: tilt
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 29
|
46
|
+
segments:
|
47
|
+
- 1
|
48
|
+
- 2
|
49
|
+
- 1
|
50
|
+
version: 1.2.1
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: haml
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 53
|
62
|
+
segments:
|
63
|
+
- 3
|
64
|
+
- 0
|
65
|
+
- 25
|
66
|
+
version: 3.0.25
|
67
|
+
type: :runtime
|
68
|
+
version_requirements: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activesupport
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 15
|
78
|
+
segments:
|
79
|
+
- 3
|
80
|
+
- 0
|
81
|
+
- 4
|
82
|
+
version: 3.0.4
|
83
|
+
type: :runtime
|
84
|
+
version_requirements: *id004
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: activemodel
|
87
|
+
prerelease: false
|
88
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
hash: 15
|
94
|
+
segments:
|
95
|
+
- 3
|
96
|
+
- 0
|
97
|
+
- 4
|
98
|
+
version: 3.0.4
|
99
|
+
type: :runtime
|
100
|
+
version_requirements: *id005
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
name: i18n
|
103
|
+
prerelease: false
|
104
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
hash: 11
|
110
|
+
segments:
|
111
|
+
- 0
|
112
|
+
- 5
|
113
|
+
- 0
|
114
|
+
version: 0.5.0
|
115
|
+
type: :runtime
|
116
|
+
version_requirements: *id006
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: rdiscount
|
119
|
+
prerelease: false
|
120
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
hash: 31
|
126
|
+
segments:
|
127
|
+
- 1
|
128
|
+
- 6
|
129
|
+
- 8
|
130
|
+
version: 1.6.8
|
131
|
+
type: :runtime
|
132
|
+
version_requirements: *id007
|
133
|
+
- !ruby/object:Gem::Dependency
|
134
|
+
name: fog
|
135
|
+
prerelease: false
|
136
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
hash: 7
|
142
|
+
segments:
|
143
|
+
- 0
|
144
|
+
- 6
|
145
|
+
- 0
|
146
|
+
version: 0.6.0
|
147
|
+
type: :runtime
|
148
|
+
version_requirements: *id008
|
149
|
+
- !ruby/object:Gem::Dependency
|
150
|
+
name: rspec
|
151
|
+
prerelease: false
|
152
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ">="
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
hash: 3
|
158
|
+
segments:
|
159
|
+
- 0
|
160
|
+
version: "0"
|
161
|
+
type: :development
|
162
|
+
version_requirements: *id009
|
163
|
+
- !ruby/object:Gem::Dependency
|
164
|
+
name: rspec_tag_matchers
|
165
|
+
prerelease: false
|
166
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
167
|
+
none: false
|
168
|
+
requirements:
|
169
|
+
- - ">="
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
hash: 3
|
172
|
+
segments:
|
173
|
+
- 0
|
174
|
+
version: "0"
|
175
|
+
type: :development
|
176
|
+
version_requirements: *id010
|
177
|
+
- !ruby/object:Gem::Dependency
|
178
|
+
name: autotest
|
179
|
+
prerelease: false
|
180
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
181
|
+
none: false
|
182
|
+
requirements:
|
183
|
+
- - ">="
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
hash: 3
|
186
|
+
segments:
|
187
|
+
- 0
|
188
|
+
version: "0"
|
189
|
+
type: :development
|
190
|
+
version_requirements: *id011
|
191
|
+
- !ruby/object:Gem::Dependency
|
192
|
+
name: factory_girl
|
193
|
+
prerelease: false
|
194
|
+
requirement: &id012 !ruby/object:Gem::Requirement
|
195
|
+
none: false
|
196
|
+
requirements:
|
197
|
+
- - ">="
|
198
|
+
- !ruby/object:Gem::Version
|
199
|
+
hash: 62196449
|
200
|
+
segments:
|
201
|
+
- 2
|
202
|
+
- 0
|
203
|
+
- 0
|
204
|
+
- beta
|
205
|
+
- 1
|
206
|
+
version: 2.0.0.beta1
|
207
|
+
type: :development
|
208
|
+
version_requirements: *id012
|
209
|
+
description: Description TBD
|
210
|
+
email:
|
211
|
+
- s.mohapi-banks@digital-science.com
|
212
|
+
executables:
|
213
|
+
- amiba
|
214
|
+
extensions: []
|
215
|
+
|
216
|
+
extra_rdoc_files: []
|
217
|
+
|
218
|
+
files:
|
219
|
+
- bin/amiba
|
220
|
+
- bin/amiba-wp-import
|
221
|
+
- lib/amiba/all.rb
|
222
|
+
- lib/amiba/configuration.rb
|
223
|
+
- lib/amiba/core_ext/file.rb
|
224
|
+
- lib/amiba/core_ext/symbol.rb
|
225
|
+
- lib/amiba/entry.rb
|
226
|
+
- lib/amiba/page.rb
|
227
|
+
- lib/amiba/repo.rb
|
228
|
+
- lib/amiba/reverse_markdown.rb
|
229
|
+
- lib/amiba/scope.rb
|
230
|
+
- lib/amiba/site.rb
|
231
|
+
- lib/amiba/source/entry.rb
|
232
|
+
- lib/amiba/source/entry_finder.rb
|
233
|
+
- lib/amiba/source/feed.rb
|
234
|
+
- lib/amiba/source/partial.rb
|
235
|
+
- lib/amiba/source.rb
|
236
|
+
- lib/amiba.rb
|
237
|
+
- templates/layouts/default.haml.tt
|
238
|
+
- templates/skeletons/page.haml.tt
|
239
|
+
- templates/skeletons/page.md.tt
|
240
|
+
- templates/entries/.empty_directory
|
241
|
+
- templates/pages/.empty_directory
|
242
|
+
- Thorfile
|
243
|
+
- Gemfile
|
244
|
+
- templates/.amiba
|
245
|
+
has_rdoc: true
|
246
|
+
homepage: http://www.digital-science.com
|
247
|
+
licenses: []
|
248
|
+
|
249
|
+
post_install_message:
|
250
|
+
rdoc_options: []
|
251
|
+
|
252
|
+
require_paths:
|
253
|
+
- lib
|
254
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
255
|
+
none: false
|
256
|
+
requirements:
|
257
|
+
- - ">="
|
258
|
+
- !ruby/object:Gem::Version
|
259
|
+
hash: 3
|
260
|
+
segments:
|
261
|
+
- 0
|
262
|
+
version: "0"
|
263
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
264
|
+
none: false
|
265
|
+
requirements:
|
266
|
+
- - ">="
|
267
|
+
- !ruby/object:Gem::Version
|
268
|
+
hash: 23
|
269
|
+
segments:
|
270
|
+
- 1
|
271
|
+
- 3
|
272
|
+
- 6
|
273
|
+
version: 1.3.6
|
274
|
+
requirements: []
|
275
|
+
|
276
|
+
rubyforge_project:
|
277
|
+
rubygems_version: 1.6.2
|
278
|
+
signing_key:
|
279
|
+
specification_version: 3
|
280
|
+
summary: Simple gem to build a static web-site
|
281
|
+
test_files: []
|
282
|
+
|