runecms 0.0.12 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b21f4eb1bb1ba14621ce2e5e828135369171857133f3cd69f0f458e6d87dffcc
4
- data.tar.gz: 6dc137a0c006d464a80ca68d5a6fcdadfcf69909d8a232ae37c62838c4f098fe
3
+ metadata.gz: bb703049421336644a4ed7f558e5b0e24ac1ac1afda11078abc2c487e6fcde62
4
+ data.tar.gz: 877c8eed4ad958999c8bb5af867286bda8c9a71cfd10faa6a91cf88f8824d172
5
5
  SHA512:
6
- metadata.gz: d388385924aa49ec1b12147bb037788625549577953e8999971c0911ea3c8e2bd586dbc3d7c82c4255c56e0037c78550054fa72ba2efc961530fbc71a723f808
7
- data.tar.gz: 242b2d20913ab59d25da21b29d9421bc176165dae0f4c985a4c39ea092a4dbf6f65a818fe616837380593711ec64772acf0f6c09d428279f0bc9948b0af78724
6
+ metadata.gz: b4d793a88a5f2d23ce5b9d74daa7094bd0827d4e1bc6bcbcad54c0d504510b12458c399b02c110dd2aa63e492c9aa28e3b3c8953280a609ee3643c6fdc2d184c
7
+ data.tar.gz: d3953ef17d5ba3e319ff30958b4685a4a65e7f5b1333b61294142c3b0923a60a922722509f538038733720b2dd242828e20f63134f096ef8c28750441988b485
data/README.lt3 CHANGED
@@ -1,23 +1,44 @@
1
+ . Note: at present, paragraphs are broken in livetext. Hence the .br
2
+
1
3
  RuneCMS is intended to be a simple, lightweight tool for building
2
4
  and deploying static websites.
3
5
 
6
+ .br 2
7
+
4
8
  It's based on Livetext, but could be generalized to be agnostic of
5
9
  that tool. It is abstracted from a portion of RuneBlog.
6
10
 
11
+ .br 2
12
+
7
13
  In its present form, the `rcms command simply takes a parameter.
8
- Your choices are:
14
+ Choices are:
15
+
16
+ .br 2
17
+
9
18
  .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
19
+ `[rcms version] :: Print the version number of RuneCMS
20
+
21
+ `[rcms config] :: Initialize `config.txt if necessary and edit with `vi
22
+
23
+ `[rcms check] :: List stale files, but do nothing else
24
+
25
+ `[rcms generate] :: Find stale files under `source/ and generate them under `target/
26
+
27
+ `[rcms publish] :: Publish `target/ to the remote server
28
+
29
+ `[rcms update] :: Shortcut - Like a generate followed by a publish
30
+
31
+ `[rcms view] :: View the current state of `target/ via browser (local files)
32
+
33
+ `[rcms browse] :: Browse the current state of the remote server
15
34
  .end
16
35
 
17
36
  At present, there is no check for these to be done in order. For example,
18
37
  you could publish without a generate (analogous to editing a C program
19
38
  and running the executable without recompiling it).
20
39
 
40
+ .br 2
41
+
21
42
  The assumption is made that keys for the user and server are already
22
43
  set up. The `config.txt file looks like:
23
44
 
@@ -27,6 +48,49 @@ path: /var/www/foo
27
48
  user: hal9000
28
49
  </pre>
29
50
 
51
+ <hr>
52
+
53
+ *[Original notes:]
54
+
55
+ <pre>
56
+ General idea: Website is stored in a directory tree. Use Livetext (etc.?) to create target files
57
+ and rsync to upload.
58
+
59
+ .br 2
60
+
61
+ Config will comprise:
62
+ - server
63
+ - user
64
+ - root/path
65
+
66
+ .br 2
67
+
68
+ Dir structure:
69
+
70
+ .br 2
71
+
72
+ site
73
+ |
74
+ +---- config.lt3
75
+ +---- source/...
76
+ +---- target/...
77
+
78
+ .br 2
79
+
80
+ Logic flow:
81
+ 1. Edit file(s) under source/ tree
82
+ 2. Generate
83
+ - reads config
84
+ - finds modified files under source/
85
+ - runs livetext on each
86
+ - results go under target/
87
+ 3. View target/ locally to verify
88
+ 4. Publish via rsync
89
+ # cmd = "rsync -r -z #{target}/ #@user@#@server:#{path}/"
90
+
91
+ </pre>
92
+
93
+ .br 2
30
94
 
