textigniter 0.0.31 → 0.0.32

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -3,7 +3,7 @@
3
3
  Copyright (c) 2011 Kaleb Heitzman
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
-
6
+
7
7
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
8
 
9
9
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.textile CHANGED
@@ -1,5 +1,9 @@
1
1
  h1. Textigniter
2
2
 
3
+ Follow us on twitter
4
+ "@textigniter":http://twitter.com/textigniter
5
+ "@kalebheitzman":http://twitter.com/kalebheitzman
6
+
3
7
  Textigniter is a command line tool used to generate static websites. Textigniter uses the power of "Textile":http://redcloth.org/ ("Markdown":http://kramdown.rubyforge.org/ is optional...), "Liquid":http://liquidmarkup.org/, "LESS CSS":http://lesscss.org/, and "Coffee Script":http://jashkenas.github.com/coffee-script/ for parsing different files and outputting "HTML5":http://www.html5rocks.com/en/ powered websites (Obviously you'll need to know HTML5, textigniter just helps with a development philosophy).
4
8
 
5
9
  h2. Installation
@@ -0,0 +1,6 @@
1
+ title: Post One
2
+ created_at: 2011-11-01T15:00:00
3
+ type: article
4
+ template: blog
5
+ -- content
6
+ This is a sample blog post
@@ -0,0 +1,4 @@
1
+ title: Post Two
2
+ type: article
3
+ -- content
4
+ This is a sample blog post
@@ -0,0 +1,4 @@
1
+ title: Post One
2
+ type: article
3
+ -- content
4
+ This is a sample blog post
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>{{ title }}</title>
5
+ </head>
6
+ <body>
7
+
8
+ <h1>{{ title }}</h1>
9
+
10
+ {{ content }}
11
+
12
+ <h2>Other entries</h2>
13
+
14
+ {% for article in articles %}
15
+
16
+ <h3>{{ article.title }}</h3>
17
+
18
+ {% endfor %}
19
+
20
+ </body>
21
+ </html>
@@ -1,4 +1,9 @@
1
+ # site configuration
1
2
  site_name: "Textigniter"
2
3
  site_description: "A textigniter powered website"
4
+ copyright: "2011 &copy; Textigniter"
5
+
6
+ # textigniter configuration
7
+ blog_type: article
3
8
  output_environment: "output"
4
9
  text_parser: textile
@@ -7,13 +7,13 @@ class Textigniter::Build::TemplateParser
7
7
  # create an array to store processed templates
8
8
  items = Array.new
9
9
  # iterate through the item list and parse templates
10
- item_list.each do |item|
10
+ item_list['items'].each do |item|
11
11
  # specifiy the template
12
12
  file = File.open(Dir::pwd + "/.textigniter/layouts/" + item['template'] + '.liquid', 'rb')
13
13
  # load the template
14
14
  template_from_file = file.read
15
15
  # render the output
16
- item['output'] = parse(template_from_file, item)
16
+ item['output'] = parse(template_from_file, item, item_list['articles'])
17
17
  # push the item onto the array
18
18
  items.push item
19
19
  end
@@ -21,7 +21,13 @@ class Textigniter::Build::TemplateParser
21
21
  return items
22
22
  end
23
23
 
24
- def parse(content, item)
24
+ def parse(content, item, articles)
25
+ # check for blog posts
26
+ if item['type'] == $config['blog_type']
27
+ # set a key with all articles
28
+ item['articles'] = articles
29
+ end
30
+ # require liquid lib
25
31
  require 'liquid'
26
32
  #parse the template
27
33
  template = Liquid::Template.parse(content)
@@ -7,6 +7,8 @@ class Textigniter::Build::TextParser
7
7
  STDOUT.puts "Parsing ".yellow_on_black + "[#{$config['text_parser']}]".blue_on_black + " content ".yellow_on_black + "[OK]".green_on_black
8
8
  # create array to store processed items in
9
9
  items = Array.new
10
+ # create an articles array for blog items
11
+ articles = Array.new
10
12
  # go through the build list and process
11
13
  build_list.each do |f|
12
14
  # open the file for reading
@@ -26,9 +28,25 @@ class Textigniter::Build::TextParser
26
28
  $config.each do |c|
27
29
  @h[c[0]] = c[1]
28
30
  end
31
+ # process for a created_at
32
+ unless @h.has_key? 'created_at'
33
+ # string to test agains
34
+ created_at = File.basename(f, '.textile')[0..9]
35
+ # is this a valid date?
36
+ valid = Date.parse(created_at) rescue false
37
+ if valid
38
+ @h['created_at'] = created_at
39
+ end
40
+ end
29
41
  # get the slug if it exists else calculate
30
42
  unless @h.has_key? 'slug'
