jekyll-pug 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f797b15de38684188dd3e881bbb882b0c5bfffab
4
- data.tar.gz: 6972df5f89bb45d524afebfe277062051e650481
3
+ metadata.gz: 25bfef7691615e1ab72b0a410561f5817d1be190
4
+ data.tar.gz: fdb7cb4a43a15bde3042e8f3f683e93b77453818
5
5
  SHA512:
6
- metadata.gz: e261fdbf0ba394a9282cfe1c3a0bd777efb8eeefa6cb67e1fc3340a6a21c64314cd57a04dff3db1c2915868403d554978ee8d50da1f2276b67078b4eb0b35a94
7
- data.tar.gz: c22559b5080567e8d3a2e0ecd8b5312e481a409d8c9268ea67ff46305a4c5cdf47be34dccbe6777a0c37b16532ed7eaff21dc7253626fcb1c99f9a8fa1add729
6
+ metadata.gz: e3ceaf10e1a88c1ffe3d87a69ba2a50ca1523eb2f24d649ac86fb997a4440c4583f5f14c3430bd9d8ef8d549716cf71b4d077689e008c057b4739db22c44e740
7
+ data.tar.gz: 32e6c7c592ac5faf5c7e59c6ab61fdfccc937c090c3cc807c4870420a6958c8edbaaba5ede1ab64620a9ab3d7f2a5e6e4b330600bab1d66f2353136b1f890c63
@@ -1,23 +1,17 @@
1
1
  require "pug-ruby"
2
+ require "jekyll-pug/pug-renderer"
3
+ require "jekyll-pug/include-tag"
2
4
 
3
- require "jekyll-pug/tags/pug_partial"
4
- require "jekyll-pug/ext/convertible"
5
-
6
- module Jekyll
7
- class PugConverter < Converter
8
- safe true
9
- priority :low
10
-
11
- def matches(ext)
12
- ext =~ /^\.pug$/i
13
- end
14
-
15
- def output_ext(ext)
16
- ".html"
17
- end
18
-
19
- def convert(content)
20
- return Pug.compile(content, {"filename"=>"./_includes/."})
21
- end
22
- end
5
+ # Enable/Disable Minfify based on the user's config file.
6
+ if Jekyll.configuration({})['jekyll-pug']
7
+ if Jekyll.configuration({})['jekyll-pug']['minify']
8
+ # Minify is enabled - pretty disabled
9
+ Pug.config.pretty = false
10
+ else
11
+ # Minify is disabled - pretty enabled
12
+ Pug.config.pretty = true
13
+ end
14
+ else
15
+ # Enable pretty by default
16
+ Pug.config.pretty = true
23
17
  end
