argon18 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/argon18 +10 -3
- data/lib/argon18.rb +44 -0
- data/lib/server/app.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7860f1a5f96ac95590a1eab34aa06abbbdf76f9c4b7527915c980e20e99361b4
|
4
|
+
data.tar.gz: 5c31eed89e738b7cd2e5346d42ebb3745724b8965933d8f60391d13ef104525d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea28a8f0971575d7d8c81ed80ecb402c17e429db727e16c02ad3386b982e372f8349cdd74ddf03688d46fe8e19c44656c1a20ccfbc80c697f6ed3dfbda169132
|
7
|
+
data.tar.gz: 4ced5e57fa3bb13194d061853ea94c97478f98a7043cf759d99e21f8909fe6c0459dfb6986228a4fbae7a81f34a8c894876b3ad0a7c5c0cbe5b14003c2710d15
|
data/bin/argon18
CHANGED
@@ -6,6 +6,8 @@ ARGV = []
|
|
6
6
|
|
7
7
|
require 'argon18'
|
8
8
|
|
9
|
+
flags = ["-h", "--help", "-E"]
|
10
|
+
|
9
11
|
if args.include? "-h" or args.include? "--help"
|
10
12
|
puts(
|
11
13
|
"
|
@@ -15,13 +17,18 @@ Start a web server in a given directory.
|
|
15
17
|
With no DIRECTORY the current working directory is used.
|
16
18
|
|
17
19
|
-h, --help display this message and exit
|
20
|
+
-E export the site to static html files (will be placed in project_root/output)
|
18
21
|
"
|
19
22
|
)
|
20
23
|
else
|
21
24
|
project_root = "."
|
22
|
-
if args[
|
23
|
-
project_root = args[
|
25
|
+
if args[-1] && !(flags.include? args[-1])
|
26
|
+
project_root = args[-1]
|
27
|
+
end
|
28
|
+
if args.include? "-E" or args.include? "--export"
|
29
|
+
Argon.gen_static_html project_root
|
30
|
+
else
|
31
|
+
Argon.run_app project_root
|
24
32
|
end
|
25
|
-
Argon.run_app project_root
|
26
33
|
end
|
27
34
|
|
data/lib/argon18.rb
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
require 'sinatra'
|
2
2
|
require 'slim'
|
3
3
|
require 'rack'
|
4
|
+
require 'fileutils'
|
4
5
|
|
5
6
|
require 'server/app.rb'
|
6
7
|
|
8
|
+
class SlimEnv
|
9
|
+
attr_accessor :name
|
10
|
+
end
|
11
|
+
|
7
12
|
class Argon
|
8
13
|
def self.run_app(project_root)
|
9
14
|
ENV['project_root'] = File.expand_path(project_root)
|
@@ -14,4 +19,43 @@ class Argon
|
|
14
19
|
Rack::Handler::WEBrick.run(ArgonApp, Port: 9292)
|
15
20
|
end
|
16
21
|
end
|
22
|
+
|
23
|
+
def self.gen_static_html(project_root)
|
24
|
+
ENV['project_root'] = File.expand_path(project_root)
|
25
|
+
ENV['views_path'] = "views"
|
26
|
+
ENV['public_path'] = "public"
|
27
|
+
ENV['output_path'] = ENV['project_root'] + "/" + "output/"
|
28
|
+
|
29
|
+
FileUtils.mkdir_p ENV['output_path']
|
30
|
+
|
31
|
+
Dir.chdir(ENV['project_root']) do
|
32
|
+
files = []
|
33
|
+
dir_stack = [ENV['views_path']]
|
34
|
+
p dir_stack
|
35
|
+
|
36
|
+
slim_env = SlimEnv.new
|
37
|
+
slim_env.name = "Argon18"
|
38
|
+
# Copy media
|
39
|
+
FileUtils.cp_r "#{ENV['public_path']}/.", ENV['output_path']
|
40
|
+
|
41
|
+
# Render slim files
|
42
|
+
while !dir_stack.empty?
|
43
|
+
curr_dir = (dir_stack.delete_at 0).split("views/")[-1]
|
44
|
+
FileUtils.mkdir_p (ENV['output_path'] + curr_dir)
|
45
|
+
Dir[curr_dir + "/*"].each { |d| dir_stack << d }
|
46
|
+
dir_stack.filter! { |f| File.directory? f }
|
47
|
+
|
48
|
+
files = Dir[curr_dir + "/*.slim"]
|
49
|
+
p files
|
50
|
+
files.each do |f|
|
51
|
+
content = File.read f
|
52
|
+
parsed = Slim::Template.new { content }.render(slim_env)
|
53
|
+
parsed = parsed.gsub(/href="\/"/, 'href="index.html"')
|
54
|
+
parsed = parsed.gsub(/href="([^".]+)"/, 'href="\1.html"')
|
55
|
+
base_name = f.split(".")[0].split("views/")[-1]
|
56
|
+
File.write ENV['output_path'] + base_name + ".html", parsed
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
17
61
|
end
|
data/lib/server/app.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: argon18
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Udén
|
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '0'
|
81
81
|
requirements: []
|
82
|
-
rubygems_version: 3.
|
82
|
+
rubygems_version: 3.1.2
|
83
83
|
signing_key:
|
84
84
|
specification_version: 4
|
85
85
|
summary: Argon 18 ⚛️
|