jekyll-transform 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. checksums.yaml +7 -0
  2. data/.index +47 -0
  3. data/HISTORY.md +9 -0
  4. data/LICENSE.txt +23 -0
  5. data/README.md +91 -0
  6. data/lib/jekyll-transform.rb +105 -0
  7. metadata +67 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2af0c2ea81575418b63f6117c075911979dcb017
4
+ data.tar.gz: 237e4981848bdf715966e211e4a8a9ec0e7e4ae9
5
+ SHA512:
6
+ metadata.gz: 3e3c7f1afc4d49326ab3191c9ea898fae613ec4de2af51719d2f0d8f8f0b4cdb13a1928c14ee36f456af837616c75e54196168e9de54cecb054d20598bf9dacb
7
+ data.tar.gz: 76f57ab6d9caa5d4fe2a5167c1098c1c7737d80cc07643ed4fe0a85e9c9572ad2a18f29851f658899067a7e96f99ead7e8d1074c7a94075b7dca4c6e35f5a0e1
data/.index ADDED
@@ -0,0 +1,47 @@
1
+ ---
2
+ revision: 2013
3
+ type: ruby
4
+ sources:
5
+ - var
6
+ authors:
7
+ - name: Trans
8
+ email: transfire@gmail.com
9
+ organizations: []
10
+ requirements:
11
+ - name: jekyll
12
+ conflicts: []
13
+ alternatives: []
14
+ resources:
15
+ - type: home
16
+ uri: http://rubyworks.github.com/jekyll-transform
17
+ label: Homepage
18
+ - type: code
19
+ uri: http://github.com/rubyworks/jekyll-transform
20
+ label: Source Code
21
+ - type: docs
22
+ uri: http://rubydoc.info/gems/jekyll-transform/frames
23
+ label: Documentation
24
+ - type: mail
25
+ uri: http://groups.google.com/groups/rubyworks-mailinglist
26
+ label: Mailing List
27
+ repositories:
28
+ - name: upstream
29
+ scm: git
30
+ uri: git://github.com/rubyworks/kekyll-transform.git
31
+ categories: []
32
+ copyrights:
33
+ - holder: Rubyworks
34
+ year: '2013'
35
+ license: BSD-2-Clause
36
+ customs: []
37
+ paths:
38
+ lib:
39
+ - lib
40
+ name: jekyll-transform
41
+ title: Jekyll Transform
42
+ summary: Transform any directory into a website!
43
+ created: '2013-08-09'
44
+ description: "Jykell Transform converts transforms external sources \ninto a Jykell
45
+ managable material."
46
+ version: 0.1.0
47
+ date: '2013-08-09'
@@ -0,0 +1,9 @@
1
+ # RELEASE HISTORY
2
+
3
+ ## 0.1.0 / 2013-08-10
4
+
5
+ This is the initial release of Jekyll Transform.
6
+
7
+ Changes:
8
+
9
+ * Happy Release Day!
@@ -0,0 +1,23 @@
1
+ (SPDX) BSD-2-Clause License
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions are met:
5
+
6
+ * Redistributions of source code must retain the above copyright notice,
7
+ this list of conditions and the following disclaimer.
8
+
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY Thomas Sawyer ``AS IS'' AND ANY EXPRESS
14
+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
16
+ NO EVENT SHALL Thomas Sawyer OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
17
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
18
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
20
+ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
22
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+
@@ -0,0 +1,91 @@
1
+ # Jekyll Transform
2
+
3
+ **Transform your documents into a Jekyll site!**
4
+
5
+ ## About
6
+
7
+ Jekyll Transform allows Jekyll to use any directory as a source for markup
8
+ documents in the construction of a website. The documents within the
9
+ directory **do not need YAML front matter**. A good example how this can be
10
+ useful is taking a Gollum wiki and using its contents for the creation of
11
+ a custom website.
12
+
13
+
14
+ ## Usage
15
+
16
+ Jekyll Transform works as a Jekyll plugin.
17
+
18
+ You first need to have a Jekyll setup in accordance with Jekyll's specification.
19
+ With a Jekyll site in place you simply need to add a `transform.rb` file to
20
+ your site's `_plugins` directory containing:
21
+
22
+ require `jekyll-transform'
23
+
24
+ Then in your `_config.yml` file add:
25
+
26
+ transform:
27
+ folder: '_wiki'
28
+ page_yaml:
29
+ layout: page
30
+ post_yaml:
31
+ layout: post
32
+
33
+ Change the confgiuration to meet your needs. The `folder` settings
34
+ tells it where to find the files to be transformed. In our example
35
+ we use `_wiki` because we want to it to contain a cloned Gollum wiki
36
+ repository. If no entry is given the default is `_trans`. The `page_yaml`
37
+ and `post_yaml` entries specify the YAML front matter to add to pages
38
+ and posts respecively. If not given the defaults are as shown above,
39
+ `page` and `post`.
40
+
41
+ Jekyll transform distinguishes posts from pages simply soley by the name
42
+ of the file starting with a date. It does not matter where they are located
43
+ in the directory. And pages will keep their relative paths.
44
+
45
+ Drafts are not yet supported, but that will be added in future release.
46
+ In the mean time you can still set `future: false` and date your drafts
47
+ far in the future.
48
+
49
+
50
+ ## Tips
51
+
52
+ ### Is it possible to customize files individually?
53
+
54
+ If your documents can contain HTML style comments then you can add YAML
55
+ matter to the bottom of the document. For instance, perhaps specfic
56
+ documents require a `speical` layout. Adding the following to the bottom
57
+ of the document will allow Jekyll to use it as the documents YAML front
58
+ matter.
59
+
60
+ ```html
61
+ <!--- ---
62
+ layout: special
63
+ --->
64
+ ```
65
+
66
+ In the future we might allow YAML front matter to be set via glob matches
67
+ in the _config.yml, if there are requests for the feature.
68
+
69
+ ### How does Jekyll Transfrom compare to Smeagol?
70
+
71
+ Smeagol is a little different in that it is specifcally designed for use
72
+ with Gollum wikis. It is also, first and foremost, a Rack-based service
73
+ for serving up a Gollum wiki as a customize website. New versions do include
74
+ a static site generator, but its generation features aren't as polished as
75
+ Jekyll's. On the other hand, Smeagol does supports all markup languages
76
+ that Gollum supports and more faithly renders them in the same manner as
77
+ Gollum (because it in most cases it passes the chore off to Gollum).
78
+
79
+
80
+ ## Copyrights
81
+
82
+ Copyright (c) 2013 Rubyworks
83
+
84
+ Hyde is open-source software distributed under the BSD-2-Clause license.
85
+
86
+ See LICENSE.txt for details.
87
+
88
+
89
+
90
+
91
+
@@ -0,0 +1,105 @@
1
+ module Jekyll
2
+
3
+ class TransformPage < Page
4
+ # Read the YAML frontmatter.
5
+ #
6
+ # base - The String path to the dir containing the file.
7
+ # name - The String filename of the file.
8
+ #
9
+ # Returns nothing.
10
+ def read_yaml(base, name)
11
+ begin
12
+ self.content = File.read(File.join(base, name))
13
+
14
+ config_data = (site.config['transform'] || {})['page_yaml'] || {} #{'layout'=>'default'}
15
+ if self.content =~ /(<!---\s+---\s*\n.*?\n?)^(---\s*$\n?)/m
16
+ self.content = $POSTMATCH
17
+ self.data = config_data.merge(YAML.safe_load($1))
18
+ else
19
+ self.data = config_data
20
+ end
21
+ rescue SyntaxError => e
22
+ puts "YAML Exception reading #{File.join(base, name)}: #{e.message}"
23
+ rescue Exception => e
24
+ puts "Error reading file #{File.join(base, name)}: #{e.message}"
25
+ end
26
+
27
+ self.data ||= {'layout'=>'page'}
28
+ end
29
+ end
30
+
31
+ class TransformPost < Post
32
+ # Read the YAML frontmatter.
33
+ #
34
+ # base - The String path to the dir containing the file.
35
+ # name - The String filename of the file.
36
+ #
37
+ # Returns nothing.
38
+ def read_yaml(base, name)
39
+ begin
40
+ self.content = File.read(File.join(base, name))
41
+
42
+ config_data = (site.config['transform'] || {})['post_yaml'] || {} #{'layout'=>'default'}
43
+ if self.content =~ /(<!---\s+---\s*\n.*?\n?)^(---\s*$\n?)/m
44
+ self.content = $POSTMATCH
45
+ self.data = config_data.merge(YAML.safe_load($1))
46
+ else
47
+ self.data = config_data
48
+ end
49
+ rescue SyntaxError => e
50
+ puts "YAML Exception reading #{File.join(base, name)}: #{e.message}"
51
+ rescue Exception => e
52
+ puts "Error reading file #{File.join(base, name)}: #{e.message}"
53
+ end
54
+
55
+ self.data ||= {'layout'=>'post'}
56
+
57
+ self.extracted_excerpt = self.extract_excerpt
58
+ end
59
+
60
+ def path
61
+ self.data['path'] || File.join(@dir, @name).sub(/\A\//, '')
62
+ end
63
+
64
+ def containing_dir(source, dir)
65
+ return File.join(source, dir)
66
+ end
67
+ end
68
+
69
+
70
+ class TransformGenerator < Generator
71
+ safe true
72
+
73
+ #
74
+ # TODO: Handle drafts.
75
+ #
76
+ def generate(site)
77
+ return unless site.config.key?('transform')
78
+
79
+ folder = site.config['transform']['folder'] || '_trans'
80
+ source = File.join(site.source, folder)
81
+ files = transform_entries(source)
82
+ files.each do |file|
83
+ if is_post?(File.join(source, file))
84
+ post = TransformPost.new(site, source, File.dirname(file), File.basename(file))
85
+ site.posts << post
86
+ else
87
+ page = TransformPage.new(site, source, File.dirname(file), File.basename(file))
88
+ site.pages << page
89
+ end
90
+ end
91
+ end
92
+
93
+ def transform_entries(dir)
94
+ Dir.glob(File.join(dir, '**/*')).map do |d|
95
+ d.sub(dir+'/', '')
96
+ end
97
+ end
98
+
99
+ def is_post?(file)
100
+ /\d\d\d\d-\d\d-\d\d/ =~ File.basename(file)
101
+ end
102
+
103
+ end
104
+
105
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-transform
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Trans
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: "Jykell Transform converts transforms external sources \ninto a Jykell
28
+ managable material."
29
+ email:
30
+ - transfire@gmail.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files:
34
+ - LICENSE.txt
35
+ - README.md
36
+ - HISTORY.md
37
+ files:
38
+ - .index
39
+ - lib/jekyll-transform.rb
40
+ - README.md
41
+ - HISTORY.md
42
+ - LICENSE.txt
43
+ homepage: http://rubyworks.github.com/jekyll-transform
44
+ licenses:
45
+ - BSD-2-Clause
46
+ metadata: {}
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project:
63
+ rubygems_version: 2.0.3
64
+ signing_key:
65
+ specification_version: 4
66
+ summary: Transform any directory into a website!
67
+ test_files: []