31
- @h['slug'] = File.basename(f, '.textile')
43
+ # if no created_at, no need to fix
44
+ if @h['created_at'].nil?
45
+ @h['slug'] = File.basename(f, '.textile')
46
+ # fix the slug
47
+ else
48
+ @h['slug'] = File.basename(f, '.textile').gsub(@h['created_at'][0..9] + "-", '')
49
+ end
32
50
  end
33
51
  # the write directory
34
52
  directory = File.dirname(f).sub($twd,$owd) + '/' + @h['slug']
@@ -49,13 +67,36 @@ class Textigniter::Build::TextParser
49
67
  # store into the list
50
68
  @h[key] = content
51
69
  end
70
+ # check if blog_type
71
+ if @h.has_key? 'type'
72
+ if @h['type'] == $config['blog_type']
73
+ articles.push @h
74
+ end
75
+ end
52
76
  # push processed item onto the array
53
77
  items.push @h
54
- end
78
+ end
79
+ # create a super object to pass
80
+ @results = Hash.new
81
+ # store files to process
82
+ @results['items'] = items
83
+ # store blog posts to separate key
84
+ @results['articles'] = articles
85
+ # process blog articles
86
+ # process_blog(articles)
55
87
  # return the items
56
- return items
88
+ return @results
89
+ end
90
+
91
+ # process blog articles
92
+ def process_blog(articles)
93
+ # iterate through articles
94
+ articles.each do |article|
95
+ # puts "#{article['title']}"
96
+ end
57
97
  end
58
98
 
99
+ # parse text
59
100
  def parse(content)
60
101
  case $config['text_parser']
61
102
  when "textile"
@@ -79,4 +120,7 @@ class Textigniter::Build::TextParser
79
120
  end
80
121
  end
81
122
 
82
- end
123
+ end
124
+
125
+ # requirements
126
+ require 'date'
@@ -5,7 +5,7 @@
5
5
  # (Default: /public_html)
6
6
  class Textigniter::Build
7
7
 
8
- def initialize
8
+ def initialize(args)
9
9
  # Output a start message
10
10
  STDOUT.puts "Building static content".yellow_on_black
11
11
  # Check for an existing environment
@@ -38,18 +38,24 @@ class Textigniter::Build
38
38
  when 'html'
39
39
  # Create the html list
40
40
  build_list = Dir.glob($twd + "/content/**/*")
41
-
42
41
  when 'styles'
43
42
  # Create the style list
44
43
  build_list = Dir.glob($twd + "/styles/**/*")
45
-
46
44
  when 'scripts'
47
45
  # Create the script list
48
46
  build_list = Dir.glob($twd + "/scripts/**/*")
49
-
50
47
  end
48
+ # create an array to store the new build list in
49
+ cleaned_build_list = Array.new
50
+ # Clean up the build list
51
+ build_list.each do |l|
52
+ # if not a directory keep the file
53
+ unless File.directory?(l)
54
+ cleaned_build_list.push l
55
+ end
56
+ end
51
57
  # Return the list
52
- return build_list
58
+ return cleaned_build_list
53
59
  end
54
60
 
55
61
  end
@@ -3,7 +3,7 @@
3
3
  # no options or incorrect options.
4
4
  class Textigniter::Help
5
5
 
6
- def initialize
6
+ def initialize(args)
7
7
  STDOUT.puts "Usage:\r\n".yellow_on_black
8
8
  STDOUT.puts " textigniter COMMAND [OPTION]\r\n".white_on_black
9
9
  # show build help
@@ -4,9 +4,11 @@
4
4
  # arguments passed on the command line.
5
5
  class Textigniter::Init
6
6
 
7
- def initialize
7
+ def initialize(args)
8
8
  # Sends message to cli
9
9
  STDOUT.puts "Initializing a new textigniter environment".yellow_on_black
10
+ # get the skeleton
11
+ skeleton(args)
10
12
  end
11
13
 
12
14
  # Duplicate the skeleton into the current working directory/passed directory
@@ -45,7 +47,7 @@ class Textigniter::Init
45
47
  # Use fileutils to build the directory
46
48
  FileUtils.cp_r files, cwd
47
49
  # Output success message
48
- STDOUT.puts "[OK]".green_on_black + " Textigniter environment initiliazed".yellow_on_black
50
+ STDOUT.puts "Textigniter environment initiliazed ".yellow_on_black + "[OK]".green_on_black
49
51
  end
50
52
  end
51
53
 
@@ -33,6 +33,7 @@ class Textigniter::Scrub
33
33
  # Recursively remove directory and contents
34
34
  def scrub_directory(directory=nil)
35
35
  begin
36
+ # remove the files and directories
36
37
  Find.find(directory) do |path|
37
38
  FileUtils.remove_dir(path, true)
38
39
  Find.prune
