runecms 0.0.7

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ede0ce49bdbce41d4a5b21380d2917194d2c4cff1c102820f6d79a93f425121b
4
+ data.tar.gz: 43bb06d716a28baf22ad7e8eaec55ff0d584c55f2d1feb091201386af71006e9
5
+ SHA512:
6
+ metadata.gz: 8570f0907a13e4bed0d0568e9b688fb24985c094289d6e0c09bbe0300ab6ab4ec5a58f8e64ac4d270e769345e7af068f6fc09f6f28ee12b592368ac15514ca32
7
+ data.tar.gz: d7c612dad92069bb329a3d68772e3a588c708db2dc1f87a371d8f3509a1016f7d7276516c034ee2f3bd982fe5c98a618a92b1116808e274cc1a4b63081ac9d1c
data/README.lt3 ADDED
@@ -0,0 +1,32 @@
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
+ Your choices are:
9
+ .xtable
10
+ `[ rcms config] :: Initialize `config.txt if necessary and edit with `vi
11
+ `[ rcms generate] :: Find stale files under `source/ and generate them under `target/
12
+ `[ rcms view] :: View the current state of `target/ via browser (local files)
13
+ `[ rcms publish] :: Publish `target/ to the remote server
14
+ `[ rcms browse] :: Browse the current state of the remote server
15
+ .end
16
+
17
+ At present, there is no check for these to be done in order. For example,
18
+ you could publish without a generate (analogous to editing a C program
19
+ and running the executable without recompiling it).
20
+
21
+ The assumption is made that keys for the user and server are already
22
+ set up. The `config.txt file looks like:
23
+
24
+ <pre>
25
+ server: foo.com
26
+ path: /var/www/foo
27
+ user: hal9000
28
+ </pre>
29
+
30
+
31
+ More details later...
32
+
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ RuneCMS is intended to be a simple, lightweight tool for building
2
+ and deploying static websites.
3
+ <p>
4
+
5
+ It's based on Livetext, but could be generalized to be agnostic of
6
+ that tool. It is abstracted from a portion of RuneBlog.
7
+ <p>
8
+
9
+ In its present form, the <font size=+1><tt>rcms</tt></font> command simply takes a parameter.
10
+ Your choices are:
11
+ <br><center><table width=90% cellpadding=5>
12
+ <tr>
13
+ <td valign=top><font size=+1><tt>rcms config</tt></font> </td>
14
+ <td valign=top>Initialize <font size=+1><tt>config.txt</tt></font> if necessary and edit with <font size=+1><tt>vi</tt></font></td>
15
+ </tr>
16
+ <tr>
17
+ <td valign=top><font size=+1><tt>rcms generate</tt></font></td>
18
+ <td valign=top>Find stale files under <font size=+1><tt>source/</tt></font> and generate them under <font size=+1><tt>target/</tt></font></td>
19
+ </tr>
20
+ <tr>
21
+ <td valign=top><font size=+1><tt>rcms view</tt></font> </td>
22
+ <td valign=top>View the current state of <font size=+1><tt>target/</tt></font> via browser (local files)</td>
23
+ </tr>
24
+ <tr>
25
+ <td valign=top><font size=+1><tt>rcms publish</tt></font> </td>
26
+ <td valign=top>Publish <font size=+1><tt>target/</tt></font> to the remote server</td>
27
+ </tr>
28
+ <tr>
29
+ <td valign=top><font size=+1><tt>rcms browse</tt></font> </td>
30
+ <td valign=top>Browse the current state of the remote server</td>
31
+ </tr>
32
+ </table></center>
33
+ At present, there is no check for these to be done in order. For example,
34
+ you could publish without a generate (analogous to editing a C program
35
+ and running the executable without recompiling it).
36
+ <p>
37
+
38
+ The assumption is made that keys for the user and server are already
39
+ set up. The <font size=+1><tt>config.txt</tt></font> file looks like:
40
+ <p>
41
+
42
+ <pre>
43
+ server: foo.com
44
+ path: /var/www/foo
45
+ user: hal9000
46
+ </pre>
47
+ <p>
48
+
49
+ <p>
50
+
51
+ More details later...
52
+ <p>
53
+
data/bin/rcms ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH << "lib"
4
+ $LOAD_PATH << "../../lib" # for examples/ex1/ etc.
5
+
6
+ require 'rubygems'
7
+
8
+ require 'runecms'
9
+
10
+ # "Main"
11
+
12
+ usage_message if ARGV.empty?
13
+
14
+ cmd = ARGV.first
15
+
16
+ abort "Don't know #{cmd}" unless command?(cmd)
17
+
18
+ read_config
19
+
20
+ execute(cmd)
21
+
@@ -0,0 +1,3 @@
1
+ server: foo.com
2
+ path: /var/www/foo
3
+ user: hal9000
@@ -0,0 +1,3 @@
1
+ <h3>This file is in HTML</h3>
2
+
3
+ It would get copied over with no processing.
@@ -0,0 +1,7 @@
1
+ .h3 This file...
2
+
3
+ is a `.lt3 file, which means livetext would process it
4
+ before it is copied from source/ to target/
5
+
6
+ That's all for now.
7
+
@@ -0,0 +1,5 @@
1
+ .h1 Well, here we are
2
+
3
+ *[ Not much to see here, really]
4
+
5
+ But maybe later there will be.
@@ -0,0 +1,3 @@
1
+ <h3>This file is in HTML</h3>
2
+
3
+ It would get copied over with no processing.
@@ -0,0 +1,10 @@
1
+ <h3>This file...</h3>
2
+ <p>
3
+
4
+ is a <font size=+1><tt>.lt3</tt></font> file, which means livetext would process it
5
+ before it is copied from source/ to target/
6
+ <p>
7
+
8
+ That's all for now.
9
+ <p>
10
+
@@ -0,0 +1,7 @@
1
+ <h1>Well, here we are</h1>
2
+ <p>
3
+
4
+ <b>Not much to see here, really</b>
5
+ <p>
6
+
7
+ But maybe later there will be.
@@ -0,0 +1,58 @@
1
+
2
+ require 'find'
3
+
4
+ CONFIG = "config.txt"
5
+
6
+ def run_config
7
+ unless File.exist?(CONFIG)
8
+ File.open(CONFIG, "w") do |f|
9
+ f.puts "server: "
10
+ f.puts "path: "
11
+ f.puts "user: "
12
+ end
13
+ end
14
+ system("vi #{CONFIG}")
15
+ end
16
+
17
+ def run_generate
18
+ verify_dirs # handle missing subdirectories
19
+ list = find_files("source")
20
+ list.each do |file|
21
+ if stale?(file)
22
+ puts " #{file} is stale"
23
+ update_target(file)
24
+ end
25
+ end
26
+ end
27
+
28
+ def run_view
29
+ # FIXME index is hardcoded...
30
+ system("open target/index.html")
31
+ end
32
+
33
+ def run_publish
34
+ cmd = "rsync -r -z target/ #@user@#@server:#@path/"
35
+ system(cmd)
36
+ # puts "Would run: '#{cmd}'"
37
+ # puts
38
+ end
39
+
40
+ def run_update
41
+ run_generate
42
+ run_publish
43
+ end
44
+
45
+ def run_browse
46
+ system("open #@server")
47
+ # puts "Would run: 'open #@server'"
48
+ # puts
49
+ end
50
+
51
+ def command?(cmd)
52
+ self.respond_to?("run_#{cmd}", true)
53
+ end
54
+
55
+ def execute(cmd)
56
+ send("run_#{cmd}")
57
+ end
58
+
@@ -0,0 +1,85 @@
1
+
2
+ def usage_message
3
+ puts
4
+ puts <<-TEXT
5
+ rcms config Initialize config.txt if necessary and edit with vi
6
+ rcms generate Find stale files under source/ and generate them under target/
7
+ rcms view View the current state of target/ via browser (local files)
8
+ rcms publish Publish target/ to the remote server
9
+ rcms update Shortcut - Like a generate followed by a push
10
+ rcms browse Browse the current state of the remote server
11
+ TEXT
12
+ puts
13
+ exit
14
+ end
15
+
16
+ def find_files(dir)
17
+ list = Find.find(dir).to_a - [dir]
18
+ list.map {|x| x.sub("#{dir}/","") }
19
+ end
20
+
21
+ def stale?(file) # without source/ or target/
22
+ return false if File.directory?(file)
23
+ if file.end_with?(".lt3")
24
+ file1 = file
25
+ file2 = file.sub(/.lt3$/, ".html")
26
+ else
27
+ file1 = file2 = file
28
+ end
29
+ return true if ! File.exist?("target/#{file2}")
30
+
31
+ t1 = File.mtime("source/#{file1}")
32
+ t2 = File.mtime("target/#{file2}")
33
+ t1 > t2
34
+ end
35
+
36
+ def update_target(file)
37
+ file2 = fix_extension(file)
38
+ if lt3?(file)
39
+ update = "livetext"
40
+ redir = ">"
41
+ else
42
+ update = "cp"
43
+ redir = ""
44
+ end
45
+ cmd = "#{update} source/#{file} #{redir} target/#{file2}"
46
+ # puts cmd
47
+ system(cmd)
48
+ end
49
+
50
+ def verify_dirs
51
+ src_dirs = []
52
+ Find.find("source") do |path|
53
+ src_dirs << path if File.directory?(path)
54
+ end
55
+
56
+ src_dirs.each do |path|
57
+ tdir = path.sub("source", "target")
58
+ Dir.mkdir(tdir) unless Dir.exist?(tdir)
59
+ end
60
+ end
61
+
62
+ def lt3?(file)
63
+ file.end_with?(".lt3")
64
+ end
65
+
66
+ def fix_extension(file)
67
+ if lt3?(file)
68
+ file2 = file.sub(/.lt3$/, ".html")
69
+ else
70
+ file2 = file
71
+ end
72
+ file2
73
+ end
74
+
75
+ def read_config
76
+ lines = File.readlines("config.txt")
77
+ # Example: "user: hal9000"
78
+ lines.each do |line|
79
+ var, val = line.split(": ")
80
+ instance_variable_set("@"+var, val.chomp.strip)
81
+ end
82
+ rescue => err
83
+ abort "Can't open config file: #{err}"
84
+ end
85
+
@@ -0,0 +1,3 @@
1
+ class RuneCMS
2
+ VERSION = "0.0.7"
3
+ end
data/lib/runecms.rb ADDED
@@ -0,0 +1,3 @@
1
+ require_relative 'runecms/version.rb'
2
+ require_relative 'runecms/commands.rb'
3
+ require_relative 'runecms/support.rb'
data/runecms.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ require 'date'
2
+ require 'find'
3
+
4
+ $LOAD_PATH << "lib"
5
+
6
+ require "runecms"
7
+
8
+ Gem::Specification.new do |s|
9
+ def s.file_trees(*dirs)
10
+ list = []
11
+ dirs.each {|dir| list += Find.find(dir).to_a }
12
+ list
13
+ end
14
+
15
+ # ^ save this somewhere
16
+ # Also: bump version, new gem, ...
17
+ # Maybe base entire thing on livetext?? Meaning a
18
+ # single .lt3 file to specify the entire project??
19
+
20
+ system("rm -f *.gem")
21
+ s.name = 'runecms'
22
+ s.version = RuneCMS::VERSION
23
+ s.date = Date.today.strftime("%Y-%m-%d")
24
+ s.summary = "Simple static website manager"
25
+ s.description = "A simple static website manager based on Livetext (and Ruby)"
26
+ s.authors = ["Hal Fulton"]
27
+ s.email = 'rubyhacker@gmail.com'
28
+ s.executables << "rcms"
29
+
30
+ # Files...
31
+ main = s.file_trees("bin", "lib", "examples", "test")
32
+ misc = %w[./README.lt3 ./README.md runecms.gemspec]
33
+
34
+ s.files = main + misc
35
+ s.homepage = 'https://github.com/Hal9000/runecms'
36
+ s.license = "Ruby"
37
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: runecms
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.7
5
+ platform: ruby
6
+ authors:
7
+ - Hal Fulton
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-06-04 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
+ - examples/ex1/target/file2.html
28
+ - examples/ex1/target/file3.html
29
+ - examples/ex1/target/index.html
30
+ - lib/runecms.rb
31
+ - lib/runecms/commands.rb
32
+ - lib/runecms/support.rb
33
+ - lib/runecms/version.rb
34
+ - runecms.gemspec
35
+ homepage: https://github.com/Hal9000/runecms
36
+ licenses:
37
+ - Ruby
38
+ metadata: {}
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubygems_version: 3.1.2
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: Simple static website manager
58
+ test_files: []