Skip to content

Commit 0aa67b4

Browse files
committed
preliminary conformance with node-wordpress
1 parent be500ee commit 0aa67b4

File tree

7 files changed

+89
-13
lines changed

7 files changed

+89
-13
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
output/
2+
page
3+
vendor
24
tmp/*
35
tmp
46
order.json

Rules

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class Nanoc3::Filter
5858
@output << %{<div class="example">\n}
5959
@output << %{<div class="filename">#{filename}</div>\n} if filename
6060
@output << %{<div class="caption">#{caption}</div>\n} if caption
61-
@output << %{<pre class="brush: #{replace}; gutter: false; toolbar: false"><code>} <<
61+
@output << %{<pre><code data-lang="#{replace}">} <<
6262
CGI.escapeHTML(match.pre_match) << %{</code></pre>}
6363
@output << %{</div>\n}
6464
end
@@ -75,7 +75,8 @@ class Nanoc3::Item
7575
{
7676
'title' => self[:title] || self.identifier,
7777
'chapter' => self[:chapter],
78-
'isCategory' => self[:filename].index('dex.md') != nil
78+
'menu_order' => self[:ordinal_index]
79+
# 'isCategory' => self[:filename].index('dex.md') != nil
7980
}.to_json(*a)
8081
end
8182
end
@@ -118,8 +119,8 @@ preprocess do
118119
@chapter_order.each do |folder|
119120
@chapters [ folder] = {}
120121
@chapters[ folder ][ :items ] = @grouped_items[folder].sort_by {|i|
121-
p @chapter_articles[ i[ :chapter ] ].index( p i.identifier.split('/')[2] ) || 0
122-
@chapter_articles[ i[ :chapter ] ].index( p i.identifier.split('/')[2] ) || 0
122+
# p @chapter_articles[ i[ :chapter ] ].index( i.identifier.split('/')[2] ) || 0
123+
@chapter_articles[ i[ :chapter ] ].index( i.identifier.split('/')[2] ) || 0
123124
}
124125
@ordered_items = @ordered_items + @chapters[ folder ][ :items ]
125126
@chapters[ folder ][ :title ] = folder.gsub(/-/, " ").upcase
@@ -131,7 +132,7 @@ preprocess do
131132
item[:next_item] = @ordered_items[ i+1 ]
132133
item[:previous_item] = @ordered_items[ i-1 ]
133134
end
134-
item[:github_user] = @github_users[ item[:github] ]
135+
item[:github_user] = @github_users[ item[:github] ]#
135136
end
136137

137138
@site.config[:chapters] = @chapters
@@ -152,7 +153,7 @@ filters = {
152153

153154
# Index files in each content directory
154155
route "/*/dex" do
155-
item.identifier.sub("dex/", "") + 'index.html'
156+
"/" + item.identifier.split('/')[1] + ".html"
156157
end
157158

158159
# Just the homepage
@@ -163,9 +164,7 @@ end
163164
compile '*' do
164165
filter :code_blocks
165166
filter filters[item[:extension].to_sym] || item[:extension].to_sym
166-
if item[:homepage]
167-
layout 'home'
168-
elsif item.identifier.match /\/dex\/$/
167+
if item.identifier.match /\/dex\/$/
169168
layout 'wp_dex'
170169
else
171170
layout 'wp_stub'
@@ -181,7 +180,8 @@ route '*' do
181180
item.identifier.chop + '.' + item[:extension]
182181
else
183182
# /foo/ -> /foo/index.html
184-
item.identifier + 'index.html'
183+
184+
item.identifier.chop + '.html'
185185
end
186186
end
187187

config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ text_extensions: [ 'css', 'erb', 'haml', 'htm', 'html', 'js', 'less', 'markdown'
66
# The path to the directory where all generated files will be written to. This
77
# can be an absolute path starting with a slash, but it can also be path
88
# relative to the site directory.
9-
output_dir: output
9+
output_dir: page
1010

1111
# A list of index filenames, i.e. names of files that will be served by a web
1212
# server when a directory is requested. Usually, index files are named

grunt.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
module.exports = function( grunt ) {
2+
3+
grunt.loadNpmTasks( "grunt-clean" );
4+
grunt.loadNpmTasks( "grunt-html" );
5+
grunt.loadNpmTasks( "grunt-wordpress" );
6+
grunt.loadNpmTasks( "grunt-jquery-content" );
7+
8+
grunt.initConfig({
9+
clean: {
10+
folder: "dist/"
11+
},
12+
htmllint: {
13+
resources: "resources/*.html"
14+
},
15+
jshint: {
16+
options: {
17+
undef: true,
18+
node: true
19+
}
20+
},
21+
lint: {
22+
grunt: "grunt.js"
23+
},
24+
watch: {
25+
pages: {
26+
files: "page/**/*.html",
27+
tasks: "deploy"
28+
}
29+
},
30+
"build-pages": {
31+
all: grunt.file.expandFiles( "page/**/*.html" )
32+
},
33+
"build-resources": {
34+
all: grunt.file.expandFiles( "resources/**/*" )
35+
},
36+
wordpress: grunt.utils._.extend({
37+
dir: "dist/wordpress"
38+
}, grunt.file.readJSON( "config.json" ) )
39+
});
40+
41+
grunt.registerTask( "default", "lint" );
42+
grunt.registerTask( "build-wordpress", "clean lint build-pages build-resources");
43+
grunt.registerTask( "deploy", "wordpress-deploy" );
44+
45+
};

layouts/nanoc_meta.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<script id="nanoc_meta" type="nanoc/meta"><%= @item.to_json %></script>
1+
<script><%= @item.to_json %></script>

layouts/wp_dex.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<%= render 'nanoc_meta' %>
22
<!--raw-->
33
<%= yield %>
4-
<%= render 'chapter_contents' %>
54
<!--/raw-->

package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "learn.jquery.com",
3+
"title": "jQuery Learning Site",
4+
"description": "jQuery Foundation site for learning jQuery and JavaScript",
5+
"version": "0.0.0",
6+
"homepage": "http://learn.jquery.com",
7+
"author": {
8+
"name": "jQuery Foundation (http://jquery.org/)"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "git://github.com/jquery/learn.jquery.com.git"
13+
},
14+
"bugs": {
15+
"url": "https://github.com/jquery/learn.jquery.com/issues"
16+
},
17+
"licenses": [
18+
{
19+
"type": "MIT",
20+
"url": "http://www.opensource.org/licenses/MIT"
21+
}
22+
],
23+
"dependencies": {
24+
"grunt": "0.3.x",
25+
"grunt-clean": "0.3.0",
26+
"grunt-html": "0.1.1",
27+
"grunt-wordpress": "1.0.0",
28+
"grunt-jquery-content": "0.2.2"
29+
}
30+
}

0 commit comments

Comments
 (0)