textigniter 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +9 -0
- data/README.textile +28 -0
- data/Rakefile +8 -0
- data/bin/textigniter +5 -0
- data/lib/skeleton/.textigniter/content/about.textile +6 -0
- data/lib/skeleton/.textigniter/content/index.textile +11 -0
- data/lib/skeleton/.textigniter/layouts/default.liquid +9 -0
- data/lib/skeleton/.textigniter/scripts/functions.coffeescript +28 -0
- data/lib/skeleton/.textigniter/styles/style.less +8 -0
- data/lib/skeleton/README.textile +5 -0
- data/lib/skeleton/config.yml +8 -0
- data/lib/skeleton/public_html/media/README.textile +0 -0
- data/lib/skeleton/public_html/media/images/README.textile +0 -0
- data/lib/skeleton/public_html/scripts/README.textile +0 -0
- data/lib/skeleton/public_html/styles/README.textile +0 -0
- data/lib/textigniter/build/render_files.rb +33 -0
- data/lib/textigniter/build/script_parser.rb +45 -0
- data/lib/textigniter/build/style_parser.rb +49 -0
- data/lib/textigniter/build/template_parser.rb +47 -0
- data/lib/textigniter/build/text_parser.rb +68 -0
- data/lib/textigniter/build.rb +64 -0
- data/lib/textigniter/help.rb +35 -0
- data/lib/textigniter/init.rb +55 -0
- data/lib/textigniter/scrub.rb +48 -0
- data/lib/textigniter.rb +111 -0
- data/textigniter.gemspec +64 -0
- metadata +131 -0
data/LICENSE
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2011 Kaleb Heitzman
|
4
|
+
|
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
|
+
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
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
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
h1. Textigniter
|
2
|
+
|
3
|
+
Textigniter is a command line tool used to generate static websites. The main point of configuration is the config.yml that is set up in a textigniter initialized directory. Textigniter comes default with textile, liquid, less, and coffee-script as parsers to output static content.
|
4
|
+
|
5
|
+
h2. Installation
|
6
|
+
|
7
|
+
It's easy
|
8
|
+
|
9
|
+
@gem install textigniter@
|
10
|
+
|
11
|
+
The default parser gem's will be downloaded as well.
|
12
|
+
|
13
|
+
h2. Usage
|
14
|
+
|
15
|
+
@textigniter init@
|
16
|
+
@textigniter init directory@
|
17
|
+
|
18
|
+
Passing the init option initializes a new textigniter environment in your current directory. You can pass a second option to specify a directory that you want to install textigniter in.
|
19
|
+
|
20
|
+
@textigniter build@
|
21
|
+
|
22
|
+
Passing the build option will make textigniter parse the _.textigniter_ directory and output the static html to _public_html_
|
23
|
+
|
24
|
+
@textignier scrub@
|
25
|
+
When you pass the scrub option, all textigniter related files and folders will be removed. This will also remove _public_html_. If you have files not related to textigniter specifically in the _public_html_ folder, you should back them up if you do not want to lose them.
|
26
|
+
|
27
|
+
@textigniter help@
|
28
|
+
Passing help on the command line will print out usage of _textigniter_
|
data/Rakefile
ADDED
data/bin/textigniter
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Assignment:
|
2
|
+
number = 42
|
3
|
+
opposite = true
|
4
|
+
|
5
|
+
# Conditions:
|
6
|
+
number = -42 if opposite
|
7
|
+
|
8
|
+
# Functions:
|
9
|
+
square = (x) -> x * x
|
10
|
+
|
11
|
+
# Arrays:
|
12
|
+
list = [1, 2, 3, 4, 5]
|
13
|
+
|
14
|
+
# Objects:
|
15
|
+
math =
|
16
|
+
root: Math.sqrt
|
17
|
+
square: square
|
18
|
+
cube: (x) -> x * square x
|
19
|
+
|
20
|
+
# Splats:
|
21
|
+
race = (winner, runners...) ->
|
22
|
+
print winner, runners
|
23
|
+
|
24
|
+
# Existence:
|
25
|
+
alert "I knew it!" if elvis?
|
26
|
+
|
27
|
+
# Array comprehensions:
|
28
|
+
cubes = (math.cube num for num in list)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# The RenderFiles class outputs static files based on a list passed to it.
|
2
|
+
# The list contains at least two key value pairs.
|
3
|
+
#
|
4
|
+
# For example:
|
5
|
+
# items['directory'] = "/some-directory"
|
6
|
+
# items['filename] = "some-filename" The extension is added in this class
|
7
|
+
class Textigniter::Build::RenderFiles
|
8
|
+
|
9
|
+
# Renders static content to file
|
10
|
+
def render(items, format)
|
11
|
+
# Output start message
|
12
|
+
STDOUT.puts "Rendering #{format} to file ".yellow_on_black + "[OK]".green_on_black
|
13
|
+
# Render each item
|
14
|
+
items.each do |item|
|
15
|
+
# Recursively create directory if it doesn't exist
|
16
|
+
FileUtils.mkpath item['directory']
|
17
|
+
# Switch based on format and build a filename
|
18
|
+
case format
|
19
|
+
when 'html'
|
20
|
+
filename = item['directory'] + 'index.html'
|
21
|
+
when 'css'
|
22
|
+
filename = item['directory'] + '/' + item['filename'] + '.css'
|
23
|
+
when 'js'
|
24
|
+
filename = item['directory'] + '/' + item['filename'] + '.js'
|
25
|
+
end
|
26
|
+
# Write the output to file
|
27
|
+
File.open(filename, 'w') do |file|
|
28
|
+
file.write item['output']
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# This class parses scripts. Currently it only parses coffeescript
|
2
|
+
class Textigniter::Build::ScriptParser
|
3
|
+
|
4
|
+
def process(build_list)
|
5
|
+
# Output message
|
6
|
+
STDOUT.puts "Parsing ".yellow_on_black + "[#{$config['script_parser']}]".blue_on_black + " scripts ".yellow_on_black + "[OK]".green_on_black
|
7
|
+
# create array to store processed items in
|
8
|
+
items = Array.new
|
9
|
+
# process the build list
|
10
|
+
build_list.each do |f|
|
11
|
+
# open the file for reading
|
12
|
+
file = File.open(f, 'rb')
|
13
|
+
# store the contents in contents and split it at --
|
14
|
+
contents = file.read
|
15
|
+
# create a hash to store info
|
16
|
+
@h = Hash.new
|
17
|
+
# get the directory
|
18
|
+
directory = File.dirname(f).sub($twd,$owd) + '/'
|
19
|
+
@h['directory'] = directory
|
20
|
+
# get the file name
|
21
|
+
@h['filename'] = File.basename(f, ".#{$config['script_parser']}")
|
22
|
+
# parse the content
|
23
|
+
@h['output'] = parse(contents)
|
24
|
+
# push processed item onto the array
|
25
|
+
items.push @h
|
26
|
+
end
|
27
|
+
# return the items
|
28
|
+
return items
|
29
|
+
end
|
30
|
+
|
31
|
+
def parse(content)
|
32
|
+
case $config['script_parser']
|
33
|
+
when "coffeescript"
|
34
|
+
# require coffee-script gem
|
35
|
+
require 'coffee-script'
|
36
|
+
# return the output
|
37
|
+
return CoffeeScript.compile content
|
38
|
+
|
39
|
+
else
|
40
|
+
return content
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# The StyleParser parses css files. Currently it only parses less files.
|
2
|
+
class Textigniter::Build::StyleParser
|
3
|
+
|
4
|
+
def process(build_list)
|
5
|
+
# Output message
|
6
|
+
STDOUT.puts "Parsing ".yellow_on_black + "[#{$config['style_parser']}]".blue_on_black + " styles ".yellow_on_black + "[OK]".green_on_black
|
7
|
+
# create array to store processed items in
|
8
|
+
items = Array.new
|
9
|
+
# process the build list
|
10
|
+
build_list.each do |f|
|
11
|
+
# open the file for reading
|
12
|
+
file = File.open(f, 'rb')
|
13
|
+
# store the contents in contents and split it at --
|
14
|
+
contents = file.read
|
15
|
+
# create a hash to store info
|
16
|
+
@h = Hash.new
|
17
|
+
# get the directory
|
18
|
+
directory = File.dirname(f).sub($twd,$owd) + '/'
|
19
|
+
@h['directory'] = directory
|
20
|
+
# get the file name
|
21
|
+
@h['filename'] = File.basename(f, ".#{$config['style_parser']}")
|
22
|
+
# parse the content
|
23
|
+
@h['output'] = parse(contents)
|
24
|
+
# push processed item onto the array
|
25
|
+
items.push @h
|
26
|
+
end
|
27
|
+
# return the items
|
28
|
+
return items
|
29
|
+
end
|
30
|
+
|
31
|
+
def parse(content)
|
32
|
+
case $config['style_parser']
|
33
|
+
when "less"
|
34
|
+
# require less gem
|
35
|
+
require 'less'
|
36
|
+
# instantiate the parser
|
37
|
+
parser = Less::Parser.new
|
38
|
+
# parse the content
|
39
|
+
tree = parser.parse(content)
|
40
|
+
# return the output
|
41
|
+
return tree.to_css
|
42
|
+
|
43
|
+
else
|
44
|
+
return content
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# This class parses templates. Currently it only parses liquid templates
|
2
|
+
class Textigniter::Build::TemplateParser
|
3
|
+
|
4
|
+
def process(item_list)
|
5
|
+
# Output message
|
6
|
+
STDOUT.puts "Parsing ".yellow_on_black + "[#{$config['template_parser']}]".blue_on_black + " templates ".yellow_on_black + "[OK]".green_on_black
|
7
|
+
# create an array to store processed templates
|
8
|
+
items = Array.new
|
9
|
+
# iterate through the item list and parse templates
|
10
|
+
item_list.each do |item|
|
11
|
+
# specifiy the template
|
12
|
+
file = File.open(Dir::pwd + '/.textigniter/layouts/' + item['template'] + '.' + $config['template_parser'], 'rb')
|
13
|
+
# load the template
|
14
|
+
template_from_file = file.read
|
15
|
+
# render the output
|
16
|
+
item['output'] = parse(template_from_file, item)
|
17
|
+
# push the item onto the array
|
18
|
+
items.push item
|
19
|
+
end
|
20
|
+
# return the items
|
21
|
+
return items
|
22
|
+
end
|
23
|
+
|
24
|
+
def parse(content, item)
|
25
|
+
case $config['template_parser']
|
26
|
+
when "liquid"
|
27
|
+
require 'liquid'
|
28
|
+
#parse the template
|
29
|
+
template = Liquid::Template.parse(content)
|
30
|
+
# render the template
|
31
|
+
output = template.render(item)
|
32
|
+
# return the output
|
33
|
+
return output
|
34
|
+
|
35
|
+
else
|
36
|
+
require 'liquid'
|
37
|
+
#parse the template
|
38
|
+
template = Liquid::Template.parse(content)
|
39
|
+
# render the template
|
40
|
+
output = template.render(item)
|
41
|
+
# return the output
|
42
|
+
return output
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# this is the script parser
|
2
|
+
class Textigniter::Build::TextParser
|
3
|
+
|
4
|
+
# parse the text and build a hash to send to template rendering
|
5
|
+
def process(build_list)
|
6
|
+
# Output message
|
7
|
+
STDOUT.puts "Parsing ".yellow_on_black + "[#{$config['text_parser']}]".blue_on_black + " content ".yellow_on_black + "[OK]".green_on_black
|
8
|
+
# create array to store processed items in
|
9
|
+
items = Array.new
|
10
|
+
# go through the build list and process
|
11
|
+
build_list.each do |f|
|
12
|
+
# open the file for reading
|
13
|
+
file = File.open(f, 'rb')
|
14
|
+
# store the contents in contents and split it at --
|
15
|
+
contents = file.read
|
16
|
+
components = contents.split('--')
|
17
|
+
# load the config from the text file
|
18
|
+
meta = YAML::load(components[0])
|
19
|
+
# create a new hash to work with
|
20
|
+
@h = Hash.new
|
21
|
+
# parse through the meta
|
22
|
+
meta.each do |m|
|
23
|
+
@h[m[0]] = m[1]
|
24
|
+
end
|
25
|
+
# get the slug if it exists else calculate
|
26
|
+
unless @h.has_key? 'slug'
|
27
|
+
@h['slug'] = File.basename(f, '.textile')
|
28
|
+
end
|
29
|
+
# the write directory
|
30
|
+
directory = File.dirname(f).sub($twd,$owd) + '/' + @h['slug']
|
31
|
+
directory = directory.sub('public_html/content', 'public_html')
|
32
|
+
directory = directory.sub('public_html/index', 'public_html') + '/'
|
33
|
+
@h['directory'] = directory
|
34
|
+
# get the template if exists else default
|
35
|
+
unless @h.has_key? 'template'
|
36
|
+
@h['template'] = 'default'
|
37
|
+
end
|
38
|
+
# gather the rest of the components into key value and convert
|
39
|
+
components[1..-1].each do |component|
|
40
|
+
# split into key value
|
41
|
+
kv = component.split("\n", 2)
|
42
|
+
# do some cleanup
|
43
|
+
key = kv[0].strip
|
44
|
+
content = parse(kv[1].strip)
|
45
|
+
# store into the list
|
46
|
+
@h[key] = content
|
47
|
+
end
|
48
|
+
# push processed item onto the array
|
49
|
+
items.push @h
|
50
|
+
end
|
51
|
+
# return the items
|
52
|
+
return items
|
53
|
+
end
|
54
|
+
|
55
|
+
def parse(content)
|
56
|
+
case $config['text_parser']
|
57
|
+
when "textile"
|
58
|
+
require 'RedCloth'
|
59
|
+
return RedCloth.new(content).to_html
|
60
|
+
|
61
|
+
else
|
62
|
+
require 'RedCloth'
|
63
|
+
return RedCloth.new(content).to_html
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# The Build class searches through the textigniter enviornment
|
2
|
+
# (Default: /.textigniter) and parses through text files, stylesheets, and
|
3
|
+
# javascripts with filters that correlate to the extension of the file. The
|
4
|
+
# parsed content is then rendered to the output directory
|
5
|
+
# (Default: /public_html)
|
6
|
+
class Textigniter::Build
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
# Output a start message
|
10
|
+
STDOUT.puts "Building static content".yellow_on_black
|
11
|
+
# Check for an existing environment
|
12
|
+
unless File.directory?(".textigniter")
|
13
|
+
# Output a failure message do to lack of environment and exit
|
14
|
+
STDOUT.puts "Textigniter does not exist in this directory ".yellow_on_black + "[FAIL]".red_on_black
|
15
|
+
STDOUT.puts "\r\nHint: ".white_on_black + "textigniter init ".bold.white_on_black + " creates a new environment\r\n".white_on_black
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
# Parse the text
|
19
|
+
text_items = TextParser.new.process(build_list('html'))
|
20
|
+
# Parse the template
|
21
|
+
template_items = TemplateParser.new.process(text_items)
|
22
|
+
# Parse the styles
|
23
|
+
style_items = StyleParser.new.process(build_list('styles'))
|
24
|
+
# Parse the scripts
|
25
|
+
script_items = ScriptParser.new.process(build_list('scripts'))
|
26
|
+
# Render html to file
|
27
|
+
RenderFiles.new.render(template_items, 'html')
|
28
|
+
# Render styles to file
|
29
|
+
RenderFiles.new.render(style_items, 'css')
|
30
|
+
# Render scripts to file
|
31
|
+
RenderFiles.new.render(script_items, 'js')
|
32
|
+
end
|
33
|
+
|
34
|
+
# Create a build list to pass to parsers
|
35
|
+
def build_list(format)
|
36
|
+
# switch on format
|
37
|
+
case format
|
38
|
+
when 'html'
|
39
|
+
# Create the html list
|
40
|
+
build_list = Dir.glob($twd + "/content/**/*.#{$config['text_parser']}")
|
41
|
+
|
42
|
+
when 'styles'
|
43
|
+
# Create the style list
|
44
|
+
build_list = Dir.glob($twd + "/styles/**/*.#{$config['style_parser']}")
|
45
|
+
|
46
|
+
when 'scripts'
|
47
|
+
# Create the script list
|
48
|
+
build_list = Dir.glob($twd + "/scripts/**/*.#{$config['script_parser']}")
|
49
|
+
|
50
|
+
end
|
51
|
+
# Return the list
|
52
|
+
return build_list
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
# Requirements needed
|
58
|
+
require 'fileutils'
|
59
|
+
require 'textigniter/build/render_files'
|
60
|
+
require 'textigniter/build/script_parser'
|
61
|
+
require 'textigniter/build/style_parser'
|
62
|
+
require 'textigniter/build/template_parser'
|
63
|
+
require 'textigniter/build/text_parser'
|
64
|
+
require 'yaml'
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# The Help Class provides usage options to the command line for quick
|
2
|
+
# reference. The help class is also called when textigniter is called with
|
3
|
+
# no options or incorrect options.
|
4
|
+
class Textigniter::Help
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
STDOUT.puts "Usage:\r\n".yellow_on_black
|
8
|
+
STDOUT.puts " textigniter COMMAND [OPTION]\r\n".white_on_black
|
9
|
+
# show build help
|
10
|
+
build
|
11
|
+
# show init help
|
12
|
+
init
|
13
|
+
# show scrub help
|
14
|
+
scrub
|
15
|
+
end
|
16
|
+
|
17
|
+
# Build help
|
18
|
+
def build
|
19
|
+
STDOUT.puts " textigniter build".bold.white_on_black
|
20
|
+
STDOUT.puts " Builds static output from the textigniter environment\r\n".yellow_on_black
|
21
|
+
end
|
22
|
+
|
23
|
+
# Init help
|
24
|
+
def init
|
25
|
+
STDOUT.puts " textigniter init".bold.white_on_black
|
26
|
+
STDOUT.puts " Creates a new textigniter environment\r\n".yellow_on_black
|
27
|
+
end
|
28
|
+
|
29
|
+
# Scruby help
|
30
|
+
def scrub
|
31
|
+
STDOUT.puts " textigniter scrub".bold.white_on_black
|
32
|
+
STDOUT.puts " Deletes the textigniter environment\r\n".yellow_on_black
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# The Init class creates a new textigniter environment by duplicating a
|
2
|
+
# skeleton directory stored in the gem. The class will either duplicate this
|
3
|
+
# directory into the current working directory or a directory of choice by
|
4
|
+
# arguments passed on the command line.
|
5
|
+
class Textigniter::Init
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
# Sends message to cli
|
9
|
+
STDOUT.puts "Initializing a new textigniter environment".yellow_on_black
|
10
|
+
end
|
11
|
+
|
12
|
+
# Duplicate the skeleton into the current working directory/passed directory
|
13
|
+
def skeleton(dir=nil)
|
14
|
+
# Create the specified directory if passed
|
15
|
+
unless dir.nil?
|
16
|
+
begin
|
17
|
+
# Make the directory
|
18
|
+
FileUtils.mkdir(dir)
|
19
|
+
# Change into the dir
|
20
|
+
FileUtils.cd(dir)
|
21
|
+
rescue
|
22
|
+
# Error message, the directory already exists.
|
23
|
+
STDOUT.puts "[FAIL]".red_on_black + " #{dir} already exists. \r\n".yellow_on_black
|
24
|
+
exit
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Get the current working directory path
|
29
|
+
cwd = Dir::pwd + '/'
|
30
|
+
# Get the skeleton directory path
|
31
|
+
swd = File.dirname(__FILE__).gsub('lib/textigniter', 'lib/skeleton/')
|
32
|
+
|
33
|
+
# Run a check for existing environment
|
34
|
+
if File.directory?(cwd + '.textigniter')
|
35
|
+
# Output error and resolution message
|
36
|
+
STDOUT.puts "[FAIL]".red_on_black + " Existing textigniter environment".yellow_on_black
|
37
|
+
STDOUT.puts "\r\nHint: If you need to start over, use ".white_on_black + "textigniter scrub".bold.white_on_black
|
38
|
+
else
|
39
|
+
# Build list of files
|
40
|
+
files = Dir.glob(swd + '*', File::FNM_DOTMATCH)
|
41
|
+
# Clean up the list, removes .. & .
|
42
|
+
# If someone has a better solution for this, please let me know
|
43
|
+
files.delete(swd + '.')
|
44
|
+
files.delete(swd + '..')
|
45
|
+
# Use fileutils to build the directory
|
46
|
+
FileUtils.cp_r files, cwd
|
47
|
+
# Output success message
|
48
|
+
STDOUT.puts "[OK]".green_on_black + " Textigniter environment initiliazed".yellow_on_black
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
# Requirements needed
|
55
|
+
require 'fileutils'
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# The Scrub Class deletes the textigniter environment leaving intact any files
|
2
|
+
# and folders that you have added at the base level. It will remove any files
|
3
|
+
# that you have added to the public_html folder so be sure to back those up.
|
4
|
+
class Textigniter::Scrub
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
# Output start message
|
8
|
+
STDOUT.puts "Scrubbing textigniter environment".yellow_on_black
|
9
|
+
# Check for an existing environment
|
10
|
+
unless File.directory?(".textigniter")
|
11
|
+
# Output a failure message do to lack of environment and exit
|
12
|
+
STDOUT.puts "Textigniter does not exist in this directory ".yellow_on_black + "[FAIL]".red_on_black
|
13
|
+
STDOUT.puts "\r\nHint: ".white_on_black + "textigniter init ".bold.white_on_black + " creates a new environment\r\n".white_on_black
|
14
|
+
exit
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Scrub the directory
|
19
|
+
def scrub
|
20
|
+
# Get the current working directory
|
21
|
+
cwd = Dir::pwd + '/'
|
22
|
+
# Scrub the directory, no turning back
|
23
|
+
scrub_directory(cwd + '.textigniter')
|
24
|
+
scrub_directory(cwd + 'public_html')
|
25
|
+
# Files to delete as well
|
26
|
+
files = [ cwd + "README.textile", cwd + "config.yml" ]
|
27
|
+
# Remove files specified
|
28
|
+
FileUtils.rm files, :force => true
|
29
|
+
# Output success message
|
30
|
+
puts "Textigniter enivorment has been scrubbed ".yellow_on_black + "[OK]".green_on_black
|
31
|
+
end
|
32
|
+
|
33
|
+
# Recursively remove directory and contents
|
34
|
+
def scrub_directory(directory=nil)
|
35
|
+
begin
|
36
|
+
Find.find(directory) do |path|
|
37
|
+
FileUtils.remove_dir(path, true)
|
38
|
+
Find.prune
|
39
|
+
end
|
40
|
+
rescue
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
# Requirements needed
|
47
|
+
require 'fileutils'
|
48
|
+
require 'find'
|
data/lib/textigniter.rb
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
# _ _ _ _ _
|
2
|
+
# | |_ _____ _| |_(_) __ _ _ __ (_) |_ ___ _ __
|
3
|
+
# | __/ _ \ \/ / __| |/ _` | '_ \| | __/ _ \ '__|
|
4
|
+
# | || __/> <| |_| | (_| | | | | | || __/ |
|
5
|
+
# \__\___/_/\_\\__|_|\__, |_| |_|_|\__\___|_|
|
6
|
+
# |___/
|
7
|
+
#
|
8
|
+
# Textigniter is a command line tool used to generate static websites. The
|
9
|
+
# main point of configuration is the config.yml that is set up in a
|
10
|
+
# textigniter initialized directory. Textigniter comes default with textile,
|
11
|
+
# liquid, less, and coffee-script as parsers to output static content.
|
12
|
+
#
|
13
|
+
# 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
|
15
|
+
# would recommend you use something more established like Jekyll or Nanoc for
|
16
|
+
# productions sites.
|
17
|
+
#
|
18
|
+
# Last update: November 19, 2011
|
19
|
+
class Textigniter
|
20
|
+
|
21
|
+
# Contains a switch for arguments passed via the command line
|
22
|
+
def initialize
|
23
|
+
# Get command line arguments arguments
|
24
|
+
cmd = ARGV[0]
|
25
|
+
args = ARGV[1]
|
26
|
+
|
27
|
+
# Store configuration information into a global
|
28
|
+
if File.exists?(Dir::pwd + '/config.yml')
|
29
|
+
# Use the existing site configuration
|
30
|
+
$config = YAML::load(File.open(Dir::pwd + '/config.yml'))
|
31
|
+
else
|
32
|
+
# Pull base site configuration from textigniter gem
|
33
|
+
$config = YAML::load(File.dirname(__FILE__) + '/skeleton/config.yml')
|
34
|
+
end
|
35
|
+
# Store textigniter enviornment path in a global
|
36
|
+
$twd = Dir::pwd + "/#{$config['textigniter_environment']}"
|
37
|
+
# Store output environment path in a global
|
38
|
+
$owd = Dir::pwd + "/#{$config['output_environment']}"
|
39
|
+
|
40
|
+
# get gemspec info
|
41
|
+
specfile = File.dirname(__FILE__).gsub('lib', 'textigniter.gemspec')
|
42
|
+
$spec = Gem::Specification::load(specfile)
|
43
|
+
|
44
|
+
# Let's put up some cool ascii art promoting textigniter
|
45
|
+
STDOUT.puts %q{
|
46
|
+
_ _ _ _ _
|
47
|
+
| |_ _____ _| |_(_) __ _ _ __ (_) |_ ___ _ __
|
48
|
+
| __/ _ \ \/ / __| |/ _` | '_ \| | __/ _ \ '__|
|
49
|
+
| || __/> <| |_| | (_| | | | | | || __/ |
|
50
|
+
\__\___/_/\_\\\__|_|\__, |_| |_|_|\__\___|_| v}.bold.blue + "#{$spec.version}".bold.blue + %q{
|
51
|
+
|___/
|
52
|
+
}.bold.blue
|
53
|
+
|
54
|
+
# Select method based on cmd
|
55
|
+
case cmd
|
56
|
+
|
57
|
+
when "build"
|
58
|
+
Textigniter.build(args)
|
59
|
+
|
60
|
+
when "help"
|
61
|
+
Textigniter.help(args)
|
62
|
+
|
63
|
+
when "init"
|
64
|
+
Textigniter.init(args)
|
65
|
+
|
66
|
+
when "scrub"
|
67
|
+
Textigniter.scrub
|
68
|
+
|
69
|
+
else
|
70
|
+
Textigniter.help
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
STDOUT.puts "\r\n"
|
75
|
+
end
|
76
|
+
|
77
|
+
# Initialize a new build object
|
78
|
+
def self.build(args=nil)
|
79
|
+
# create a new build instance
|
80
|
+
@build = Build.new
|
81
|
+
end
|
82
|
+
|
83
|
+
# Initialize a new help object
|
84
|
+
def self.help(args=nil)
|
85
|
+
# create a new help instance
|
86
|
+
@help = Help.new
|
87
|
+
end
|
88
|
+
|
89
|
+
# Initialize a new init object
|
90
|
+
def self.init(args=nil)
|
91
|
+
# create a new initialization instance
|
92
|
+
@init = Init.new
|
93
|
+
@init.skeleton(args)
|
94
|
+
end
|
95
|
+
|
96
|
+
# Initialize a new scrub object
|
97
|
+
def self.scrub
|
98
|
+
# create a new scrub instance
|
99
|
+
@scrub = Scrub.new
|
100
|
+
@scrub.scrub
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
# load requirements
|
106
|
+
require 'colored'
|
107
|
+
require 'textigniter/build'
|
108
|
+
require 'textigniter/help'
|
109
|
+
require 'textigniter/init'
|
110
|
+
require 'textigniter/scrub'
|
111
|
+
require 'yaml'
|
data/textigniter.gemspec
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.rubygems_version = '1.9.2'
|
3
|
+
|
4
|
+
s.name = 'textigniter'
|
5
|
+
s.version = '0.0.3'
|
6
|
+
s.executables << 'textigniter'
|
7
|
+
s.date = '2011-11-19'
|
8
|
+
|
9
|
+
s.summary = 'A static site generator'
|
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
|
16
|
+
|
17
|
+
s.authors = ["Kaleb Heitzman"]
|
18
|
+
s.email = 'jkheitzman@gmail.com'
|
19
|
+
s.homepage = 'http://github.com/kalebheitzman/textigniter'
|
20
|
+
|
21
|
+
s.extra_rdoc_files = %w[README.textile LICENSE]
|
22
|
+
|
23
|
+
s.add_dependency('RedCloth', '>= 0')
|
24
|
+
s.add_dependency('liquid', '>= 0')
|
25
|
+
s.add_dependency('less', '>= 0')
|
26
|
+
s.add_dependency('coffee-script', '>= 0')
|
27
|
+
s.add_dependency('colored', '>= 0')
|
28
|
+
|
29
|
+
# = MANIFEST =
|
30
|
+
s.files = %w[
|
31
|
+
Rakefile
|
32
|
+
README.textile
|
33
|
+
textigniter.gemspec
|
34
|
+
bin/textigniter
|
35
|
+
lib/skeleton/README.textile
|
36
|
+
lib/skeleton/config.yml
|
37
|
+
lib/skeleton/.textigniter/content/index.textile
|
38
|
+
lib/skeleton/.textigniter/content/about.textile
|
39
|
+
lib/skeleton/.textigniter/scripts/functions.coffeescript
|
40
|
+
lib/skeleton/.textigniter/styles/style.less
|
41
|
+
lib/skeleton/.textigniter/layouts/default.liquid
|
42
|
+
lib/skeleton/.textigniter/layouts/partials
|
43
|
+
lib/skeleton/public_html/media/README.textile
|
44
|
+
lib/skeleton/public_html/media/images/README.textile
|
45
|
+
lib/skeleton/public_html/scripts/README.textile
|
46
|
+
lib/skeleton/public_html/styles/README.textile
|
47
|
+
lib/textigniter.rb
|
48
|
+
lib/textigniter/build.rb
|
49
|
+
lib/textigniter/help.rb
|
50
|
+
lib/textigniter/init.rb
|
51
|
+
lib/textigniter/scrub.rb
|
52
|
+
lib/textigniter/build/render_files.rb
|
53
|
+
lib/textigniter/build/script_parser.rb
|
54
|
+
lib/textigniter/build/style_parser.rb
|
55
|
+
lib/textigniter/build/template_parser.rb
|
56
|
+
lib/textigniter/build/text_parser.rb
|
57
|
+
]
|
58
|
+
# = MANIFEST =
|
59
|
+
|
60
|
+
s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
|
61
|
+
|
62
|
+
s.licenses = ['MIT']
|
63
|
+
|
64
|
+
end
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: textigniter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Kaleb Heitzman
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-11-19 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: RedCloth
|
16
|
+
requirement: &70166844060160 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70166844060160
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: liquid
|
27
|
+
requirement: &70166844059620 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70166844059620
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: less
|
38
|
+
requirement: &70166844059060 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70166844059060
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: coffee-script
|
49
|
+
requirement: &70166844058580 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70166844058580
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: colored
|
60
|
+
requirement: &70166844058020 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70166844058020
|
69
|
+
description: ! " Textigniter is a lightweight static site generator based on\n
|
70
|
+
\ textile, liquid, less, and coffeescript. Future versions may\n be more modular
|
71
|
+
but let's be honest, I'm pretty partial to\n textile.\n"
|
72
|
+
email: jkheitzman@gmail.com
|
73
|
+
executables:
|
74
|
+
- textigniter
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files:
|
77
|
+
- README.textile
|
78
|
+
- LICENSE
|
79
|
+
files:
|
80
|
+
- Rakefile
|
81
|
+
- README.textile
|
82
|
+
- textigniter.gemspec
|
83
|
+
- bin/textigniter
|
84
|
+
- lib/skeleton/README.textile
|
85
|
+
- lib/skeleton/config.yml
|
86
|
+
- lib/skeleton/.textigniter/content/index.textile
|
87
|
+
- lib/skeleton/.textigniter/content/about.textile
|
88
|
+
- lib/skeleton/.textigniter/scripts/functions.coffeescript
|
89
|
+
- lib/skeleton/.textigniter/styles/style.less
|
90
|
+
- lib/skeleton/.textigniter/layouts/default.liquid
|
91
|
+
- lib/skeleton/public_html/media/README.textile
|
92
|
+
- lib/skeleton/public_html/media/images/README.textile
|
93
|
+
- lib/skeleton/public_html/scripts/README.textile
|
94
|
+
- lib/skeleton/public_html/styles/README.textile
|
95
|
+
- lib/textigniter.rb
|
96
|
+
- lib/textigniter/build.rb
|
97
|
+
- lib/textigniter/help.rb
|
98
|
+
- lib/textigniter/init.rb
|
99
|
+
- lib/textigniter/scrub.rb
|
100
|
+
- lib/textigniter/build/render_files.rb
|
101
|
+
- lib/textigniter/build/script_parser.rb
|
102
|
+
- lib/textigniter/build/style_parser.rb
|
103
|
+
- lib/textigniter/build/template_parser.rb
|
104
|
+
- lib/textigniter/build/text_parser.rb
|
105
|
+
- LICENSE
|
106
|
+
homepage: http://github.com/kalebheitzman/textigniter
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
115
|
+
requirements:
|
116
|
+
- - ! '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
121
|
+
requirements:
|
122
|
+
- - ! '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
requirements: []
|
126
|
+
rubyforge_project:
|
127
|
+
rubygems_version: 1.8.11
|
128
|
+
signing_key:
|
129
|
+
specification_version: 3
|
130
|
+
summary: A static site generator
|
131
|
+
test_files: []
|