@@ -0,0 +1,92 @@
1
+ require 'pug-ruby'
2
+
3
+ module Jekyll
4
+ module Tags
5
+ class JekyllPug_IncludeTag < IncludeTag
6
+ def initialize(tag_name, markup, tokens)
7
+ super
8
+ matched = markup.strip.match(VARIABLE_SYNTAX)
9
+ if matched
10
+ @file = matched["variable"].strip
11
+ @params = matched["params"].strip
12
+ else
13
+ @file, @params = markup.strip.split(%r!\s+!, 2)
14
+ end
15
+ # If file does not have an extension...
16
+ if @file !~ /\.\w+$/
17
+ # ...add a .pug
18
+ # "navigation" -> "navigation.pug"
19
+ @file = @file + ".pug"
20
+ @isPug = true
21
+ else
22
+ @isPug = false
23
+ end
24
+ validate_params if @params
25
+ @tag_name = tag_name
26
+ end
27
+ # Render the variable if required
28
+ def render_variable(context)
29
+ if @file.match(VARIABLE_SYNTAX)
30
+ partial = context.registers[:site]
31
+ .liquid_renderer
32
+ .file("(variable)")
33
+ .parse(@file)
34
+ partial.render!(context)
35
+ end
36
+ end
37
+
38
+ def locate_include_file(context, file, safe)
39
+ includes_dirs = tag_includes_dirs(context)
40
+ includes_dirs.each do |dir|
41
+ path = File.join(dir.to_s, file.to_s)
42
+ return path if valid_include_file?(path, dir.to_s, safe)
43
+ end
44
+ raise IOError, "Could not locate the included file '#{file}' in any of "\
45
+ "#{includes_dirs}. Ensure it exists in one of those directories and, "\
46
+ "if it is a symlink, does not point outside your site source."
47
+ end
48
+
49
+ def render(context)
50
+ site = context.registers[:site]
51
+ file = render_variable(context) || @file
52
+ validate_file_name(file)
53
+
54
+ path = locate_include_file(context, file, site.safe)
55
+ return unless path
56
+
57
+
58
+ add_include_to_dependency(site, path, context)
59
+
60
+ partial = load_cached_partial(path, context)
61
+ context.stack do
62
+ context["include"] = parse_params(context) if @params
63
+ begin
64
+ partial.render!(context)
65
+ rescue Liquid::Error => e
66
+ e.template_name = path
67
+ e.markup_context = "included " if e.markup_context.nil?
68
+ raise e
69
+ end
70
+ end
71
+ end
72
+ end
73
+
74
+ class JekyllPug_IncludeRelativeTag < IncludeTag
75
+ def tag_includes_dirs(context)
76
+ Array(page_path(context)).freeze
77
+ end
78
+
79
+ def page_path(context)
80
+ if context.registers[:page].nil?
81
+ context.registers[:site].source
82
+ else
83
+ current_doc_dir = File.dirname(context.registers[:page]["path"])
84
+ context.registers[:site].in_source_dir current_doc_dir
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
90
+
91
+ Liquid::Template.register_tag("include", Jekyll::Tags::JekyllPug_IncludeTag)
92
+ Liquid::Template.register_tag("include_relative", Jekyll::Tags::JekyllPug_IncludeRelativeTag)
@@ -0,0 +1,40 @@
1
+ # This is where the magic happens
2
+ module Jekyll
3
+ class LiquidRenderer
4
+ File.class_eval do
5
+ def parse(content)
6
+ measure_time do
7
+ if @filename =~ /\.pug$/
8
+ content = Pug.compile(content, {"filename"=>"./_includes/."})
9
+ end
10
+ # if content.lines.first =~ /^$/
11
+ # content = content.sub(/^$\n/, "")
12
+ # end
13
+ @template = Liquid::Template.parse(content, :line_numbers => true)
14
+ end
15
+
16
+ self
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ # This section ensures that Pug files are compiled as HTML.
23
+ module Jekyll
24
+ class PugConverter < Converter
25
+ safe true
26
+ priority :low
27
+
28
+ def matches(ext)
29
+ ext =~ /^\.pug$/i
30
+ end
31
+
32
+ def output_ext(ext)
33
+ ".html"
34
+ end
35
+
36
+ def convert(content)
37
+ return content
38
+ end
39
+ end
40
+ end
metadata CHANGED
@@ -1,75 +1,56 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-pug
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Doug Beney
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-24 00:00:00.000000000 Z
11
+ date: 2017-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 3.3.0
19
+ version: '3.3'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 3.3.0
26
+ version: '3.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pug-ruby
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.0'
41
- description: Pug to HTML converter for Jekyll
41
+ description: Flawlessly use Pug with Jekyll to convert Pug files into HTMl
42
42
  email:
43
- - work@dougbeney.com
43
+ - work@dougie.io
44
44
  executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - ".DS_Store"
49
- - ".gitignore"
50
- - Gemfile
51
- - LICENSE.txt
52
- - README.md
53
- - Rakefile
54
- - jekyll-pug.gemspec
55
- - lib/.DS_Store
56
48
  - lib/jekyll-pug.rb