31
95
  More details later...
32
96
 
data/README.md CHANGED
@@ -1,53 +1,100 @@
1
1
  RuneCMS is intended to be a simple, lightweight tool for building
2
2
  and deploying static websites.
3
- <p>
4
-
3
+ <br><br>
5
4
  It's based on Livetext, but could be generalized to be agnostic of
6
5
  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:
6
+ <br><br>
7
+ In its present form, the <t>rcms</t> command simply takes a parameter.
8
+ Choices are:
9
+ <br><br>
11
10
  <br><center><table width=90% cellpadding=5>
12
11
  <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>
12
+ <td valign=top><t>rcms version</t></td>
13
+ <td valign=top>Print the version number of RuneCMS</td>
15
14
  </tr>
16
15
  <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
16
  </tr>
20
17
  <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>
18
+ <td valign=top><t>rcms config</t></td>
19
+ <td valign=top>Initialize <t>config.txt</t> if necessary and edit with <t>vi</t></td>
23
20
  </tr>
24
21
  <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
22
  </tr>
28
23
  <tr>
29
- <td valign=top><font size=+1><tt>rcms browse</tt></font> </td>
24
+ <td valign=top><t>rcms check</t></td>
25
+ <td valign=top> List stale files, but do nothing else</td>
26
+ </tr>
27
+ <tr>
28
+ </tr>
29
+ <tr>
30
+ <td valign=top><t>rcms generate</t></td>
31
+ <td valign=top>Find stale files under <t>source/</t> and generate them under <t>target/</t></td>
32
+ </tr>
33
+ <tr>
34
+ </tr>
35
+ <tr>
36
+ <td valign=top><t>rcms publish</t></td>
37
+ <td valign=top>Publish <t>target/</t> to the remote server</td>
38
+ </tr>
39
+ <tr>
40
+ </tr>
41
+ <tr>
42
+ <td valign=top><t>rcms update</t> </td>
43
+ <td valign=top>Shortcut - Like a generate followed by a publish</td>
44
+ </tr>
45
+ <tr>
46
+ </tr>
47
+ <tr>
48
+ <td valign=top><t>rcms view</t></td>
49
+ <td valign=top>View the current state of <t>target/</t> via browser (local files)</td>
50
+ </tr>
51
+ <tr>
52
+ </tr>
53
+ <tr>
54
+ <td valign=top><t>rcms browse</t></td>
30
55
  <td valign=top>Browse the current state of the remote server</td>
31
56
  </tr>
32
57
  </table></center>
33
58
  At present, there is no check for these to be done in order. For example,
34
59
  you could publish without a generate (analogous to editing a C program
35
60
  and running the executable without recompiling it).
36
- <p>
37
-
61
+ <br><br>
38
62
  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
-
63
+ set up. The <t>config.txt</t> file looks like:
42
64
  <pre>
43
65
  server: foo.com
44
66
  path: /var/www/foo
45
67
  user: hal9000
46
68
  </pre>
47
- <p>
48
-
49
- <p>
50
-
69
+ <hr>
70
+ <b>Original notes:</b>
71
+ <pre>
72
+ General idea: Website is stored in a directory tree. Use Livetext (etc.?) to create target files
73
+ and rsync to upload.
74
+ <br><br>
75
+ Config will comprise:
76
+ - server
77
+ - user
78
+ - root/path
79
+ <br><br>
80
+ Dir structure:
81
+ <br><br>
82
+ site
83
+ |
84
+ +---- config.lt3
85
+ +---- source/...
86
+ +---- target/...
87
+ <br><br>
88
+ Logic flow:
89
+ 1. Edit file(s) under source/ tree
90
+ 2. Generate
91
+ - reads config
92
+ - finds modified files under source/
93
+ - runs livetext on each
94
+ - results go under target/
95
+ 3. View target/ locally to verify
96
+ 4. Publish via rsync
97
+ # cmd = "rsync -r -z #{target}/ #@user@#@server:#{path}/"
98
+ </pre>
99
+ <br><br>
51
100
  More details later...