data/lib/textigniter.rb CHANGED
@@ -1,17 +1,10 @@
1
- # _ _ _ _ _
2
- # | |_ _____ _| |_(_) __ _ _ __ (_) |_ ___ _ __
3
- # | __/ _ \ \/ / __| |/ _` | '_ \| | __/ _ \ '__|
4
- # | || __/> <| |_| | (_| | | | | | || __/ |
5
- # \__\___/_/\_\\__|_|\__, |_| |_|_|\__\___|_|
6
- # |___/
7
- #
8
1
  # Textigniter is a command line tool used to generate static websites. The
9
2
  # main point of configuration is the config.yml that is set up in a
10
3
  # textigniter initialized directory. Textigniter comes default with textile,
11
4
  # liquid, less, and coffee-script as parsers to output static content.
12
5
  #
13
6
  # If you have and questions/comments, please feel free to contact Kaleb
14
- # Heitzman at jkheitzman@gmail.com. This is more of a personal project and I
7
+ # Heitzman at kalebheitzman@me.com. This is more of a personal project and I
15
8
  # would recommend you use something more established like Jekyll or Nanoc for
16
9
  # productions sites.
17
10
  #
@@ -20,6 +13,9 @@ class Textigniter
20
13
 
21
14
  # Contains a switch for arguments passed via the command line
22
15
  def initialize
16
+ # get start time
17
+ beginning = Time.now
18
+
23
19
  # Get command line arguments arguments
24
20
  cmd = ARGV[0]
25
21
  args = ARGV[1]
@@ -53,44 +49,39 @@ class Textigniter
53
49
 
54
50
  # Select method based on cmd
55
51
  case cmd
56
-
57
52
  when "build"
58
53
  Textigniter.build(args)
59
-
60
54
  when "help"
61
55
  Textigniter.help(args)
62
-
63
56
  when "init"
64
57
  Textigniter.init(args)
65
-
66
58
  when "scrub"
67
59
  Textigniter.scrub
68
-
69
60
  else
70
- Textigniter.help
71
-
61
+ Textigniter.help(args)
72
62
  end
73
-
63
+ # print out elapsed time
64
+ puts "Time elapsed: ".yellow_on_black + "#{Time.now - beginning} seconds".white_on_black
65
+ # pretty up
74
66
  STDOUT.puts "\r\n"
75
67
  end
76
68
 
77
69
  # Initialize a new build object
78
70
  def self.build(args=nil)
79
71
  # create a new build instance
80
- @build = Build.new
72
+ @build = Build.new(args)
81
73
  end
82
74
 
83
75
  # Initialize a new help object
84
76
  def self.help(args=nil)
85
77
  # create a new help instance
86
- @help = Help.new
78
+ @help = Help.new(args)
87
79
  end
88
80
 
89
81
  # Initialize a new init object
90
82
  def self.init(args=nil)
91
83
  # create a new initialization instance
92
- @init = Init.new
93
- @init.skeleton(args)
84
+ @init = Init.new(args)
94
85
  end
95
86
 
96
87
  # Initialize a new scrub object
data/textigniter.gemspec CHANGED
@@ -2,17 +2,14 @@ Gem::Specification.new do |s|
2
2
  s.rubygems_version = '1.9.2'
3
3
 
4
4
  s.name = 'textigniter'
5
- s.version = '0.0.31'
5
+ s.version = '0.0.32'
6
6
  s.executables << 'textigniter'
7
7
  s.date = '2011-11-19'
8
8
 
9
9
  s.summary = 'A static site generator'
10
10
  s.description = <<-EOF
11
- Textigniter is a lightweight static site generator based on
12
- textile, liquid, less, and coffeescript. Future versions may
13
- be more modular but let's be honest, I'm pretty partial to
14
- textile.
15
- EOF
11
+ Textigniter is a lightweight static site generator based on textile (markdown optional), liquid, less, and coffeescript. There are no plans for textigniter to support other parsers. Keeping it clean yet powerful.
12
+ EOF
16
13
 
17
14
  s.authors = ["Kaleb Heitzman"]
18
15
  s.email = 'jkheitzman@gmail.com'
@@ -20,12 +17,12 @@ Gem::Specification.new do |s|
20
17
 
21
18
  s.extra_rdoc_files = %w[README.textile LICENSE]
22
19
 
23
- s.add_dependency('RedCloth', '>= 0')
24
- s.add_dependency('kramdown', '>= 0')
25
- s.add_dependency('liquid', '>= 0')
26
- s.add_dependency('less', '>= 0')
27
- s.add_dependency('coffee-script', '>= 0')
28
- s.add_dependency('colored', '>= 0')
20
+ s.add_dependency('RedCloth', '~> 4.2.0')
21
+ s.add_dependency('kramdown', '~> 0.13.0')
22
+ s.add_dependency('liquid', '~> 2.3.0')
23
+ s.add_dependency('less', '~> 2.0.0')
24
+ s.add_dependency('coffee-script', '~> 2.2.0')
25
+ s.add_dependency('colored', '~> 1.0')
29
26
 
