jekyll-page-hooks 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -15,3 +15,5 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .DS_Store
19
+ _site
data/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # Changelog
2
+
3
+ ### 1.0.0
4
+ - Initial release.
5
+
6
+ ### 1.0.1
7
+ - Naming refactor
8
+
9
+ ### 1.0.2
10
+ - Now requires Jekyll (oops)
11
+ - Added tests
12
+
data/README.md CHANGED
@@ -51,6 +51,8 @@ module Jekyll
51
51
  end
52
52
  ```
53
53
 
54
+ For a more complete example, check out [test.rb](test/_plugins/test.rb) and [index.md](test/index.md).
55
+
54
56
  ### When to use what
55
57
 
56
58
  With `pre_render` you can access page and post data before it has been
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
13
13
  gem.homepage = "http://github.com/octopress/jekyll-page-hooks"
14
14
  gem.license = "MIT"
15
15
 
16
- gem.add_dependency 'jekyll', '>= 1.0.0'
16
+ gem.add_runtime_dependency 'jekyll', '>= 1.0.0'
17
17
 
18
18
  gem.files = `git ls-files`.split($/)
19
19
  gem.require_paths = ["lib"]
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module PageHooksVersion
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
5
5
  end
@@ -1,3 +1,5 @@
1
+ require 'jekyll'
2
+
1
3
  module Jekyll
2
4
 
3
5
  # Extended plugin type that allows the plugin
data/test/.gitignore ADDED
@@ -0,0 +1 @@
1
+ _site
data/test/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'jekyll-page-hooks', :path => '../'
4
+
data/test/_config.yml ADDED
@@ -0,0 +1,3 @@
1
+ name: Your New Jekyll Site
2
+ markdown: redcarpet
3
+ pygments: true
@@ -0,0 +1,46 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
6
+ <title>{{ page.title }}</title>
7
+ <meta name="viewport" content="width=device-width">
8
+
9
+ <!-- syntax highlighting CSS -->
10
+ <link rel="stylesheet" href="/css/syntax.css">
11
+
12
+ <!-- Custom CSS -->
13
+ <link rel="stylesheet" href="/css/main.css">
14
+
15
+ </head>
16
+ <body>
17
+
18
+ <div class="container">
19
+ <div class="site">
20
+ <div class="header">
21
+ <h1 class="title"><a href="/">{{ site.name }}</a></h1>
22
+ <a class="extra" href="/">home</a>
23
+ </div>
24
+
25
+ {{ content }}
26
+
27
+ <div class="footer">
28
+ <div class="contact">
29
+ <p>
30
+ Your Name<br />
31
+ What You Are<br />
32
+ your@email.com
33
+ </p>
34
+ </div>
35
+ <div class="contact">
36
+ <p>
37
+ <a href="http://github.com/yourusername/">github.com/yourusername</a><br />
38
+ <a href="http://twitter.com/yourusername/">twitter.com/yourusername</a><br />
39
+ </p>
40
+ </div>
41
+ </div>
42
+ </div>
43
+ </div> <!-- /container -->
44
+
45
+ </body>
46
+ </html>
@@ -0,0 +1,9 @@
1
+ ---
2
+ layout: default
3
+ ---
4
+ <h2>{{ page.title }}</h2>
5
+ <p class="meta">{{ page.date | date_to_string }}</p>
6
+
7
+ <div class="post">
8
+ {{ content }}
9
+ </div>
@@ -0,0 +1,57 @@
1
+ require 'jekyll-page-hooks'
2
+ require 'time'
3
+
4
+ module Jekyll
5
+ class PageHooksTest < PageHooks
6
+
7
+ # Inherited methods from PageHooks
8
+
9
+ # Called before processors
10
+ #
11
+ def pre_render(page)
12
+ page.content = snatch_cupcake page.content
13
+ end
14
+
15
+ # Called after processors
16
+ #
17
+ def post_render(page)
18
+ page.content = blink_strong page.content
19
+ end
20
+
21
+ # Called after write
22
+ #
23
+ def post_write(page)
24
+ log_page page
25
+ end
26
+
27
+ # Plugin methods
28
+
29
+ # Replaces *cupcake* with _______ before markdown renders <em>cupcake</em>.
30
+ #
31
+ def snatch_cupcake(content)
32
+ content.sub /\*cupcake\*/, '_______'
33
+ end
34
+
35
+ # Replaces <strong> tag with <strong><blink> after html has been rendered.
36
+ #
37
+ def blink_strong(content)
38
+ content.gsub /<strong>(.+?)<\/strong>/ do
39
+ "<strong><blink>#{$1}</blink></strong>"
40
+ end
41
+ end
42
+
43
+ # Rewrites the generated file on disk, replacing ::time:: with a <time> tag
44
+ # noting when the file was written.
45
+ #
46
+ def log_page(page)
47
+ time = Time.now
48
+ content = page.output.gsub /::time::/ do
49
+ "<time datetime='#{time.utc.iso8601}'>#{time.localtime.strftime('%Y-%m-%d %H:%M:%s')}</time>"
50
+ end
51
+
52
+ file = page.destination page.site.config['destination']
53
+ File.open(file, 'w') { |f| f.write content }
54
+ end
55
+
56
+ end
57
+ end
data/test/css/main.css ADDED
@@ -0,0 +1,160 @@
1
+ /*****************************************************************************/
2
+ /*
3
+ /* Common
4
+ /*
5
+ /*****************************************************************************/
6
+
7
+ /* Global Reset */
8
+ * {
9
+ margin: 0;
10
+ padding: 0;
11
+ }
12
+
13
+ html, body { height: 100%; }
14
+
15
+ body {
16
+ background-color: #FFF;
17
+ font: 13.34px Helvetica, Arial, sans-serif;
18
+ font-size: small;
19
+ text-align: center;
20
+ }
21
+
22
+ h1, h2, h3, h4, h5, h6 {
23
+ font-size: 100%; }
24
+
25
+ h1 { margin-bottom: 1em; }
26
+ p { margin: 1em 0; }
27
+
28
+ a { color: #00a; }
29
+ a:hover { color: #000; }
30
+ a:visited { color: #a0a; }
31
+
32
+ /*****************************************************************************/
33
+ /*
34
+ /* Home
35
+ /*
36
+ /*****************************************************************************/
37
+ ul.posts {
38
+ list-style-type: none;
39
+ margin-bottom: 2em;
40
+ }
41
+
42
+ ul.posts li {
43
+ line-height: 1.75em;
44
+ }
45
+
46
+ ul.posts span {
47
+ color: #aaa;
48
+ font-family: Monaco, "Courier New", monospace;
49
+ font-size: 80%;
50
+ }
51
+
52
+ /*****************************************************************************/
53
+ /*
54
+ /* Site
55
+ /*
56
+ /*****************************************************************************/
57
+
58
+ .site {
59
+ font-size: 115%;
60
+ text-align: justify;
61
+ width: 42em;
62
+ margin: 3em auto 2em;
63
+ line-height: 1.5em;
64
+ }
65
+
66
+ .site .header a {
67
+ font-weight: bold;
68
+ text-decoration: none;
69
+ }
70
+
71
+ .site .header h1.title {
72
+ display: inline-block;
73
+ margin-bottom: 2em;
74
+ }
75
+
76
+ .site .header h1.title a {
77
+ color: #a00;
78
+ }
79
+
80
+ .site .header h1.title a:hover {
81
+ color: #000;
82
+ }
83
+
84
+ .site .header a.extra {
85
+ color: #aaa;
86
+ margin-left: 1em;
87
+ }
88
+
89
+ .site .header a.extra:hover {
90
+ color: #000;
91
+ }
92
+
93
+ .site .meta {
94
+ color: #aaa;
95
+ }
96
+
97
+ .site .footer {
98
+ font-size: 80%;
99
+ color: #666;
100
+ border-top: 4px solid #eee;
101
+ margin-top: 2em;
102
+ overflow: hidden;
103
+ }
104
+
105
+ .site .footer .contact {
106
+ float: left;
107
+ margin-right: 3em;
108
+ }
109
+
110
+ .site .footer .contact a {
111
+ color: #8085C1;
112
+ }
113
+
114
+ .site .footer .rss {
115
+ margin-top: 1.1em;
116
+ margin-right: -.2em;
117
+ float: right;
118
+ }
119
+
120
+ .site .footer .rss img {
121
+ border: 0;
122
+ }
123
+
124
+ /*****************************************************************************/
125
+ /*
126
+ /* Posts
127
+ /*
128
+ /*****************************************************************************/
129
+
130
+ /* standard */
131
+ .post pre {
132
+ border: 1px solid #ddd;
133
+ background-color: #eef;
134
+ padding: 0 .4em;
135
+ }
136
+
137
+ .post ul, .post ol {
138
+ margin-left: 1.35em;
139
+ }
140
+
141
+ .post code {
142
+ border: 1px solid #ddd;
143
+ background-color: #eef;
144
+ padding: 0 .2em;
145
+ }
146
+
147
+ .post pre code {
148
+ border: none;
149
+ }
150
+
151
+ /* terminal */
152
+ .post pre.terminal {
153
+ border: 1px solid #000;
154
+ background-color: #333;
155
+ color: #FFF;
156
+ }
157
+
158
+ .post pre.terminal code {
159
+ background-color: #333;
160
+ }
@@ -0,0 +1,60 @@
1
+ .highlight { background: #ffffff; }
2
+ .highlight .c { color: #999988; font-style: italic } /* Comment */
3
+ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
4
+ .highlight .k { font-weight: bold } /* Keyword */
5
+ .highlight .o { font-weight: bold } /* Operator */
6
+ .highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */
7
+ .highlight .cp { color: #999999; font-weight: bold } /* Comment.Preproc */
8
+ .highlight .c1 { color: #999988; font-style: italic } /* Comment.Single */
9
+ .highlight .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */
10
+ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
11
+ .highlight .gd .x { color: #000000; background-color: #ffaaaa } /* Generic.Deleted.Specific */
12
+ .highlight .ge { font-style: italic } /* Generic.Emph */
13
+ .highlight .gr { color: #aa0000 } /* Generic.Error */
14
+ .highlight .gh { color: #999999 } /* Generic.Heading */
15
+ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
16
+ .highlight .gi .x { color: #000000; background-color: #aaffaa } /* Generic.Inserted.Specific */
17
+ .highlight .go { color: #888888 } /* Generic.Output */
18
+ .highlight .gp { color: #555555 } /* Generic.Prompt */
19
+ .highlight .gs { font-weight: bold } /* Generic.Strong */
20
+ .highlight .gu { color: #aaaaaa } /* Generic.Subheading */
21
+ .highlight .gt { color: #aa0000 } /* Generic.Traceback */
22
+ .highlight .kc { font-weight: bold } /* Keyword.Constant */
23
+ .highlight .kd { font-weight: bold } /* Keyword.Declaration */
24
+ .highlight .kp { font-weight: bold } /* Keyword.Pseudo */
25
+ .highlight .kr { font-weight: bold } /* Keyword.Reserved */
26
+ .highlight .kt { color: #445588; font-weight: bold } /* Keyword.Type */
27
+ .highlight .m { color: #009999 } /* Literal.Number */
28
+ .highlight .s { color: #d14 } /* Literal.String */
29
+ .highlight .na { color: #008080 } /* Name.Attribute */
30
+ .highlight .nb { color: #0086B3 } /* Name.Builtin */
31
+ .highlight .nc { color: #445588; font-weight: bold } /* Name.Class */
32
+ .highlight .no { color: #008080 } /* Name.Constant */
33
+ .highlight .ni { color: #800080 } /* Name.Entity */
34
+ .highlight .ne { color: #990000; font-weight: bold } /* Name.Exception */
35
+ .highlight .nf { color: #990000; font-weight: bold } /* Name.Function */
36
+ .highlight .nn { color: #555555 } /* Name.Namespace */
37
+ .highlight .nt { color: #000080 } /* Name.Tag */
38
+ .highlight .nv { color: #008080 } /* Name.Variable */
39
+ .highlight .ow { font-weight: bold } /* Operator.Word */
40
+ .highlight .w { color: #bbbbbb } /* Text.Whitespace */
41
+ .highlight .mf { color: #009999 } /* Literal.Number.Float */
42
+ .highlight .mh { color: #009999 } /* Literal.Number.Hex */
43
+ .highlight .mi { color: #009999 } /* Literal.Number.Integer */
44
+ .highlight .mo { color: #009999 } /* Literal.Number.Oct */
45
+ .highlight .sb { color: #d14 } /* Literal.String.Backtick */
46
+ .highlight .sc { color: #d14 } /* Literal.String.Char */
47
+ .highlight .sd { color: #d14 } /* Literal.String.Doc */
48
+ .highlight .s2 { color: #d14 } /* Literal.String.Double */
49
+ .highlight .se { color: #d14 } /* Literal.String.Escape */
50
+ .highlight .sh { color: #d14 } /* Literal.String.Heredoc */
51
+ .highlight .si { color: #d14 } /* Literal.String.Interpol */
52
+ .highlight .sx { color: #d14 } /* Literal.String.Other */
53
+ .highlight .sr { color: #009926 } /* Literal.String.Regex */
54
+ .highlight .s1 { color: #d14 } /* Literal.String.Single */
55
+ .highlight .ss { color: #990073 } /* Literal.String.Symbol */
56
+ .highlight .bp { color: #999999 } /* Name.Builtin.Pseudo */
57
+ .highlight .vc { color: #008080 } /* Name.Variable.Class */
58
+ .highlight .vg { color: #008080 } /* Name.Variable.Global */
59
+ .highlight .vi { color: #008080 } /* Name.Variable.Instance */
60
+ .highlight .il { color: #009999 } /* Literal.Number.Integer.Long */
data/test/index.md ADDED
@@ -0,0 +1,18 @@
1
+ ---
2
+ layout: default
3
+ title: Your New Jekyll Site
4
+ ---
5
+
6
+ ## Prefilter cupcake test
7
+
8
+ Snatch this *cupcake* from my hand.
9
+
10
+ If successfull the paragraph above will have zero cupcakes in it.
11
+
12
+ ## PostFilter blink test
13
+
14
+ `<strong>` is for the weak. The age of `<blink><strong>` is **upon us**.
15
+
16
+ ## Post write test
17
+
18
+ This page was written to disk at ::time::.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-page-hooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-11 00:00:00.000000000 Z
12
+ date: 2013-08-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jekyll
@@ -36,6 +36,7 @@ extensions: []
36
36
  extra_rdoc_files: []
37
37
  files:
38
38
  - .gitignore
39
+ - CHANGELOG.md
39
40
  - Gemfile
40
41
  - LICENSE.txt
41
42
  - README.md
@@ -43,6 +44,15 @@ files:
43
44
  - jekyll-page-hooks.gemspec
44
45
  - lib/jekyll-page-hooks.rb
45
46
  - lib/jekyll-page-hooks/version.rb
47
+ - test/.gitignore
48
+ - test/Gemfile
49
+ - test/_config.yml
50
+ - test/_layouts/default.html
51
+ - test/_layouts/post.html
52
+ - test/_plugins/test.rb
53
+ - test/css/main.css
54
+ - test/css/syntax.css
55
+ - test/index.md
46
56
  homepage: http://github.com/octopress/jekyll-page-hooks
47
57
  licenses:
48
58
  - MIT