57
- - lib/jekyll-pug/.DS_Store
58
- - lib/jekyll-pug/ext/convertible.rb
59
- - lib/jekyll-pug/tags/pug_partial.rb
60
- - test-site/Gemfile
61
- - test-site/_includes/footer.pug
62
- - test-site/_includes/nav.pug
63
- - test-site/_includes/variables_and_mixins.pug
64
- - test-site/_layouts/default.pug
65
- - test-site/_site/index.html
66
- - test-site/_site/main.css
67
- - test-site/_site/readme.md
68
- - test-site/index.pug
69
- - test-site/main.css
70
- - test-site/readme.md
71
- homepage: https://github.com/DougBeney/jekyll-pug
72
- licenses: []
49
+ - lib/jekyll-pug/include-tag.rb
50
+ - lib/jekyll-pug/pug-renderer.rb
51
+ homepage: http://jekyll-pug.dougie.io/
52
+ licenses:
53
+ - MIT
73
54
  metadata: {}
74
55
  post_install_message:
75
56
  rdoc_options: []
@@ -87,8 +68,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
68
  version: '0'
88
69
  requirements: []
89
70
  rubyforge_project:
90
- rubygems_version: 2.6.12
71
+ rubygems_version: 2.6.14
91
72
  signing_key:
92
73
  specification_version: 4
93
- summary: Convert Pug files to standard HTML files as part of your Jekyll build.
74
+ summary: Use Pug with Jekyll.
94
75
  test_files: []