30
27
  # = MANIFEST =
31
28
  s.files = %w[
@@ -37,9 +34,13 @@ Gem::Specification.new do |s|
37
34
  lib/skeleton/config.yml
38
35
  lib/skeleton/.textigniter/content/index.textile
39
36
  lib/skeleton/.textigniter/content/about.textile
37
+ lib/skeleton/.textigniter/content/articles/2011-11-01-post-one.textile
38
+ lib/skeleton/.textigniter/content/articles/2011-11-02-post-two.textile
39
+ lib/skeleton/.textigniter/content/articles/2011-11-03-post-three.textile
40
40
  lib/skeleton/.textigniter/scripts/functions.coffeescript
41
41
  lib/skeleton/.textigniter/styles/style.less
42
42
  lib/skeleton/.textigniter/layouts/about.liquid
43
+ lib/skeleton/.textigniter/layouts/blog.liquid
43
44
  lib/skeleton/.textigniter/layouts/default.liquid
44
45
  lib/skeleton/.textigniter/layouts/partials
45
46
  lib/textigniter.rb
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: textigniter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.31
4
+ version: 0.0.32
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,73 +13,73 @@ date: 2011-11-19 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: RedCloth
16
- requirement: &70121931208660 !ruby/object:Gem::Requirement
16
+ requirement: &70139173890900 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ! '>='
19
+ - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '0'
21
+ version: 4.2.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70121931208660
24
+ version_requirements: *70139173890900
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: kramdown
27
- requirement: &70121931208140 !ruby/object:Gem::Requirement
27
+ requirement: &70139173890360 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
- - - ! '>='
30
+ - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: '0'
32
+ version: 0.13.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70121931208140
35
+ version_requirements: *70139173890360
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: liquid
38
- requirement: &70121931207600 !ruby/object:Gem::Requirement
38
+ requirement: &70139173889860 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
- - - ! '>='
41
+ - - ~>
42
42
  - !ruby/object:Gem::Version
43
- version: '0'
43
+ version: 2.3.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70121931207600
46
+ version_requirements: *70139173889860
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: less
49
- requirement: &70121931207100 !ruby/object:Gem::Requirement
49
+ requirement: &70139173889320 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
- - - ! '>='
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 2.0.0
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70121931207100
57
+ version_requirements: *70139173889320
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: coffee-script
60
- requirement: &70121931206500 !ruby/object:Gem::Requirement
60
+ requirement: &70139173888720 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
- - - ! '>='
63
+ - - ~>
64
64
  - !ruby/object:Gem::Version
65
- version: '0'
65
+ version: 2.2.0
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70121931206500
68
+ version_requirements: *70139173888720
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: colored
71
- requirement: &70121931205820 !ruby/object:Gem::Requirement
71
+ requirement: &70139173887660 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
- - - ! '>='
74
+ - - ~>
75
75
  - !ruby/object:Gem::Version
76
- version: '0'
76
+ version: '1.0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70121931205820
80
- description: ! " Textigniter is a lightweight static site generator based on\n
81
- \ textile, liquid, less, and coffeescript. Future versions may\n be more modular
82
- but let's be honest, I'm pretty partial to\n textile.\n"
79
+ version_requirements: *70139173887660
80
+ description: ! " Textigniter is a lightweight static site generator based on textile
81
+ (markdown optional), liquid, less, and coffeescript. There are no plans for textigniter
82
+ to support other parsers. Keeping it clean yet powerful. \n"
83
83
  email: jkheitzman@gmail.com
84
84
  executables:
85
85
  - textigniter
@@ -96,9 +96,13 @@ files:
96
96
  - lib/skeleton/config.yml
97
97
  - lib/skeleton/.textigniter/content/index.textile
98
98
  - lib/skeleton/.textigniter/content/about.textile
99
+ - lib/skeleton/.textigniter/content/articles/2011-11-01-post-one.textile
100
+ - lib/skeleton/.textigniter/content/articles/2011-11-02-post-two.textile
101
+ - lib/skeleton/.textigniter/content/articles/2011-11-03-post-three.textile
99
102
  - lib/skeleton/.textigniter/scripts/functions.coffeescript
100
103
  - lib/skeleton/.textigniter/styles/style.less
101
104
  - lib/skeleton/.textigniter/layouts/about.liquid
105
+ - lib/skeleton/.textigniter/layouts/blog.liquid
102
106
  - lib/skeleton/.textigniter/layouts/default.liquid
103
107
  - lib/textigniter.rb
104
108
  - lib/textigniter/build.rb