striker 0.0.8.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +179 -0
- data/Rakefile +1 -0
- data/bin/striker +58 -0
- data/lib/new_site/config.yml +17 -0
- data/lib/new_site/css/style.css +1 -0
- data/lib/new_site/js/script.js +1 -0
- data/lib/new_site/templates/archive/index.html +1 -0
- data/lib/new_site/templates/default.html +10 -0
- data/lib/new_site/templates/page.html +10 -0
- data/lib/new_site/templates/tags/index.html +1 -0
- data/lib/new_site/templates/tags/tag.html +2 -0
- data/lib/striker.rb +28 -0
- data/lib/striker/archive.rb +72 -0
- data/lib/striker/command/build.rb +34 -0
- data/lib/striker/command/new.rb +42 -0
- data/lib/striker/command/page.rb +67 -0
- data/lib/striker/command/strike.rb +18 -0
- data/lib/striker/command/templates/page.md +8 -0
- data/lib/striker/media/image.rb +78 -0
- data/lib/striker/page.rb +86 -0
- data/lib/striker/settings.rb +22 -0
- data/lib/striker/site.rb +27 -0
- data/lib/striker/tag.rb +77 -0
- data/lib/striker/tags/soundcloud.rb +26 -0
- data/lib/striker/tags/thumbnail.rb +38 -0
- data/lib/striker/tags/tweet.rb +25 -0
- data/lib/striker/tags/vimeo.rb +26 -0
- data/lib/striker/tags/youtube.rb +26 -0
- data/lib/striker/template.rb +33 -0
- data/lib/striker/version.rb +3 -0
- data/striker.gemspec +32 -0
- metadata +219 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 564fb4720de771314258930e6d16fa5287d5e907
|
4
|
+
data.tar.gz: fb0676c796a47c0c5e1e9c14f9b33570db364ca7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 738aa7c261a4e5ab560948fd4e2f74b72c5d8e0528b5ea61e27f086e4d0a3b662eb9bed21a0fceabd27da77360fc7ae3c9693c8f4292b3e7ba3edef418f8a7aa
|
7
|
+
data.tar.gz: 6376d19dd265eaf98eefb2c8352a79d249f403ccd94cea86658c9f6d67357712ea166875feb312f8c012931d90d440b77e36a361ffa04eb2805c62a3bc03399c
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Swaroop SM
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,179 @@
|
|
1
|
+
# Striker
|
2
|
+
|
3
|
+
[](https://codeclimate.com/github/swaroopsm/striker)
|
4
|
+
|
5
|
+
A Simple & Fast Static Site Generator. Striker has been released as a pre version as of now, to get reviews and bug reports.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
<!--
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
gem 'striker'
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
-->
|
20
|
+
|
21
|
+
$ gem install striker --pre
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
#### Create New Site
|
26
|
+
$ striker new my-awesome-site
|
27
|
+
$ cd my-awesome-site
|
28
|
+
|
29
|
+
##### This creates the following directory structure:
|
30
|
+
my-awesome-site/
|
31
|
+
css/
|
32
|
+
js/
|
33
|
+
media/
|
34
|
+
images/
|
35
|
+
sounds/
|
36
|
+
videos/
|
37
|
+
pages/
|
38
|
+
templates/
|
39
|
+
config.yml
|
40
|
+
|
41
|
+
|
42
|
+
#### Create New Page
|
43
|
+
$ striker page --new home --title "Home Page" [--no-media | --no-image | --no-sound | --no-video]
|
44
|
+
Use the appropriate option if you need images or videos or sound.
|
45
|
+
|
46
|
+
This creates a page named `home.md` in `pages/`. The content is written in [markdown](http://daringfireball.net/projects/markdown/).
|
47
|
+
#####The front matter of this page looks like the following
|
48
|
+
---
|
49
|
+
title: Home Page
|
50
|
+
author: Swaroop SM
|
51
|
+
date: 2013-10-19
|
52
|
+
template: page
|
53
|
+
---
|
54
|
+
|
55
|
+
### Home Page
|
56
|
+
|
57
|
+
You can include any front-matter, but `title`, `date` and `template` are mandatory fields
|
58
|
+
|
59
|
+
The value that you specified for the `template` field, tells the gem to look for a file named `page.html` in the `templates/` directory. Here you can specify the markup of your page.
|
60
|
+
|
61
|
+
##### Templating
|
62
|
+
Striker uses [Liquid Templating](http://liquidmarkup.org).
|
63
|
+
To define a new template add a file called `my_template.html` in `templates/` and you can specify this template in your `markdown` pages.
|
64
|
+
|
65
|
+
#### Dealing with Images
|
66
|
+
Make sure you have [ImageMagick](http://www.imagemagick.org/script/index.php) installed.
|
67
|
+
|
68
|
+
##### Add thumbnail to a page.
|
69
|
+
If you would like to make an image appear on one of your pages, simply add an image named as `thumbnail.(jpg|png|gif)` to the images directory of your page.
|
70
|
+
Eg.: If you would like to add a thumbnail to your home page, place a `thumbnail.jpg` in `images/home/thumbnail.jpg`
|
71
|
+
|
72
|
+
Then in your `home.md` you can use the custom liquid tag helper to output the image by doing:
|
73
|
+
######
|
74
|
+
{% thumbnail 250w 250h #[image-id] .[image-class] %}
|
75
|
+
|
76
|
+
Explanation:
|
77
|
+
#####
|
78
|
+
thumbnail - the tag name
|
79
|
+
250w, 250h - The desired width and height that you would like to resize the image
|
80
|
+
#[image-id] - Specify id the the image tag
|
81
|
+
.[image-class] - Specify class to the image tag
|
82
|
+
|
83
|
+
You can specify the size of the image using width/height. or you can also scale the image. For Eg.: If you would like to reduce the size of the image to 50% of the original size, you can do the following:
|
84
|
+
#####
|
85
|
+
{% thumbnail 0.5s #[image-id] .[image-class] %}
|
86
|
+
|
87
|
+
To display non-thumbnail images, drop images into the appropriate page's `images/` directory.
|
88
|
+
Then to display images in your template use the following:
|
89
|
+
#####
|
90
|
+
{% for image in page.images %}
|
91
|
+
<img src="{{ image.url }}" />
|
92
|
+
{% endfor %}
|
93
|
+
|
94
|
+
##### Start the Server
|
95
|
+
$ striker strike
|
96
|
+
This starts the server at `localhost` and port `1619`
|
97
|
+
|
98
|
+
### Some Goodies:
|
99
|
+
##### Adding tags to pages
|
100
|
+
In your `config.yml`
|
101
|
+
#
|
102
|
+
tagged:
|
103
|
+
style: tagged
|
104
|
+
This specifies the page that you want to serve for tags. For Eg.: if you want something like `http://yoursite.com/tags` change it to the following:
|
105
|
+
#
|
106
|
+
tagged:
|
107
|
+
style: tags
|
108
|
+
|
109
|
+
To create markup for your templates `striker` provides two files:
|
110
|
+
|
111
|
+
To provide markup for the main tags page. Eg.: `http://yoursite.com/tagged` add markup in the following template.
|
112
|
+
|
113
|
+
* `templates/tags/index.html`
|
114
|
+
|
115
|
+
To provide markup for a specific tag page. Eg.: `http://yoursite.com/tagged/ruby` add markup in the following template
|
116
|
+
|
117
|
+
* `templates/tags/tag.html`
|
118
|
+
|
119
|
+
##### Site Archive
|
120
|
+
Archive of posts is quite commin in blogs. If you would like to add an archive to your site, follow the below steps:
|
121
|
+
|
122
|
+
In your `config.yml` add the following if it does not exist:
|
123
|
+
#
|
124
|
+
archive:
|
125
|
+
style: archive
|
126
|
+
period: :month
|
127
|
+
|
128
|
+
The `style` parameter specifies the path name; the above would create `http://yoursite.com/archive/2013/10`
|
129
|
+
|
130
|
+
You can provide two values to the `period` parameter - `:year` or `:month`
|
131
|
+
|
132
|
+
The `:year` value would create a path like: `http://yoursite.com/archive/2013`
|
133
|
+
|
134
|
+
The `:month` value would create a path like: `http://yoursite.com/archive/2013/10`
|
135
|
+
|
136
|
+
*Note:*
|
137
|
+
|
138
|
+
For the archive to be fully functional and work as expected you need to provide the `date` in the front-matter of all your pages without which can lead to incorrect results.
|
139
|
+
|
140
|
+
The templates for specifying the markup are in `templates/archive/index.html`.
|
141
|
+
|
142
|
+
To access all site archives you can use `site.archives` in your templates
|
143
|
+
|
144
|
+
To access a specific archive in your archive templates use the following:
|
145
|
+
#
|
146
|
+
{% for page in archive.pages %}
|
147
|
+
<a href="{{ page.url }}">{{ page.title }}</a>
|
148
|
+
{% endfor %}
|
149
|
+
|
150
|
+
##### Helper Tags Available:
|
151
|
+
*Embed YouTube Video*
|
152
|
+
#####
|
153
|
+
{% youtube bNAyPK2O4fk 650w 400h %}
|
154
|
+
|
155
|
+
*Embed Vimeo Video*
|
156
|
+
#####
|
157
|
+
{% vimeo 29897413 650w 400h %}
|
158
|
+
|
159
|
+
*Embed SoundCloud Track*
|
160
|
+
#####
|
161
|
+
{% soundcloud 3058346 400w 200h %}
|
162
|
+
|
163
|
+
#### Build Website
|
164
|
+
$ striker build
|
165
|
+
Generate the final website by creating a `public/` directory
|
166
|
+
|
167
|
+
<!--
|
168
|
+
## Contributing
|
169
|
+
|
170
|
+
1. Fork it
|
171
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
172
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
173
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
174
|
+
5. Create new Pull Request
|
175
|
+
-->
|
176
|
+
|
177
|
+
|
178
|
+
[](https://bitdeli.com/free "Bitdeli Badge")
|
179
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/striker
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'commander/import'
|
5
|
+
require_relative '../lib/striker'
|
6
|
+
|
7
|
+
program :name, 'striker'
|
8
|
+
program :version, Striker::VERSION
|
9
|
+
program :description, 'Simple & Lite Static Site Generator'
|
10
|
+
|
11
|
+
command :new do |c|
|
12
|
+
c.syntax = 'striker new SITE_NAME'
|
13
|
+
c.description = 'Generates a new static site with a specified directory structure'
|
14
|
+
|
15
|
+
c.action do |args, options|
|
16
|
+
Striker::Command::New.process(args, options)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
command :page do |c|
|
21
|
+
c.syntax = 'striker page'
|
22
|
+
c.description = 'Creates a new page'
|
23
|
+
|
24
|
+
c.option '--new [name]', String, 'Create a page with a name'
|
25
|
+
c.option '--title ["title"]', String, 'Give title to the page'
|
26
|
+
c.option '--no-media', String, 'Do not create any media files the page'
|
27
|
+
c.option '--no-image', String, 'Do not create any image files the page'
|
28
|
+
c.option '--no-sound', String, 'Do not create any sound files the page'
|
29
|
+
c.option '--no-video', String, 'Do not create any video files for the page'
|
30
|
+
|
31
|
+
c.action do |args, options|
|
32
|
+
options.default :no_sound => true, :no_video => true
|
33
|
+
|
34
|
+
options = options.__hash__
|
35
|
+
Striker::Command::Page.process(args, options)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
command :build do |c|
|
40
|
+
c.syntax = 'striker build'
|
41
|
+
c.description = 'Build your website'
|
42
|
+
|
43
|
+
c.action do |args, options|
|
44
|
+
|
45
|
+
Striker::Command::Build.process
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
command :strike do |c|
|
50
|
+
c.syntax = 'striker serve'
|
51
|
+
c.description = 'Build & Preview website in the browser'
|
52
|
+
|
53
|
+
c.action do |args, options|
|
54
|
+
|
55
|
+
Striker::Command::Build.process
|
56
|
+
Striker::Command::Strike.run(args, options)
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
name: Your Website Name
|
2
|
+
port: 1619
|
3
|
+
basename: /
|
4
|
+
assets: assets
|
5
|
+
public_dir: public
|
6
|
+
permalink:
|
7
|
+
style: :name
|
8
|
+
pretty: true
|
9
|
+
tagged:
|
10
|
+
style: tagged
|
11
|
+
archive:
|
12
|
+
style: archive
|
13
|
+
period: :month
|
14
|
+
homepage: index
|
15
|
+
include_assets:
|
16
|
+
- css
|
17
|
+
- js
|
@@ -0,0 +1 @@
|
|
1
|
+
/* Write your css code here... */
|
@@ -0,0 +1 @@
|
|
1
|
+
// Write your js code here...
|
@@ -0,0 +1 @@
|
|
1
|
+
{{ archive.pages }}
|
@@ -0,0 +1 @@
|
|
1
|
+
{{ site.tags }}
|
data/lib/striker.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'yaml'
|
3
|
+
require 'mime-types'
|
4
|
+
require 'redcarpet'
|
5
|
+
require 'liquid'
|
6
|
+
require 'date'
|
7
|
+
|
8
|
+
require_relative 'striker/version'
|
9
|
+
require_relative 'striker/command/new'
|
10
|
+
require_relative 'striker/command/page'
|
11
|
+
require_relative 'striker/command/build'
|
12
|
+
require_relative 'striker/command/strike'
|
13
|
+
require_relative 'striker/settings'
|
14
|
+
require_relative 'striker/site'
|
15
|
+
require_relative 'striker/page'
|
16
|
+
require_relative 'striker/template'
|
17
|
+
require_relative 'striker/tag'
|
18
|
+
require_relative 'striker/archive'
|
19
|
+
require_relative 'striker/media/image'
|
20
|
+
require_relative 'striker/tags/thumbnail'
|
21
|
+
require_relative 'striker/tags/youtube'
|
22
|
+
require_relative 'striker/tags/vimeo'
|
23
|
+
require_relative 'striker/tags/soundcloud'
|
24
|
+
require_relative 'striker/tags/tweet'
|
25
|
+
|
26
|
+
module Striker
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Striker
|
2
|
+
class Archive
|
3
|
+
|
4
|
+
if File.exists? File.join(Settings::SOURCE_DIR, "config.yml")
|
5
|
+
@@dir = Settings::CONFIG['archive']['style']
|
6
|
+
@@period = Settings::CONFIG['archive']['period']
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.process(site_meta)
|
10
|
+
@@site_meta = site_meta
|
11
|
+
FileUtils.mkdir_p(File.join(Settings::PUBLIC_DIR, @@dir))
|
12
|
+
process_archive_dir
|
13
|
+
process_files
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.list_full
|
17
|
+
grouped_pages = []
|
18
|
+
pages = []
|
19
|
+
Dir.chdir(Settings::PAGES_DIR)
|
20
|
+
Dir.glob("*[.md|.markdown]").each do |page|
|
21
|
+
grouped_pages << Page.new(page).page_data
|
22
|
+
end
|
23
|
+
if @@period == :year
|
24
|
+
grouped_pages = grouped_pages.group_by{ |page| page['date'].strftime("%Y") }
|
25
|
+
else
|
26
|
+
grouped_pages = grouped_pages.group_by{ |page| [page['date'].strftime("%Y"), page['date'].strftime("%B")] }
|
27
|
+
end
|
28
|
+
grouped_pages.each do |p|
|
29
|
+
if p[0].class == Array
|
30
|
+
date = Date.new(p[0][0].to_i, Date::MONTHNAMES.index(p[0][1]), 1)
|
31
|
+
url = File.join(Settings::CONFIG['basename'], @@dir, date.year.to_s, date.month.to_s)
|
32
|
+
else
|
33
|
+
date = p[0]
|
34
|
+
url = File.join(Settings::CONFIG['basename'], @@dir, date)
|
35
|
+
end
|
36
|
+
|
37
|
+
pages << { 'date' => date, 'pages' => p[1], 'url' => url }
|
38
|
+
end
|
39
|
+
pages
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.process_archive_dir
|
43
|
+
list_full.each do |archive|
|
44
|
+
Dir.chdir(File.join(Settings::PUBLIC_DIR, @@dir))
|
45
|
+
if archive['date'].class == Date
|
46
|
+
FileUtils.mkdir_p(File.join(archive['date'].year.to_s, archive['date'].month.to_s))
|
47
|
+
else
|
48
|
+
FileUtils.mkdir_p(archive['date'].to_s)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.process_files
|
54
|
+
@@site_meta['archive'].each do |archive|
|
55
|
+
process_main_template(archive)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.process_main_template(archive)
|
60
|
+
Dir.chdir(Settings::TEMPLATES_DIR)
|
61
|
+
template = File.read(File.join("archive", "index.html"))
|
62
|
+
parsed_data = Liquid::Template.parse(template).render('site' => @@site_meta, 'archive' => archive)
|
63
|
+
Dir.chdir(Settings::PUBLIC_DIR)
|
64
|
+
File.open(File.join(Settings::PUBLIC_DIR, archive['url'], "index.html"), "w") do |file|
|
65
|
+
file.write(parsed_data)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
private_class_method :process_archive_dir, :process_files, :process_main_template
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|