data/.DS_Store DELETED
Binary file
data/.gitignore DELETED
@@ -1,17 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in jekyll-pug.gemspec
4
- gemspec
@@ -1,22 +0,0 @@
1
- Copyright (c) 2017 Doug Beney
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 DELETED
@@ -1,77 +0,0 @@
1
- # Jekyll::Haml
2
-
3
- This gem provides a [Jekyll](http://github.com/mojombo/jekyll) converter for
4
- [Haml](http://haml.info) files.
5
-
6
- ## Installation
7
-
8
- If using [Bundler](http://gembundler.com), add these lines to your application's Gemfile:
9
-
10
- ```rb
11
- group :jekyll_plugins do
12
- gem 'jekyll-pug'
13
- end
14
- ```
15
-
16
- Alternatively, if you don't use Bundler, just update your Jekyll project's `_config.yml`:
17
-
18
- ```yml
19
- gems:
20
- - jekyll-pug
21
- ```
22
-
23
- ## Usage
24
-
25
- You'll be able to use all of Haml's tricks to write some really clean markup. You can use liquid filters easily by just rendering the liquid tags as shown below. Have fun!
26
-
27
- ```haml
28
- ---
29
- title: Story Time
30
- permalink: page/
31
- ---
32
- .container
33
- %h3= "{% title %}"
34
-
35
- :javascript
36
- $(document).ready(function(){});
37
- ```
38
-
39
- ### Markdown blocks
40
-
41
- For clean content blocks, I find it helps to use Haml's `:markdown` filter if I can get away with it.
42
-
43
- ```haml
44
- .content
45
- :markdown
46
- *Dec 4, 2012* - [Author](http://github.com)
47
-
48
- Once upon a time, in a village by the sea...
49
- ```
50
-
51
- ### Partials
52
-
53
- The gem adds the liquid filter `haml` so you can render `_includes` that are written in Haml as well.
54
-
55
- ```liquid
56
- {% haml comments.haml %}
57
- ```
58
-
59
- ```haml
60
- -# _includes/meta.haml
61
- %meta{property: 'og:type', content: 'website'}
62
- %meta{name: 'viewport', content: 'width=device-width'}
63
- ```
64
-
65
- ## About
66
-
67
- I originally searched around the internet for a quick way to integrate HAML into my jekyll workflow and found a few around the internet to convert haml in different cases (layouts, partials, and posts). This gem is really just a collection of those techniques so they're easy to find and you can get back to creating your site using the slickest markup. It's made to drop in to your `Gemfile` just as easily as [jekyll-sass](https://github.com/noct/jekyll-sass).
68
-
69
- If you're using this stuff, you may also be interested in [Octopress](http://octopress.org). I believe it includes support for Haml/Sass out of the gate.
70
-
71
- ## Contributing
72
-
73
- 1. Fork it
74
- 2. Create your feature branch (`git checkout -b my-new-feature`)
75
- 3. Commit your changes (`git commit -am 'Add some feature'`)
76
- 4. Push to the branch (`git push origin my-new-feature`)
77
- 5. Create new Pull Request
data/Rakefile DELETED
@@ -1 +0,0 @@
1
- require "bundler/gem_tasks"
@@ -1,21 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
-
5
- Gem::Specification.new do |gem|
6
- gem.name = "jekyll-pug"
7
- gem.version = "0.0.1"
8
- gem.authors = ["Doug Beney"]
9
- gem.email = ["work@dougbeney.com"]
10
- gem.description = %q{Pug to HTML converter for Jekyll}
11
- gem.summary = %q{Convert Pug files to standard HTML files as part of your Jekyll build.}
12
- gem.homepage = "https://github.com/DougBeney/jekyll-pug"
13
-
14
- gem.files = `git ls-files`.split($/)
15
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
- gem.require_paths = ["lib"]
18
-
19
- gem.add_runtime_dependency 'jekyll', '>= 3.3.0'
20
- gem.add_runtime_dependency 'pug-ruby', '>= 1.0'
21
- end
Binary file
Binary file
@@ -1,19 +0,0 @@
1
- # Re-open Layout class to convert our Pug Layout content.
2
- module Jekyll
3
- class Layout
4
- alias old_initialize initialize
5
-
6
- def initialize(*args)
7
- old_initialize(*args)
8
- self.content = transform
9
- end
10
-
11
- def transform
12
- _renderer.convert(content)
13
- end
14
-
15
- def extname
16
- ext
17
- end
18
- end
19
- end
@@ -1,67 +0,0 @@
1
- require 'pug-ruby'
2
- require 'open3'
3
-
4
- module Jekyll
5
- class PugPartialTag < Liquid::Tag
6
- isHTML = false
7
-
8
- def initialize(tag_name, file, tokens)
9
- super
10
- @file = file.strip
11
- end
12
-
13
- def render(context)
14
- includes_dir = File.join(context.registers[:site].source, '_includes')
15
-
16
- if File.symlink?(includes_dir)
17
- return "Includes directory '#{includes_dir}' cannot be a symlink"
18
- end
19
-
20
- if @file !~ /^[a-zA-Z0-9_\/\.-]+$/ || @file =~ /\.\// || @file =~ /\/\./
21
- return "Include file '#{@file}' contains invalid characters or sequences"
22
- end
23
-
24
- if @file !~ /\.html$/
25
- isHTML = false
26
- else
27
- isHTML = true
28
- end
29
-
30
- if @file !~ /\.pug$/
31
- if !isHTML
32
- @file << ".pug"
33
- end
34
- end
35
-
36
- Dir.chdir(includes_dir) do
37
- choices = Dir['**/*'].reject { |x| File.symlink?(x) }
38
- if choices.include?(@file)
39
- source = File.read(@file)
40
- if !isHTML
41
- conversion = Pug.compile(source, {"filename" => includes_dir + "/."})
42
- else
43
- conversion = source
44
- end
45
- partial = Liquid::Template.parse(conversion)
46
- begin
47
- return partial.render!(context)
48
- rescue => e
49
- puts "Liquid Exception: #{e.message} in #{data['layout']}"
50
- e.backtrace.each do |backtrace|
51
- puts backtrace
52
- end
53
- abort('Build Failed')
54
- end
55
-
56
- context.stack do
57
- return partial.render(context)
58
- end
59
- else
60
- "Included file '#{@file}' not found in _includes directory"
61
- end
62
- end
63
- end
64
- end
65
- end
66
-
67
- Liquid::Template.register_tag('include', Jekyll::PugPartialTag)
@@ -1,5 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- group :jekyll_plugins do
4
- gem "jekyll-pug", :path => "../"
5
- end
@@ -1 +0,0 @@
1
- p Copyright 2017 - All Rights Reserved. - (Just kidding! Open-Source, baby!)
@@ -1,5 +0,0 @@
1
- nav
2
- ul
3
- li Home
4
- li About
5
- li: a(href="https://dougbeney.com/contact/") Contact
@@ -1,8 +0,0 @@
1
- - var cool_variable = "I am a cool variable!!";
2
-
3
- mixin list_stuff
4
- h1 This list is generated with a Pug mixin
5
- ul
6
- li One
7
- li Two
8
- li Three
@@ -1,19 +0,0 @@
1
- include variables_and_mixins
2
-
3
- doctype
4
- html
5
- head
6
- title {{page.title}}
7
- link(rel="stylesheet", href="/main.css")
8
- body
9
- .container
10
- h1 {{page.title}}
11
- | {% include nav %}
12
- .content {{content}}
13
-
14
- +list_stuff
15
-
16
- h1 Check out this Pug variable:
17
- p= cool_variable
18
-
19
- | {% include footer %}
@@ -1 +0,0 @@
1
- <!DOCTYPE html><html><head><title>Welcome To The Jekyll-Pug Example Site!</title><link rel="stylesheet" href="/main.css"></head><body><div class="container"><h1>Welcome To The Jekyll-Pug Example Site!</h1><nav><ul><li>Home</li><li>About</li><li><a href="https://dougbeney.com/contact/">Contact</a></li></ul></nav><div class="content"><p><strong>If you're interested in contributing to Jekyll-Pug, use this sample site to help you debug.</strong></p><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p></div><h1>This list is generated with a Pug mixin</h1><ul><li>One</li><li>Two</li><li>Three</li></ul><h1>Check out this Pug variable:</h1><p>I am a cool variable!!</p><p>Copyright 2017 - All Rights Reserved. - (Just kidding! Open-Source, baby!)</p></div></body></html>
@@ -1,27 +0,0 @@
1
- html, body{
2
- font-family: sans-serif;
3
- line-height: 1.9;
4
- margin: 0;
5
- }
6
-
7
- .container{
8
- max-width: 750px;
9
- margin: 0 auto;
10
- }
11
-
12
- p, h1, h2, ul{
13
- margin-top: 30px;
14
- }
15
-
16
- nav ul {
17
- padding: 0;
18
- display: block;
19
- width: auto;
20
- margin: 0 auto;
21
- background: #ccc;
22
- text-align: center;
23
- }
24
- nav li{
25
- display: inline;
26
- margin: 10px 20px;
27
- }
@@ -1 +0,0 @@
1
- This is a test Jekyll site - How I debug this plugin.
@@ -1,8 +0,0 @@
1
- ---
2
- title: Welcome To The Jekyll-Pug Example Site!
3
- layout: default
4
- ---
5
-
6
- p: strong If you're interested in contributing to Jekyll-Pug, use this sample site to help you debug.
7
-
8
- p Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
@@ -1,27 +0,0 @@
1
- html, body{
2
- font-family: sans-serif;
3
- line-height: 1.9;
4
- margin: 0;
5
- }
6
-
7
- .container{
8
- max-width: 750px;
9
- margin: 0 auto;
10
- }
11
-
12
- p, h1, h2, ul{
13
- margin-top: 30px;
14
- }
15
-
16
- nav ul {
17
- padding: 0;
18
- display: block;
19
- width: auto;
20
- margin: 0 auto;
21
- background: #ccc;
22
- text-align: center;
23
- }
24
- nav li{
25
- display: inline;
26
- margin: 10px 20px;
27
- }
@@ -1 +0,0 @@
1
- This is a test Jekyll site - How I debug this plugin.