jing 0.1.2 → 0.1.3
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 +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -2
- data/examples/README.md +5 -0
- data/examples/simplepage/.meta.yml +4 -0
- data/examples/simplepage/_layouts/main.html.erb +11 -0
- data/examples/simplepage/_partials/some_partial.html.erb +1 -0
- data/examples/simplepage/another.html.erb +11 -0
- data/examples/simplepage/images/lenna.jpg +0 -0
- data/examples/simplepage/index.html.md.erb +12 -0
- data/lib/jing.rb +21 -14
- data/lib/jing/version.rb +1 -1
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0109a16bd2e74f10edbe5aa725d5e8b63ff68e1ba1c5b5668641f351a2f172f
|
4
|
+
data.tar.gz: f5c8d6cf786cfc9032d3f06c1a8c4361e7a612a3b8927c11b1e45256981ce3dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2bb4d26c9d2371c680f347e1ffec482c83a2179a750063a252791ffb70c0440027991f398ca40d6cd65a4b1e0c9e5097a9a67fdb244b99ca1f0bb9f8528c104
|
7
|
+
data.tar.gz: 23ed2e92a0df6b52bd94c0c48a81ba5364125a4e1e0380e2c47cff09f929f11e0837cc21c6a306f47680c991ecf936657f68f5dc167a30dd31f59d663d010242
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -47,6 +47,8 @@ Serves the current project folder on `http://0.0.0.0:8000`:
|
|
47
47
|
|
48
48
|
$ jing serve
|
49
49
|
|
50
|
+
File endings work like Russian dolls: They get converted from outer to inner. Rails folks should be somewhat familiar with that but here it's a bit stricter.
|
51
|
+
|
50
52
|
Folders starting with `_` have special meaning, they generally won't get copied into the destination folder `_dst`.
|
51
53
|
|
52
54
|
`_partials` holds partials (TODO: explanation)
|
@@ -55,8 +57,7 @@ Folders starting with `_` have special meaning, they generally won't get copied
|
|
55
57
|
|
56
58
|
`.meta.yml` holds global meta variables available in templates when not overwritten
|
57
59
|
|
58
|
-
I'll try and add a basic example project soon. If you feel like
|
59
|
-
|
60
|
+
~~I'll try and add a basic example project soon.~~ Check out the examples folder. If you feel like giving this a try and have questions feel free to open an issue or reach out otherwise. Pull requests welcome too.
|
60
61
|
|
61
62
|
## Development
|
62
63
|
|
data/examples/README.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
<!DOCTYPE HTML>
|
2
|
+
<html lang="en-US">
|
3
|
+
<head>
|
4
|
+
<title><%= meta[:name] %></title>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<%= body %>
|
10
|
+
</body>
|
11
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
<pre><%= meta[:message] || 'no message' %></pre>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
---
|
2
|
+
layout: main
|
3
|
+
some_var: 999
|
4
|
+
another_var: bottles of beer on the wall
|
5
|
+
---
|
6
|
+
|
7
|
+
<h1>not much to do here except .. </h1>
|
8
|
+
<p><%= meta[:some_var]%> ... <%= meta[:another_var] %> ... take one down ...</p>
|
9
|
+
<p>a little song teaser</p>
|
10
|
+
|
11
|
+
<a href="/index.html">back to index</a>
|
Binary file
|
data/lib/jing.rb
CHANGED
@@ -31,7 +31,7 @@ module Jing
|
|
31
31
|
}},
|
32
32
|
{extensions: %w[js], handler: ->(body, meta, ctx){
|
33
33
|
load_gem 'uglifier'
|
34
|
-
Uglifier.compile(body, harmony: true)
|
34
|
+
Uglifier.compile(body, harmony: true, output: {ascii_only: true})
|
35
35
|
}},
|
36
36
|
{extensions: %w[md markdown], handler: ->(body, meta, ctx){
|
37
37
|
load_gem 'kramdown'
|
@@ -79,7 +79,7 @@ module Jing
|
|
79
79
|
puts "Error\t#{file[@src.size+1..-1]}\n\t#{e.message}\n#{e.backtrace.map{|x| "\t#{x}"}.join("\n")}"
|
80
80
|
end
|
81
81
|
|
82
|
-
def build!
|
82
|
+
def build!(opts={})
|
83
83
|
t = Time.now
|
84
84
|
FileUtils.rm_r(@dst) if File.exist?(@dst)
|
85
85
|
Dir.mkdir(@dst)
|
@@ -95,24 +95,30 @@ module Jing
|
|
95
95
|
puts "#{'%.4fs' % (Time.now-t)} total"
|
96
96
|
end
|
97
97
|
|
98
|
-
def watch!
|
98
|
+
def watch!(opts={})
|
99
99
|
@converter_extensions.delete('js')
|
100
|
-
build!
|
100
|
+
build!(opts)
|
101
101
|
load_gem('filewatcher')
|
102
102
|
Filewatcher.new([@src, '**', '*']).watch do |filename, event|
|
103
|
-
|
104
|
-
|
103
|
+
unless File.expand_path(filename) == @dst
|
104
|
+
puts "WATCHED #{filename}\t#{event}"
|
105
|
+
build!(opts)
|
106
|
+
end
|
105
107
|
end
|
106
108
|
end
|
107
109
|
|
108
|
-
def serve!
|
109
|
-
WEBrick::HTTPServer.new(Port: 8000, DocumentRoot: @dst).start
|
110
|
+
def serve!(opts={})
|
111
|
+
WEBrick::HTTPServer.new(Port: opts[:port] || 8000, DocumentRoot: opts[:root] || @dst).start
|
110
112
|
end
|
111
113
|
|
112
|
-
def create!
|
113
|
-
abort("usage: #{File.basename($0)} create <
|
114
|
-
%w[_layouts _partials].each { |e| FileUtils.mkdir_p(File.join(
|
115
|
-
File.write(File.join(
|
114
|
+
def create!(opts={})
|
115
|
+
abort("usage: #{File.basename($0)} create -name <pathname>") unless opts[:name]
|
116
|
+
%w[_layouts _partials].each { |e| FileUtils.mkdir_p(File.join(opts[:name], e)) }
|
117
|
+
File.write(File.join(opts[:name], '.meta.yml'), "---\ngenerator: jing\nname: #{File.basename(opts[:name])}\n---\n")
|
118
|
+
end
|
119
|
+
|
120
|
+
def version!(opts={})
|
121
|
+
puts VERSION
|
116
122
|
end
|
117
123
|
end
|
118
124
|
|
@@ -120,7 +126,8 @@ module Jing
|
|
120
126
|
cmd = ARGV[0]
|
121
127
|
commands = Jing.instance_methods(false).grep(/!$/).map{|e| e[0..-2]}
|
122
128
|
abort("usage: #{File.basename($0)} <#{commands.join('|')}>") unless commands.include?(cmd)
|
123
|
-
|
124
|
-
jing.
|
129
|
+
opts = ARGV[1..-1].each_slice(2).reduce({}){|s,(k,v)| s[k.match(/^\-*(.*)$/)[1].to_sym] = v; s}
|
130
|
+
jing = Jing.new(opts)
|
131
|
+
jing.send(:"#{cmd}!", opts)
|
125
132
|
end
|
126
133
|
end
|
data/lib/jing/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pachacamac
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -57,6 +57,13 @@ files:
|
|
57
57
|
- bin/console
|
58
58
|
- bin/jing
|
59
59
|
- bin/setup
|
60
|
+
- examples/README.md
|
61
|
+
- examples/simplepage/.meta.yml
|
62
|
+
- examples/simplepage/_layouts/main.html.erb
|
63
|
+
- examples/simplepage/_partials/some_partial.html.erb
|
64
|
+
- examples/simplepage/another.html.erb
|
65
|
+
- examples/simplepage/images/lenna.jpg
|
66
|
+
- examples/simplepage/index.html.md.erb
|
60
67
|
- jing.gemspec
|
61
68
|
- lib/jing.rb
|
62
69
|
- lib/jing/version.rb
|