runeblog 0.3.14 → 0.3.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/helpers-blog.rb +29 -3
- data/lib/helpers-repl.rb +8 -0
- data/lib/lowlevel.rb +12 -0
- data/lib/repl.rb +47 -1
- data/lib/runeblog_version.rb +1 -1
- 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: 29a43db71861d8f4f4c0fb7d53a105c2a53046bf7750dbf027ab02e613369861
|
4
|
+
data.tar.gz: 882e0d89b642866fdb87f3be48bebbcf3af37ebcc3d0a8cb1671adc21722cb2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0720c49855701a7b032012b951efd315dfe882a0498a8e7d7d771741ed3849b58f3519329fdcc93939e0a7ee9c7827c41d4d3720737d48d9926109171ba1b609
|
7
|
+
data.tar.gz: f0092498f40e784bee2847ae5ca11966e03fb9a59d5d9fca2c9a3142050f43df1e0fbff8607ebcc5d683869ab5fc0883ab681dbe87fb51e1e1644d2cd762e998
|
data/lib/helpers-blog.rb
CHANGED
@@ -3,6 +3,7 @@ require 'fileutils'
|
|
3
3
|
|
4
4
|
require 'processing'
|
5
5
|
|
6
|
+
require 'pathmagic'
|
6
7
|
require 'lowlevel'
|
7
8
|
|
8
9
|
module RuneBlog::Helpers
|
@@ -16,10 +17,11 @@ module RuneBlog::Helpers
|
|
16
17
|
|
17
18
|
def read_features(view = nil)
|
18
19
|
hash = {}
|
19
|
-
|
20
|
-
|
20
|
+
root = @blog.root rescue ".blogs"
|
21
|
+
if view.nil? # toplevel
|
22
|
+
dir = root/"data"
|
21
23
|
else
|
22
|
-
dir =
|
24
|
+
dir = root/:views/view/:settings
|
23
25
|
end
|
24
26
|
file = dir/"features.txt"
|
25
27
|
pairs = read_pairs(file)
|
@@ -28,6 +30,30 @@ module RuneBlog::Helpers
|
|
28
30
|
@features = enabled
|
29
31
|
end
|
30
32
|
|
33
|
+
def write_features(hash, view = nil)
|
34
|
+
root = @blog.root rescue ".blogs"
|
35
|
+
if view.nil? # toplevel
|
36
|
+
dir = root/"data"
|
37
|
+
else
|
38
|
+
dir = root/:views/view/:settings
|
39
|
+
end
|
40
|
+
file = dir/"features.txt"
|
41
|
+
lines = File.readlines(file)
|
42
|
+
names = hash.keys
|
43
|
+
names.each do |name|
|
44
|
+
n, item = find_item!(lines) {|x| x =~ /^#{name} / }
|
45
|
+
k = name.length + 1 # 2nd blank after name
|
46
|
+
loop { break if item[k] != " "; k += 1 }
|
47
|
+
item[k] = hash[name]
|
48
|
+
lines[n] = item
|
49
|
+
end
|
50
|
+
File.write(file, lines.join)
|
51
|
+
rescue => err
|
52
|
+
puts "Error: #{err}"
|
53
|
+
puts err.backtrace.join("\n")
|
54
|
+
puts
|
55
|
+
end
|
56
|
+
|
31
57
|
def get_repo_config
|
32
58
|
log!(enter: __method__, level: 3)
|
33
59
|
@editor = File.read(".blogs/data/EDITOR").chomp
|
data/lib/helpers-repl.rb
CHANGED
@@ -31,6 +31,13 @@ module RuneBlog::REPL
|
|
31
31
|
"cv" => :cmd_change_view, # 0-arity must come second
|
32
32
|
|
33
33
|
"config" => :cmd_config,
|
34
|
+
|
35
|
+
"list widgets" => :cmd_list_widgets,
|
36
|
+
"lsw" => :cmd_list_widgets,
|
37
|
+
"install $widget" => :cmd_install_widget,
|
38
|
+
"enable $widget" => :cmd_enable_widget,
|
39
|
+
"disable $widget" => :cmd_disable_widget,
|
40
|
+
"update $widget" => :cmd_update_widget,
|
34
41
|
"manage $widget" => :cmd_manage,
|
35
42
|
|
36
43
|
"legacy" => :cmd_legacy,
|
@@ -89,6 +96,7 @@ module RuneBlog::REPL
|
|
89
96
|
rx = "^" + pat
|
90
97
|
rx.gsub!(/ /, " +")
|
91
98
|
rx.gsub!(/\$(\w+) */) { " *(?<#{$1}>\\w+)" }
|
99
|
+
# FIXME - detect when command is missing an arg
|
92
100
|
# How to handle multiple optional args?
|
93
101
|
rx.sub!(/>(\w+)$/) { "(.+)" }
|
94
102
|
rx << "$"
|
data/lib/lowlevel.rb
CHANGED
@@ -103,6 +103,18 @@
|
|
103
103
|
puts err.backtrace.join("\n")
|
104
104
|
end
|
105
105
|
|
106
|
+
def find_item(list)
|
107
|
+
list2 = list.select(&block)
|
108
|
+
exactly_one(list2)
|
109
|
+
end
|
110
|
+
|
111
|
+
def find_item!(list, &block)
|
112
|
+
list2 = list.select(&block)
|
113
|
+
item = exactly_one(list2)
|
114
|
+
n = list.index(&block)
|
115
|
+
[n, item]
|
116
|
+
end
|
117
|
+
|
106
118
|
def exactly_one(list)
|
107
119
|
raise "List: Zero instances" if list.empty?
|
108
120
|
raise "List: More than one instance" if list.size > 1
|
data/lib/repl.rb
CHANGED
@@ -449,6 +449,41 @@ module RuneBlog::REPL
|
|
449
449
|
error(err)
|
450
450
|
end
|
451
451
|
|
452
|
+
=begin
|
453
|
+
{lsw, list widgets} List all known widgets
|
454
|
+
{install WIDGET} Install a widget
|
455
|
+
{enable WIDGET} Use widget in this view
|
456
|
+
{disable WIDGET} Don't use widget in this view
|
457
|
+
{update WIDGET} Update widget code (this view)
|
458
|
+
{manage WIDGET} Manage widget content/layout
|
459
|
+
=end
|
460
|
+
|
461
|
+
def cmd_list_widgets
|
462
|
+
# find/list all available widgets
|
463
|
+
puts "\n STUB: #{__method__}\n "
|
464
|
+
end
|
465
|
+
|
466
|
+
def cmd_install_widget(arg)
|
467
|
+
# install a widget (view? global?)
|
468
|
+
puts "\n STUB: #{__method__}\n "
|
469
|
+
end
|
470
|
+
|
471
|
+
def cmd_enable_widget(arg)
|
472
|
+
write_features({arg.to_sym => "1"}, @blog.view)
|
473
|
+
puts "\n Enabled #{arg}\n "
|
474
|
+
end
|
475
|
+
|
476
|
+
def cmd_disable_widget(arg)
|
477
|
+
write_features({arg.to_sym => "0"}, @blog.view)
|
478
|
+
puts "\n Disabled #{arg}\n "
|
479
|
+
end
|
480
|
+
|
481
|
+
def cmd_update_widget(arg)
|
482
|
+
# update widget code
|
483
|
+
puts "\n STUB: #{__method__}\n "
|
484
|
+
end
|
485
|
+
|
486
|
+
|
452
487
|
Help = <<-EOS
|
453
488
|
|
454
489
|
{Basics:} {Views:}
|
@@ -469,7 +504,18 @@ module RuneBlog::REPL
|
|
469
504
|
{delete ID [ID...]} Remove multiple posts {rebuild} Regenerate all posts and relink
|
470
505
|
{undelete ID} Undelete a post {publish} Publish (current view)
|
471
506
|
{edit ID} Edit a post {ssh} Login to remote server
|
472
|
-
{import ASSETS} Import assets (images, etc.)
|
507
|
+
{import ASSETS} Import assets (images, etc.)
|
508
|
+
|
509
|
+
|
510
|
+
{Widgets:}
|
511
|
+
-------------------------------------------
|
512
|
+
{lsw, list widgets} List all known widgets
|
513
|
+
{install WIDGET} Install a widget
|
514
|
+
{enable WIDGET} Use widget in this view
|
515
|
+
{disable WIDGET} Don't use in this view
|
516
|
+
{update WIDGET} Update code (this view)
|
517
|
+
{manage WIDGET} Manage content/layout
|
518
|
+
|
473
519
|
EOS
|
474
520
|
|
475
521
|
def cmd_help
|
data/lib/runeblog_version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: runeblog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hal Fulton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: livetext
|