runecms 0.0.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 +7 -0
- data/README.lt3 +68 -0
- data/README.md +72 -0
- data/bin/rcms +16 -0
- data/examples/ex1/config.txt +3 -0
- data/examples/ex1/source/file2.html +3 -0
- data/examples/ex1/source/file3.lt3 +7 -0
- data/examples/ex1/source/index.lt3 +5 -0
- data/lib/runecms/commands.rb +73 -0
- data/lib/runecms/support.rb +100 -0
- data/lib/runecms/version.rb +3 -0
- data/lib/runecms.rb +3 -0
- data/runecms.gemspec +40 -0
- metadata +55 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 0b1cf72aae9cef64f3ee6b67563d364b64dc642ac9f78e4e16c5c7de052de2d1
|
|
4
|
+
data.tar.gz: 119e1a1fc184a131037ea83fc17b2ebbc4bf3808391932209b6da1f48ca64054
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: adbcaa106ba6f15871a0a5f7ba46acbac83c4fd2dea6687cb1090faa3c45e6a41c770cb65ed4ebf50555615830d6b40cdbbee0076a087f875da3bb091d08ed77
|
|
7
|
+
data.tar.gz: 6e65de46de4debb221845983380ecb98408b3ddb5db1a8bbe57c9845b7c4f2ab91e5bbeebf52a4266bbe203a507cdb72c2f680368edfb2bf89710f72604eb261
|
data/README.lt3
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
RuneCMS is intended to be a simple, lightweight tool for building
|
|
2
|
+
and deploying static websites.
|
|
3
|
+
|
|
4
|
+
It's based on Livetext, but could be generalized to be agnostic of
|
|
5
|
+
that tool. It is abstracted from a portion of RuneBlog.
|
|
6
|
+
|
|
7
|
+
In its present form, the `rcms` command simply takes a parameter.
|
|
8
|
+
These are:
|
|
9
|
+
|
|
10
|
+
.xtable
|
|
11
|
+
`[rcms config] :: Initialize `config.txt if necessary and edit with `vi
|
|
12
|
+
|
|
13
|
+
`[rcms generate] :: Find stale files under `source/ and generate them under `target/
|
|
14
|
+
|
|
15
|
+
`[rcms view] :: View the current state of `target/ via browser (local files)
|
|
16
|
+
|
|
17
|
+
`[rcms publish] :: Publish `target/ to the remote server
|
|
18
|
+
|
|
19
|
+
`[rcms browse] :: Browse the current state of the remote server
|
|
20
|
+
.end
|
|
21
|
+
|
|
22
|
+
At present, there is no check for these to be done in order. For example,
|
|
23
|
+
you could publish without a generate (analogous to editing a C program
|
|
24
|
+
and running the executable without recompiling it).
|
|
25
|
+
|
|
26
|
+
The assumption is made that keys for the user and server are already
|
|
27
|
+
set up. The `config.txt file looks like:
|
|
28
|
+
|
|
29
|
+
<pre>
|
|
30
|
+
server: foo.com
|
|
31
|
+
path: /var/www/foo
|
|
32
|
+
user: hal9000
|
|
33
|
+
</pre>
|
|
34
|
+
|
|
35
|
+
<hr>
|
|
36
|
+
|
|
37
|
+
<pre>
|
|
38
|
+
Idea: Website is stored in a directory tree. Use Livetext (etc.?) to create target files
|
|
39
|
+
and rsync to upload.
|
|
40
|
+
|
|
41
|
+
Config will comprise:
|
|
42
|
+
- server
|
|
43
|
+
- user
|
|
44
|
+
- root/path
|
|
45
|
+
|
|
46
|
+
Dir structure:
|
|
47
|
+
|
|
48
|
+
site
|
|
49
|
+
|
|
|
50
|
+
+---- config.lt3
|
|
51
|
+
+---- source/...
|
|
52
|
+
+---- target/...
|
|
53
|
+
|
|
54
|
+
Logic flow:
|
|
55
|
+
1. Edit file(s) under source/ tree
|
|
56
|
+
2. Generate
|
|
57
|
+
- reads config
|
|
58
|
+
- finds modified files under source/
|
|
59
|
+
- runs livetext on each
|
|
60
|
+
- results go under target/
|
|
61
|
+
3. View target/ locally to verify
|
|
62
|
+
4. Publish via rsync
|
|
63
|
+
# cmd = "rsync -r -z #{target}/ #@user@#@server:#{path}/"
|
|
64
|
+
|
|
65
|
+
</pre>
|
|
66
|
+
|
|
67
|
+
More details later...
|
|
68
|
+
|
data/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
RuneCMS is intended to be a simple, lightweight tool for building
|
|
2
|
+
and deploying static websites.
|
|
3
|
+
It's based on Livetext, but could be generalized to be agnostic of
|
|
4
|
+
that tool. It is abstracted from a portion of RuneBlog.
|
|
5
|
+
In its present form, the <t>rcms`</t> command simply takes a parameter.
|
|
6
|
+
These are:
|
|
7
|
+
<br><center><table width=90% cellpadding=5>
|
|
8
|
+
<tr>
|
|
9
|
+
<td valign=top><t>rcms config</t></td>
|
|
10
|
+
<td valign=top>Initialize <t>config.txt</t> if necessary and edit with <t>vi</t></td>
|
|
11
|
+
</tr>
|
|
12
|
+
<tr>
|
|
13
|
+
</tr>
|
|
14
|
+
<tr>
|
|
15
|
+
<td valign=top><t>rcms generate</t></td>
|
|
16
|
+
<td valign=top>Find stale files under <t>source/</t> and generate them under <t>target/</t></td>
|
|
17
|
+
</tr>
|
|
18
|
+
<tr>
|
|
19
|
+
</tr>
|
|
20
|
+
<tr>
|
|
21
|
+
<td valign=top><t>rcms view</t></td>
|
|
22
|
+
<td valign=top>View the current state of <t>target/</t> via browser (local files)</td>
|
|
23
|
+
</tr>
|
|
24
|
+
<tr>
|
|
25
|
+
</tr>
|
|
26
|
+
<tr>
|
|
27
|
+
<td valign=top><t>rcms publish</t></td>
|
|
28
|
+
<td valign=top>Publish <t>target/</t> to the remote server</td>
|
|
29
|
+
</tr>
|
|
30
|
+
<tr>
|
|
31
|
+
</tr>
|
|
32
|
+
<tr>
|
|
33
|
+
<td valign=top><t>rcms browse</t></td>
|
|
34
|
+
<td valign=top>Browse the current state of the remote server</td>
|
|
35
|
+
</tr>
|
|
36
|
+
</table></center>
|
|
37
|
+
At present, there is no check for these to be done in order. For example,
|
|
38
|
+
you could publish without a generate (analogous to editing a C program
|
|
39
|
+
and running the executable without recompiling it).
|
|
40
|
+
The assumption is made that keys for the user and server are already
|
|
41
|
+
set up. The <t>config.txt</t> file looks like:
|
|
42
|
+
<pre>
|
|
43
|
+
server: foo.com
|
|
44
|
+
path: /var/www/foo
|
|
45
|
+
user: hal9000
|
|
46
|
+
</pre>
|
|
47
|
+
<hr>
|
|
48
|
+
<pre>
|
|
49
|
+
Idea: Website is stored in a directory tree. Use Livetext (etc.?) to create target files
|
|
50
|
+
and rsync to upload.
|
|
51
|
+
Config will comprise:
|
|
52
|
+
- server
|
|
53
|
+
- user
|
|
54
|
+
- root/path
|
|
55
|
+
Dir structure:
|
|
56
|
+
site
|
|
57
|
+
|
|
|
58
|
+
+---- config.lt3
|
|
59
|
+
+---- source/...
|
|
60
|
+
+---- target/...
|
|
61
|
+
Logic flow:
|
|
62
|
+
1. Edit file(s) under source/ tree
|
|
63
|
+
2. Generate
|
|
64
|
+
- reads config
|
|
65
|
+
- finds modified files under source/
|
|
66
|
+
- runs livetext on each
|
|
67
|
+
- results go under target/
|
|
68
|
+
3. View target/ locally to verify
|
|
69
|
+
4. Publish via rsync
|
|
70
|
+
# cmd = "rsync -r -z #{target}/ #@user@#@server:#{path}/"
|
|
71
|
+
</pre>
|
|
72
|
+
More details later...
|
data/bin/rcms
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
|
|
2
|
+
require 'find'
|
|
3
|
+
|
|
4
|
+
CONFIG = "config.txt"
|
|
5
|
+
|
|
6
|
+
def run_version
|
|
7
|
+
puts RuneCMS::VERSION
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def run_check
|
|
11
|
+
list = stale_files("source")
|
|
12
|
+
if stale.empty?
|
|
13
|
+
puts "No stale files"
|
|
14
|
+
else
|
|
15
|
+
puts "Stale files:"
|
|
16
|
+
stale.each {|x| puts " " + x }
|
|
17
|
+
puts
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def run_config
|
|
22
|
+
unless read_config
|
|
23
|
+
File.open("config.txt", "w") do |f|
|
|
24
|
+
f.puts "server: "
|
|
25
|
+
f.puts "path: "
|
|
26
|
+
f.puts "user: "
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
system("vi config.txt")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def run_generate
|
|
33
|
+
verify_dirs # handle missing subdirectories
|
|
34
|
+
list = stale_files("source")
|
|
35
|
+
if stale.empty?
|
|
36
|
+
puts "Nothing to do"
|
|
37
|
+
else
|
|
38
|
+
puts "Stale files:"
|
|
39
|
+
stale.each do |file|
|
|
40
|
+
puts " " + x
|
|
41
|
+
update_target(file)
|
|
42
|
+
end
|
|
43
|
+
puts
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def run_update
|
|
48
|
+
run_generate
|
|
49
|
+
run_publish
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def run_view
|
|
53
|
+
# FIXME index is hardcoded...
|
|
54
|
+
system("open target/index.html")
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def run_publish
|
|
58
|
+
cmd = "rsync -r -z target/ #@user@#@server:#@path/"
|
|
59
|
+
system(cmd)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def run_browse
|
|
63
|
+
system("open #@server")
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def command?(cmd)
|
|
67
|
+
self.respond_to?("run_#{cmd}", true)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def execute(cmd)
|
|
71
|
+
send("run_#{cmd}")
|
|
72
|
+
end
|
|
73
|
+
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
|
|
2
|
+
def usage_message
|
|
3
|
+
puts
|
|
4
|
+
puts <<-TEXT
|
|
5
|
+
rcms config Initialize config.txt if necessary and edit with vi
|
|
6
|
+
rcms check List stale files, but do nothing else
|
|
7
|
+
rcms generate Find stale files under source/ and generate them under target/
|
|
8
|
+
rcms view View the current state of target/ via browser (local files)
|
|
9
|
+
rcms publish Publish target/ to the remote server
|
|
10
|
+
rcms update Shortcut - Like a generate followed by a push
|
|
11
|
+
rcms browse Browse the current state of the remote server
|
|
12
|
+
TEXT
|
|
13
|
+
puts
|
|
14
|
+
exit
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def stale_files(dir)
|
|
18
|
+
list = nil
|
|
19
|
+
path = "#{Dir.pwd}/#{dir}/"
|
|
20
|
+
list = Find.find(path).to_a
|
|
21
|
+
list = list.select {|x| ! File.directory?(x) }
|
|
22
|
+
list.map! {|x| x.sub(path, "") }
|
|
23
|
+
list.select {|x| stale?(x) }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def stale?(file) # without source/ or target/
|
|
27
|
+
return false if File.directory?(file)
|
|
28
|
+
if file.end_with?(".lt3")
|
|
29
|
+
file1 = file
|
|
30
|
+
file2 = file.sub(/.lt3$/, ".html")
|
|
31
|
+
else
|
|
32
|
+
file1 = file2 = file
|
|
33
|
+
end
|
|
34
|
+
return true if ! File.exist?("target/#{file2}")
|
|
35
|
+
|
|
36
|
+
t1 = File.mtime("source/#{file1}")
|
|
37
|
+
t2 = File.mtime("target/#{file2}")
|
|
38
|
+
t1 > t2
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def update_target(file)
|
|
42
|
+
file2 = fix_extension(file)
|
|
43
|
+
if lt3?(file)
|
|
44
|
+
cmd = "livetext source/#{file} > target/#{file2}"
|
|
45
|
+
else
|
|
46
|
+
if File.directory?(file)
|
|
47
|
+
cmd = "mkdir target/#{file2}"
|
|
48
|
+
else
|
|
49
|
+
cmd = "cp source/#{file} target/#{file2}"
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
system(cmd)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def verify_dirs
|
|
56
|
+
src_dirs = []
|
|
57
|
+
Find.find("source") do |path|
|
|
58
|
+
src_dirs << path if File.directory?(path)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
src_dirs.each do |path|
|
|
62
|
+
tdir = path.sub("source", "target")
|
|
63
|
+
Dir.mkdir(tdir) unless Dir.exist?(tdir)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def lt3?(file)
|
|
68
|
+
file.end_with?(".lt3")
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def fix_extension(file)
|
|
72
|
+
if lt3?(file)
|
|
73
|
+
file2 = file.sub(/.lt3$/, ".html")
|
|
74
|
+
else
|
|
75
|
+
file2 = file
|
|
76
|
+
end
|
|
77
|
+
file2
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def read_config
|
|
81
|
+
config = "config.txt"
|
|
82
|
+
here = Dir.pwd
|
|
83
|
+
loop do
|
|
84
|
+
raise if Dir.pwd == "/" # shouldn't get this far
|
|
85
|
+
break if File.exist?(config)
|
|
86
|
+
Dir.chdir("..")
|
|
87
|
+
end
|
|
88
|
+
lines = File.readlines("config.txt")
|
|
89
|
+
# Example: "user: hal9000"
|
|
90
|
+
lines.each do |line|
|
|
91
|
+
var, val = line.split(": ")
|
|
92
|
+
instance_variable_set("@" + var, val.chomp.strip)
|
|
93
|
+
end
|
|
94
|
+
return true
|
|
95
|
+
rescue => e
|
|
96
|
+
puts "Can't read config file: here = #{here} pwd = #{Dir.pwd}"
|
|
97
|
+
puts e
|
|
98
|
+
return false
|
|
99
|
+
end
|
|
100
|
+
|
data/lib/runecms.rb
ADDED
data/runecms.gemspec
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require 'date'
|
|
2
|
+
require 'find'
|
|
3
|
+
|
|
4
|
+
require_relative "lib/runecms"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |s|
|
|
7
|
+
def s.file_trees(*dirs)
|
|
8
|
+
list = []
|
|
9
|
+
dirs.each do |dir|
|
|
10
|
+
puts "dir = #{dir}"
|
|
11
|
+
stuff = Find.find(dir).to_a
|
|
12
|
+
puts " #{stuff.inspect}"
|
|
13
|
+
list += stuff
|
|
14
|
+
end
|
|
15
|
+
list
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# ^ save this somewhere
|
|
19
|
+
# Also: bump version, new gem, ...
|
|
20
|
+
# Maybe base entire thing on livetext?? Meaning a
|
|
21
|
+
# single .lt3 file to specify the entire project??
|
|
22
|
+
|
|
23
|
+
system("rm -f *.gem")
|
|
24
|
+
s.name = 'runecms'
|
|
25
|
+
s.version = RuneCMS::VERSION
|
|
26
|
+
s.date = Date.today.strftime("%Y-%m-%d")
|
|
27
|
+
s.summary = "Simple static website manager"
|
|
28
|
+
s.description = "A simple static website manager based on Livetext (and Ruby)"
|
|
29
|
+
s.authors = ["Hal Fulton"]
|
|
30
|
+
s.email = 'rubyhacker@gmail.com'
|
|
31
|
+
s.executables << "rcms"
|
|
32
|
+
|
|
33
|
+
# Files...
|
|
34
|
+
main = s.file_trees("bin", "lib", "examples", "test")
|
|
35
|
+
misc = %w[./README.lt3 ./README.md runecms.gemspec]
|
|
36
|
+
|
|
37
|
+
s.files = main + misc
|
|
38
|
+
s.homepage = 'https://github.com/Hal9000/runecms'
|
|
39
|
+
s.license = "Ruby"
|
|
40
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: runecms
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.3
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Hal Fulton
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2022-07-02 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: A simple static website manager based on Livetext (and Ruby)
|
|
14
|
+
email: rubyhacker@gmail.com
|
|
15
|
+
executables:
|
|
16
|
+
- rcms
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- "./README.lt3"
|
|
21
|
+
- "./README.md"
|
|
22
|
+
- bin/rcms
|
|
23
|
+
- examples/ex1/config.txt
|
|
24
|
+
- examples/ex1/source/file2.html
|
|
25
|
+
- examples/ex1/source/file3.lt3
|
|
26
|
+
- examples/ex1/source/index.lt3
|
|
27
|
+
- lib/runecms.rb
|
|
28
|
+
- lib/runecms/commands.rb
|
|
29
|
+
- lib/runecms/support.rb
|
|
30
|
+
- lib/runecms/version.rb
|
|
31
|
+
- runecms.gemspec
|
|
32
|
+
homepage: https://github.com/Hal9000/runecms
|
|
33
|
+
licenses:
|
|
34
|
+
- Ruby
|
|
35
|
+
metadata: {}
|
|
36
|
+
post_install_message:
|
|
37
|
+
rdoc_options: []
|
|
38
|
+
require_paths:
|
|
39
|
+
- lib
|
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
41
|
+
requirements:
|
|
42
|
+
- - ">="
|
|
43
|
+
- !ruby/object:Gem::Version
|
|
44
|
+
version: '0'
|
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
46
|
+
requirements:
|
|
47
|
+
- - ">="
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: '0'
|
|
50
|
+
requirements: []
|
|
51
|
+
rubygems_version: 3.1.2
|
|
52
|
+
signing_key:
|
|
53
|
+
specification_version: 4
|
|
54
|
+
summary: Simple static website manager
|
|
55
|
+
test_files: []
|