henshin 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
data/henshin.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{henshin}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["hawx"]
12
- s.date = %q{2010-05-26}
12
+ s.date = %q{2010-05-27}
13
13
  s.default_executable = %q{henshin}
14
14
  s.description = %q{Henshin is a static site generator, with a plugin system and more}
15
15
  s.email = %q{m@hawx.me}
@@ -52,6 +52,7 @@ Gem::Specification.new do |s|
52
52
  "test/site/options.yaml",
53
53
  "test/site/plugins/test.rb",
54
54
  "test/site/posts/Testing-Stuff.markdown",
55
+ "test/site/posts/cat/test.markdown",
55
56
  "test/site/posts/lorem-ipsum.markdown",
56
57
  "test/site/sass/print.sass",
57
58
  "test/site/static.html",
data/lib/henshin.rb CHANGED
@@ -25,7 +25,7 @@ module Henshin
25
25
  :time_zone => 'GMT',
26
26
  :author => '',
27
27
  :layout => '',
28
- :file_name => '{title-with-dashes}.{extension}',
28
+ :file_name => '<{category}/>{title-with-dashes}.{extension}',
29
29
  :permalink => '/{year}/{month}/{date}/{title}.html',
30
30
  :plugins => ['maraku', 'liquid'],
31
31
  :root => '.',
data/lib/henshin/post.rb CHANGED
@@ -30,22 +30,33 @@ module Henshin
30
30
  'date' => '(\d{4}-\d{2}-\d{2})',
31
31
  'date-time' => '(\d{4}-\d{2}-\d{2} at \d{2}:\d{2})',
32
32
  'xml-date-time' => '(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2})?((\+|-)\d{2}:\d{2})?)',
33
+ 'category' => '([a-zA-Z0-9_ -]+)',
33
34
  'extension' => "(#{ site.config[:extensions].join('|') })"}
34
35
 
35
36
  file_parser = config[:file_name]
36
- # create string regex and keep order of info
37
37
  data_order = []
38
+
39
+ # put together regex
38
40
  m = file_parser.gsub(/\{([a-z-]+)\}/) do
39
41
  data_order << $1
40
42
  parser[$1]
41
43
  end
44
+
45
+ # replace optional '<stuff>'
46
+ m.gsub!(/<(.+)>/) do
47
+ # this may lead to problems, well I say may...
48
+ data_order.unshift( 'optional' )
49
+ "(#{$1})?"
50
+ end
51
+
42
52
  # convert string to actual regex
43
53
  matcher = Regexp.new(m)
44
54
 
45
55
  override = {}
46
- # extract data from filename
47
- file_data = path.file_name.match( matcher ).captures
48
- file_data.each_with_index do |data, i|
56
+ name = path[ (config[:root]+'/posts/').size..-1 ]
57
+
58
+ file_data = name.match( matcher ).captures
59
+ file_data.each_with_index do |data, i|
49
60
  if data_order[i].include? 'title'
50
61
  if data_order[i].include? 'dashes'
51
62
  override[:title] = data.gsub(/-/, ' ').titlize
@@ -56,6 +67,8 @@ module Henshin
56
67
  override[:date] = data
57
68
  elsif data_order[i].include? 'extension'
58
69
  override[:extension] = data
70
+ elsif data_order[i].include? 'category'
71
+ override[:category] = data
59
72
  end
60
73
  end
61
74
  self.override( override )
@@ -135,7 +148,8 @@ module Henshin
135
148
  partials = {'year' => self.date.year,
136
149
  'month' => self.date.month,
137
150
  'date' => self.date.day,
138
- 'title' => self.title.slugify}
151
+ 'title' => self.title.slugify,
152
+ 'category' => self.category || ''}
139
153
 
140
154
  config[:permalink].gsub(/\{([a-z-]+)\}/) do
141
155
  partials[$1]
data/lib/henshin/site.rb CHANGED
@@ -43,7 +43,7 @@ module Henshin
43
43
  # Adds all items in 'posts' to the posts array
44
44
  def read_posts
45
45
  path = File.join(config[:root], 'posts')
46
- Dir.glob(path + '/*.*').each do |post|
46
+ Dir.glob(path + '/**/*.*').each do |post|
47
47
  @posts << Post.new(post, self)
48
48
  end
49
49
  end
@@ -0,0 +1,6 @@
1
+ ---
2
+ title: Test
3
+ date: 2010-05-27 at 18:54:02
4
+ ---
5
+
6
+ This should be put into the correct category, in this case 'cat'. But maybe it won't. That would be interesting.
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 2
9
- version: 0.1.2
8
+ - 3
9
+ version: 0.1.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - hawx
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-26 00:00:00 +01:00
17
+ date: 2010-05-27 00:00:00 +01:00
18
18
  default_executable: henshin
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -84,6 +84,7 @@ files:
84
84
  - test/site/options.yaml
85
85
  - test/site/plugins/test.rb
86
86
  - test/site/posts/Testing-Stuff.markdown
87
+ - test/site/posts/cat/test.markdown
87
88
  - test/site/posts/lorem-ipsum.markdown
88
89
  - test/site/sass/print.sass
89
90
  - test/site/static.html