52
- <p>
53
-
data/bin/rcms CHANGED
@@ -1,9 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $LOAD_PATH << "lib"
4
- $LOAD_PATH << "../../lib" # for examples/ex1/ etc.
5
-
6
- require 'rubygems'
3
+ $LOAD_PATH << "lib"
7
4
 
8
5
  require 'runecms'
9
6
 
@@ -15,7 +12,5 @@ cmd = ARGV.first
15
12
 
16
13
  abort "Don't know #{cmd}" unless command?(cmd)
17
14
 
18
- read_config
19
-
20
15
  execute(cmd)
21
16
 
@@ -1,3 +1,3 @@
1
1
  server: foo.com
2
- path: /var/www/foo
3
- user: hal9000
2
+ path: /var/www/foo
3
+ user: hal9000
@@ -3,29 +3,52 @@ require 'find'
3
3
 
4
4
  CONFIG = "config.txt"
5
5
 
6
+ def run_version
7
+ puts RuneCMS::VERSION
8
+ end
9
+
10
+ def run_check
11
+ stale = 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
+
6
21
  def run_config
7
- unless File.exist?(CONFIG)
8
- File.open(CONFIG, "w") do |f|
22
+ unless read_config
23
+ File.open("config.txt", "w") do |f|
9
24
  f.puts "server: "
10
- f.puts "path: "
11
- f.puts "user: "
25
+ f.puts "path: "
26
+ f.puts "user: "
12
27
  end
13
28
  end
14
- system("vi #{CONFIG}")
29
+ system("vi config.txt")
15
30
  end
16
31
 
17
32
  def run_generate
18
33
  verify_dirs # handle missing subdirectories
19
- list = find_files("source")
20
- list.each do |file|
21
- next if File.directory?("source/#{file}")
22
- if stale?(file)
23
- puts " #{file} is stale"
34
+ stale = 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
24
41
  update_target(file)
25
42
  end
43
+ puts
26
44
  end
27
45
  end
28
46
 
47
+ def run_update
48
+ run_generate
49
+ run_publish
50
+ end
51
+
29
52
  def run_view
30
53
  # FIXME index is hardcoded...
31
54
  system("open target/index.html")
@@ -34,19 +57,10 @@ end
34
57
  def run_publish
35
58
  cmd = "rsync -r -z target/ #@user@#@server:#@path/"
36
59
  system(cmd)
37
- # puts "Would run: '#{cmd}'"
38
- # puts
39
- end
40
-
41
- def run_update
42
- run_generate
43
- run_publish
44
60
  end
45
61
 
46
62
  def run_browse
47
63
  system("open #@server")
48
- # puts "Would run: 'open #@server'"
49
- # puts
50
64
  end
51
65
 
52
66
  def command?(cmd)
@@ -3,19 +3,32 @@ def usage_message
3
3
  puts
4
4
  puts <<-TEXT
5
5
  rcms config Initialize config.txt if necessary and edit with vi
6
+ rcms check List stale files, but do nothing else
6
7
  rcms generate Find stale files under source/ and generate them under target/
7
8
  rcms view View the current state of target/ via browser (local files)
8
9
  rcms publish Publish target/ to the remote server
9
10
  rcms update Shortcut - Like a generate followed by a push
10
11
  rcms browse Browse the current state of the remote server
12
+
13
+ Run from a directory with a config.txt, a source/ dir, and a target/ dir.
14
+
15
+ Config file looks like:
16
+ server: example.com
17
+ path: /some/arbitrary/path
18
+ user: myuser
19
+
11
20
  TEXT
12
21
  puts
13
22
  exit
14
23
  end
15
24
 
16
- def find_files(dir)
17
- list = Find.find(dir).to_a - [dir]
18
- list.map {|x| x.sub("#{dir}/","") }
25
+ def stale_files(dir)
26
+ list = nil
27
+ path = "#{Dir.pwd}/#{dir}/"
28
+ list = Find.find(path).to_a
29
+ list = list.select {|x| ! File.directory?(x) }
30
+ list.map! {|x| x.sub(path, "") }
31
+ list.select {|x| stale?(x) }
19
32
  end
20
33
 
21
34
  def stale?(file) # without source/ or target/
@@ -44,7 +57,6 @@ def update_target(file)
44
57
  cmd = "cp source/#{file} target/#{file2}"
45
58
  end
46
59
  end
47
- # puts cmd
48
60
  system(cmd)
49
61
  end
50
62
 
@@ -74,13 +86,23 @@ def fix_extension(file)
74
86
  end
75
87
 
76
88
  def read_config
89
+ config = "config.txt"
90
+ here = Dir.pwd
91
+ loop do
92
+ raise if Dir.pwd == "/" # shouldn't get this far
93
+ break if File.exist?(config)
94
+ Dir.chdir("..")
95
+ end
77
96
  lines = File.readlines("config.txt")
78
97
  # Example: "user: hal9000"
79
98
  lines.each do |line|
80
99
  var, val = line.split(": ")
81
- instance_variable_set("@"+var, val.chomp.strip)
100
+ instance_variable_set("@" + var, val.chomp.strip)
82
101
  end
83
- rescue => err
84
- abort "Can't open config file: #{err}"
102
+ return true
103
+ rescue => e
104
+ puts "Can't read config file: here = #{here} pwd = #{Dir.pwd}"
105
+ puts e
106
+ return false
85
107
  end
86
108
 
@@ -1,3 +1,3 @@
1
1
  class RuneCMS
2
- VERSION = "0.0.12"
2
+ VERSION = "0.0.14"
3
3
  end
data/runecms.gemspec CHANGED
@@ -1,14 +1,15 @@
1
1
  require 'date'
2
2
  require 'find'
3
3
 
4
- $LOAD_PATH << "lib"
5
-
6
- require "runecms"
4
+ require_relative "lib/runecms"
7
5
 
8
6
  Gem::Specification.new do |s|
9
7
  def s.file_trees(*dirs)
10
8
  list = []
11
- dirs.each {|dir| list += Find.find(dir).to_a }
9
+ dirs.each do |dir|
10
+ stuff = Find.find(dir).to_a
11
+ list += stuff
12
+ end
12
13
  list
13
14
  end
14
15
 
@@ -34,4 +35,5 @@ Gem::Specification.new do |s|
34
35
  s.files = main + misc
35
36
  s.homepage = 'https://github.com/Hal9000/runecms'
36
37
  s.license = "Ruby"
38
+ s.post_install_message = "\n Success! For help, run 'rcms' with no parameters.\n "
37
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runecms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hal Fulton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-04 00:00:00.000000000 Z
11
+ date: 2022-07-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple static website manager based on Livetext (and Ruby)
14
14
  email: rubyhacker@gmail.com
@@ -24,9 +24,6 @@ files:
24
24
  - examples/ex1/source/file2.html
25
25
  - examples/ex1/source/file3.lt3
26
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
27
  - lib/runecms.rb
31
28
  - lib/runecms/commands.rb
32
29
  - lib/runecms/support.rb
@@ -36,7 +33,7 @@ homepage: https://github.com/Hal9000/runecms
36
33
  licenses:
37
34
  - Ruby
38
35
  metadata: {}
39
- post_install_message:
36
+ post_install_message: "\n Success! For help, run 'rcms' with no parameters.\n "
40
37
  rdoc_options: []
41
38
  require_paths:
42
39
  - lib
@@ -1,3 +0,0 @@
1
- <h3>This file is in HTML</h3>
2
-
3
- It would get copied over with no processing.
@@ -1,10 +0,0 @@
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
-
@@ -1,7 +0,0 @@
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.