runeblog 0.3.12 → 0.3.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/bin/blog +17 -5
  3. data/empty_view/themes/standard/banner/navbar/faq.lt3 +1 -1
  4. data/empty_view/themes/standard/blog/index.lt3 +0 -1
  5. data/empty_view/themes/standard/post/generate.lt3 +0 -2
  6. data/empty_view/themes/standard/post/permalink.lt3 +0 -1
  7. data/lib/helpers-blog.rb +44 -3
  8. data/lib/helpers-repl.rb +8 -0
  9. data/lib/liveblog.rb +10 -22
  10. data/lib/lowlevel.rb +19 -0
  11. data/lib/menus.rb +115 -0
  12. data/lib/processing.rb +2 -1
  13. data/lib/publish.rb +0 -1
  14. data/lib/repl.rb +54 -6
  15. data/lib/runeblog.rb +24 -43
  16. data/lib/runeblog_version.rb +1 -1
  17. data/{empty_view/themes/standard → lib}/widgets/README +0 -0
  18. data/{empty_view/themes/standard → lib}/widgets/bydates/README +0 -0
  19. data/{empty_view/themes/standard → lib}/widgets/bydates/bydates.rb +0 -0
  20. data/{empty_view/themes/standard → lib}/widgets/bydates/card.css +0 -0
  21. data/{empty_view/themes/standard → lib}/widgets/bydates/custom.rb +0 -0
  22. data/{empty_view/themes/standard → lib}/widgets/bydates/main.css +0 -0
  23. data/{empty_view/themes/standard → lib}/widgets/links/README +0 -0
  24. data/{empty_view/themes/standard → lib}/widgets/links/card.css +0 -0
  25. data/{empty_view/themes/standard → lib}/widgets/links/custom.rb +0 -0
  26. data/{empty_view/themes/standard → lib}/widgets/links/links.rb +0 -0
  27. data/{empty_view/themes/standard → lib}/widgets/links/list.data +0 -0
  28. data/{empty_view/themes/standard → lib}/widgets/links/main.css +0 -0
  29. data/{empty_view/themes/standard → lib}/widgets/news/README +0 -0
  30. data/{empty_view/themes/standard → lib}/widgets/news/card.css +0 -0
  31. data/{empty_view/themes/standard → lib}/widgets/news/custom.rb +0 -0
  32. data/{empty_view/themes/standard → lib}/widgets/news/list.data +0 -0
  33. data/{empty_view/themes/standard → lib}/widgets/news/main.css +0 -0
  34. data/{empty_view/themes/standard → lib}/widgets/news/news.rb +0 -0
  35. data/{empty_view/themes/standard → lib}/widgets/pages/README +0 -0
  36. data/{empty_view/themes/standard → lib}/widgets/pages/card.css +0 -0
  37. data/{empty_view/themes/standard → lib}/widgets/pages/custom.rb +0 -0
  38. data/{empty_view/themes/standard → lib}/widgets/pages/disclaim.lt3 +0 -0
  39. data/{empty_view/themes/standard → lib}/widgets/pages/faq.lt3 +0 -0
  40. data/{empty_view/themes/standard → lib}/widgets/pages/like-dislike.lt3 +0 -0
  41. data/{empty_view/themes/standard → lib}/widgets/pages/list.data +0 -0
  42. data/{empty_view/themes/standard → lib}/widgets/pages/local.rb +0 -0
  43. data/{empty_view/themes/standard → lib}/widgets/pages/main.css +0 -0
  44. data/{empty_view/themes/standard → lib}/widgets/pages/other-stuff.lt3 +0 -0
  45. data/{empty_view/themes/standard → lib}/widgets/pages/pages.rb +35 -0
  46. data/{empty_view/themes/standard → lib}/widgets/pinned/README +0 -0
  47. data/{empty_view/themes/standard → lib}/widgets/pinned/card.css +0 -0
  48. data/{empty_view/themes/standard → lib}/widgets/pinned/custom.rb +0 -0
  49. data/{empty_view/themes/standard → lib}/widgets/pinned/main.css +0 -0
  50. data/{empty_view/themes/standard → lib}/widgets/pinned/pinned.rb +0 -0
  51. data/{empty_view/themes/standard → lib}/widgets/search/README +0 -0
  52. data/{empty_view/themes/standard → lib}/widgets/search/card.css +0 -0
  53. data/{empty_view/themes/standard → lib}/widgets/search/custom.rb +0 -0
  54. data/{empty_view/themes/standard → lib}/widgets/search/main.css +0 -0
  55. data/{empty_view/themes/standard → lib}/widgets/search/search.rb +0 -0
  56. data/{empty_view/themes/standard → lib}/widgets/sitemap/README +0 -0
  57. data/{empty_view/themes/standard → lib}/widgets/sitemap/card.css +0 -0
  58. data/{empty_view/themes/standard → lib}/widgets/sitemap/custom.rb +0 -0
  59. data/{empty_view/themes/standard → lib}/widgets/sitemap/main.css +0 -0
  60. data/{empty_view/themes/standard → lib}/widgets/sitemap/sitemap.rb +0 -0
  61. data/{empty_view/themes/standard → lib}/widgets/tag-cloud/OLD-example.lt3 +0 -0
  62. data/{empty_view/themes/standard → lib}/widgets/tag-cloud/README +0 -0
  63. data/{empty_view/themes/standard → lib}/widgets/tag-cloud/card.css +0 -0
  64. data/{empty_view/themes/standard → lib}/widgets/tag-cloud/custom.rb +0 -0
  65. data/{empty_view/themes/standard → lib}/widgets/tag-cloud/main.css +0 -0
  66. data/{empty_view/themes/standard → lib}/widgets/tag-cloud/tag-cloud.lt3 +0 -0
  67. data/{empty_view/themes/standard → lib}/widgets/tag-cloud/tag-cloud.rb +0 -0
  68. data/runeblog.gemspec +2 -2
  69. metadata +58 -62
  70. data/empty_view/themes/standard/widgets/ad/ad.lt3 +0 -22
  71. data/empty_view/themes/standard/widgets/ad/ad1.png +0 -0
  72. data/empty_view/themes/standard/widgets/ad/ad2.png +0 -0
  73. data/empty_view/themes/standard/widgets/ad/ad3.png +0 -0
  74. data/empty_view/themes/standard/widgets/ad/ad4.png +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0372218e12e1f9436b17621b6d32a0894daf4e58bbf7f2cd55dd6fc48eca5af5'
4
- data.tar.gz: 33da1a53944d8db1b681f885446721e626699b8a3b0126bd3b854df1f707a203
3
+ metadata.gz: d17e951cf12388a3cd71091a7e8a014bcc71d3e08d08a6001b91deb8b545bdf5
4
+ data.tar.gz: e76a74b9751d248c1bc71387bfc684376f6b130e641b856bb94ef5715b948062
5
5
  SHA512:
6
- metadata.gz: 8d5fd3bf878e11f7d9d1cba4659c9f199a0cc7908bf2bf9596e6e2716e56a53863cd0cf978dfa3c0db033c8129ab5ddf2f29daf315fa058e50171b783c926012
7
- data.tar.gz: 5790b07d2a6b3ca787b67e473f83e99ee4d29171ffc6bdbe30e5275b2ae098c7a388bd873cd9a6e1bb1a3206082e59f1bbefcffc158b3f704a0fda3a02637d7e
6
+ metadata.gz: 237fc6eca980f18aff1fc950831d7579b944727a587e23ea3fae538b5e8a222d8299432b4ad16a1f0371702fbd82fdb63d4d057146fedc9edb146a74711ae2dc
7
+ data.tar.gz: 331ba90a0ef26f7e34bcc9358776259eeac2a90aadeb0a311050a4e94d97c4fbd4035ad3464141c58fff4a61541d55d24079cbbfad36e9ff510171be08fe707d
data/bin/blog CHANGED
@@ -5,6 +5,8 @@
5
5
  require 'runeblog'
6
6
  require 'rubytext'
7
7
 
8
+ require 'menus'
9
+
8
10
  require 'repl'
9
11
 
10
12
  include RuneBlog::REPL
@@ -90,11 +92,21 @@ def mainloop
90
92
  info = @blog.view || "no view"
91
93
  print fx("[#{info}] ", Red, :bold)
92
94
  cmd = STDSCR.gets(history: @cmdhist, tab: @tabcom)
93
- cmd_quit if cmd.nil? # ^D
94
- cmd.chomp!
95
- return if cmd.empty? # CR does nothing
96
- invoking = RuneBlog::REPL.choose_method(cmd)
97
- ret = send(*invoking)
95
+ case
96
+ when cmd == RubyText::Keys::Escape
97
+ show_top_menu
98
+ puts
99
+ return
100
+ when cmd == RubyText::Keys::CtlD # ^D
101
+ cmd_quit
102
+ when cmd.is_a?(String)
103
+ cmd.chomp!
104
+ return if cmd.empty? # CR does nothing
105
+ invoking = RuneBlog::REPL.choose_method(cmd)
106
+ ret = send(*invoking)
107
+ else
108
+ puts "Don't understand '#{cmd.inspect}'\n "
109
+ end
98
110
  rescue => err
99
111
  puts err
100
112
  end
@@ -1 +1 @@
1
- .include ../../widgets/pages/faq.lt3
1
+ .include ../../../../widgets/pages/faq.lt3
@@ -9,7 +9,6 @@
9
9
 
10
10
  .sidebar
11
11
  links
12
- ad
13
12
  pinned
14
13
  pages
15
14
  news
@@ -9,10 +9,8 @@
9
9
  <!-- Generated from $File on $$date; editing not recommended. -->
10
10
 
11
11
  .seek global.lt3
12
- .include vars.lt3
13
12
 
14
13
  . FIXME
15
-
16
14
  .head
17
15
  og:title $title
18
16
  description $teaser
@@ -13,7 +13,6 @@
13
13
  <!-- It was generated from $File on $$date. -->
14
14
 
15
15
  .seek global.lt3
16
- .include vars.lt3
17
16
 
18
17
  .head
19
18
  og:title $title
@@ -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
- if view.nil? # toplevel default
20
- dir = @root/"data"
20
+ root = @blog.root rescue ".blogs"
21
+ if view.nil? # toplevel
22
+ dir = root/"data"
21
23
  else
22
- dir = @root/:views/self.view/:settings
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
@@ -39,6 +65,21 @@ module RuneBlog::Helpers
39
65
  puts "dir = #{Dir.pwd}"
40
66
  end
41
67
 
68
+ def get_all_widgets(dest)
69
+ wdir = RuneBlog::Path + "/widgets" # files kept inside gem
70
+ copy!(wdir/"*", dest)
71
+ end
72
+
73
+ def get_widget(dest, widget: :all) # recursive
74
+ wdir = ".blogs/widgets"
75
+ wdir = RuneBlog::Path + "/widgets" # files kept inside gem
76
+ if widget == :all
77
+ copy!(wdir/"*", dest)
78
+ else
79
+ copy!(wdir/widget, dest)
80
+ end
81
+ end
82
+
42
83
  def copy_data(dest)
43
84
  data = RuneBlog::Path + "/../data" # files kept inside gem
44
85
  files = %w[ROOT VIEW EDITOR universal.lt3 global.lt3 features.txt]
@@ -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 << "$"
@@ -33,8 +33,10 @@ def init_liveblog # FIXME - a lot of this logic sucks
33
33
  </a>
34
34
  HTML
35
35
  end
36
- rescue
37
- raise "Only works inside a blog repo"
36
+ rescue => err
37
+ STDERR.puts "err = #{err}"
38
+ STDERR.puts err.backtrace.join("\n")
39
+ # raise "Only works inside a blog repo"
38
40
  end
39
41
 
40
42
  ##################
@@ -380,14 +382,6 @@ def pubdate
380
382
  _optional_blank_line
381
383
  end
382
384
 
383
- def image # primitive so far
384
- _debug "img: huh? <img src=#{_args.first}></img>"
385
- fname = _args.first
386
- path = :assets/fname
387
- _out "<img src=#{path}></img>"
388
- _optional_blank_line
389
- end
390
-
391
385
  def tags
392
386
  raise "'post' was not called" unless @meta
393
387
  _debug "args = #{_args}"
@@ -408,7 +402,7 @@ def pin
408
402
  pinned = @_args
409
403
  @meta.pinned = pinned
410
404
  pinned.each do |pinview|
411
- dir = @blog.root/:views/pinview/"themes/standard/widgets/pinned/"
405
+ dir = @blog.root/:views/pinview/"widgets/pinned/"
412
406
  datafile = dir/"list.data"
413
407
  pins = _get_data?(datafile)
414
408
  pins << "#{@meta.num} #{@meta.title}\n"
@@ -552,7 +546,7 @@ def _make_class_name(app)
552
546
  end
553
547
 
554
548
  def _load_local(widget)
555
- Dir.chdir("widgets/#{widget}") do
549
+ Dir.chdir("../../widgets/#{widget}") do
556
550
  rclass = _make_class_name(widget)
557
551
  found = (require("./#{widget}") if File.exist?("#{widget}.rb"))
558
552
  code = found ? ::RuneBlog::Widget.class_eval(rclass) : nil
@@ -566,7 +560,7 @@ rescue => err
566
560
  end
567
561
 
568
562
  def _handle_standard_widget(tag)
569
- wtag = :widgets/tag
563
+ wtag = "../../widgets"/tag
570
564
  code = _load_local(tag)
571
565
  if code
572
566
  Dir.chdir(wtag) do
@@ -589,21 +583,15 @@ def sidebar
589
583
 
590
584
  _body do |token|
591
585
  tag = token.chomp.strip.downcase
592
- wtag = :widgets/tag
586
+ wtag = "../../widgets"/tag
593
587
  raise "Can't find #{wtag}" unless Dir.exist?(wtag)
594
588
  tcard = "#{tag}-card.html"
595
589
 
596
590
  case
597
591
  when standard.include?(tag)
598
592
  _handle_standard_widget(tag)
599
- when tag == "ad"
600
- num = rand(1..4)
601
- img = "widgets/ad/ad#{num}.png"
602
- src, dst = img, @root/:views/@view_name/"remote/widgets/ad/"
603
- system!("cp #{src} #{dst}")
604
- File.open(wtag/"vars.lt3", "w") {|f| f.puts ".set ad.image = #{img}" }
605
- preprocess cwd: wtag, src: tag, dst: tcard, call: ".nopara",
606
- force: true # , debug: true # , deps: depend
593
+ else
594
+ raise "Nonstandard widget?"
607
595
  end
608
596
 
609
597
  _include_file wtag/tcard
@@ -103,9 +103,28 @@
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
109
121
  list.first
110
122
  end
111
123
 
124
+ def addvar(vars, hash)
125
+ hash.each_pair do |k, v|
126
+ vars[k.to_s] = v
127
+ vars[k.to_sym] = v
128
+ end
129
+ vars
130
+ end
@@ -0,0 +1,115 @@
1
+
2
+ require 'ostruct'
3
+ require 'rubytext'
4
+ require 'repl'
5
+
6
+ Menu = OpenStruct.new
7
+
8
+ notimp = proc { RubyText.splash("Not implemented yet") }
9
+
10
+ top_about = proc { RubyText.splash("RuneBlog v #{RuneBlog::VERSION}") }
11
+ top_help = proc { RubyText.splash(RuneBlog::REPL::Help.gsub(/[{}]/, " ")) }
12
+
13
+ Menu.top_build = {
14
+ Rebuild: proc { cmd_rebuild },
15
+ Preview: proc { cmd_preview },
16
+ Publish: proc { cmd_publish },
17
+ Browse: proc { cmd_browse },
18
+ ssh: proc { cmd_ssh }
19
+ }
20
+
21
+ Menu.top_items = {
22
+ About: top_about,
23
+ Views: notimp,
24
+ Build: proc { STDSCR.menu(items: Menu.top_build) },
25
+ Config: notimp,
26
+ Help: top_help,
27
+ Quit: proc { cmd_quit }
28
+ }
29
+
30
+ def show_top_menu
31
+ STDSCR.topmenu(items: Menu.top_items)
32
+ end
33
+
34
+ # about_items
35
+
36
+
37
+ =begin
38
+ About (version)
39
+ Help
40
+ Views
41
+ New view
42
+ (select)
43
+ Posts
44
+ New post
45
+ (select)
46
+ Drafts
47
+ (select) hmm...
48
+ Widgets
49
+ (select)
50
+ Assets
51
+
52
+ Build
53
+ rebuild
54
+ preview
55
+ publish
56
+ browse
57
+ ssh
58
+
59
+ quit
60
+ =end
61
+
62
+ {
63
+
64
+ "tags" => :cmd_tags,
65
+ "import" => :cmd_import,
66
+
67
+ "config" => :cmd_config,
68
+
69
+ "install $widget" => :cmd_install_widget,
70
+ "enable $widget" => :cmd_enable_widget,
71
+ "disable $widget" => :cmd_disable_widget,
72
+ "update $widget" => :cmd_update_widget,
73
+ "manage $widget" => :cmd_manage,
74
+
75
+ "list assets" => :cmd_list_assets,
76
+ "lsa" => :cmd_list_assets,
77
+
78
+ "pages" => :cmd_pages,
79
+
80
+ "delete >postid" => :cmd_remove_post,
81
+ "undel $postid" => :cmd_undelete_post,
82
+
83
+ "edit $postid" => :cmd_edit_post,
84
+ "ed $postid" => :cmd_edit_post,
85
+ "e $postid" => :cmd_edit_post,
86
+
87
+ }
88
+
89
+ # def cmd_config
90
+ # hash = {"Variables (general)" => "global.lt3",
91
+ # " View-specific" => "../../settings/view.txt",
92
+ # " Recent posts" => "../../settings/recent.txt",
93
+ # " Publishing" => "../../settings/publish.txt",
94
+ # "Configuration: enable/disable" => "../../settings/features.txt",
95
+ # " Reddit" => "../../config/reddit/credentials.txt",
96
+ # " Facebook" => "../../config/facebook/credentials.txt",
97
+ # " Twitter" => "../../config/twitter/credentials.txt",
98
+ # "View: generator" => "blog/generate.lt3",
99
+ # " HEAD info" => "blog/head.lt3",
100
+ # " Layout " => "blog/index.lt3",
101
+ # " Recent-posts entry" => "blog/post_entry.lt3",
102
+ # " Banner: Description" => "blog/banner.lt3",
103
+ # " Text portion" => "banner/top.lt3",
104
+ # "Generator for a post" => "post/generate.lt3",
105
+ # " HEAD info for post" => "post/head.lt3",
106
+ # " Content for post" => "post/index.lt3",
107
+ # "Global CSS" => "etc/blog.css.lt3",
108
+ # "External JS/CSS (Bootstrap, etc.)" => "/etc/externals.lt3"
109
+ # }
110
+ #
111
+ # dir = @blog.view.dir/"themes/standard/"
112
+ # num, target = STDSCR.menu(title: "Edit file:", items: hash)
113
+ # edit_file(dir/target)
114
+ # end
115
+ #
@@ -2,7 +2,7 @@ if ! defined?(LIVE)
2
2
 
3
3
  require 'livetext'
4
4
 
5
- LIVE = Livetext.new
5
+ LIVE = "defined"
6
6
  LEXT = ".lt3"
7
7
 
8
8
  def newer?(f1, f2)
@@ -39,6 +39,7 @@ def preprocess(cwd: Dir.pwd, src:,
39
39
  STDERR.puts "#{sp} in: #{Dir.pwd}"
40
40
  STDERR.puts "#{sp} from: #{caller[0]}"
41
41
  STDERR.puts "#{sp} copy: #{copy}" if copy
42
+ STDERR.puts "#{sp} vars: #{vars.inspect}" unless vars == {}
42
43
  end
43
44
  stale = stale?(src, dst, deps, force)
44
45
  if stale
@@ -52,7 +52,6 @@ class RuneBlog::Publishing
52
52
  view_name = @blog.view.name
53
53
  viewpath = dir
54
54
  cmd = "rsync -r -z #{@blog.root}/views/#{@blog.view}/remote/ #@user@#@server:#{viewpath}/"
55
- puts cmd
56
55
  system!(cmd)
57
56
  check_new_posts
58
57
  dump("#{@blog.view} at #{Time.now}", "#{@blog.view.dir}/last_published")
@@ -3,6 +3,8 @@ require 'ostruct'
3
3
  require 'helpers-repl' # FIXME structure
4
4
  require 'pathmagic'
5
5
 
6
+ require 'menus'
7
+
6
8
  make_exception(:PublishError, "Error during publishing")
7
9
  make_exception(:EditorProblem, "Could not edit $1")
8
10
 
@@ -81,7 +83,7 @@ module RuneBlog::REPL
81
83
  end
82
84
 
83
85
  def _manage_pinned # cloned from manage_links
84
- dir = @blog.view.dir/"themes/standard/widgets/pinned"
86
+ dir = @blog.view.dir/"widgets/pinned"
85
87
  data = dir/"list.data"
86
88
  edit_file(data)
87
89
  end
@@ -116,13 +118,13 @@ module RuneBlog::REPL
116
118
  end
117
119
 
118
120
  def _manage_links
119
- dir = @blog.view.dir/"themes/standard/widgets/links"
121
+ dir = @blog.view.dir/"widgets/links"
120
122
  data = dir/"list.data"
121
123
  edit_file(data)
122
124
  end
123
125
 
124
- def _manage_pages
125
- dir = @blog.view.dir/"themes/standard/widgets/pages"
126
+ def _manage_pages # FIXME move into widget code
127
+ dir = @blog.view.dir/"widgets/pages"
126
128
  # Assume child files already generated (and list.data??)
127
129
  data = dir/"list.data"
128
130
  lines = _get_data?(data)
@@ -376,7 +378,7 @@ module RuneBlog::REPL
376
378
  puts " ", fx(num, Red), " ", fx(title, Black)
377
379
  other = @blog._get_views(@blog.root/:drafts/draft) - [@blog.view.to_s]
378
380
  unless other.empty?
379
- print fx(" "*9 + "also in: ", Bold)
381
+ print fx(" "*9 + "also in: ", :bold)
380
382
  puts other.join(", ")
381
383
  end
382
384
  end
@@ -449,6 +451,41 @@ module RuneBlog::REPL
449
451
  error(err)
450
452
  end
451
453
 
454
+ =begin
455
+ {lsw, list widgets} List all known widgets
456
+ {install WIDGET} Install a widget
457
+ {enable WIDGET} Use widget in this view
458
+ {disable WIDGET} Don't use widget in this view
459
+ {update WIDGET} Update widget code (this view)
460
+ {manage WIDGET} Manage widget content/layout
461
+ =end
462
+
463
+ def cmd_list_widgets
464
+ # find/list all available widgets
465
+ puts "\n STUB: #{__method__}\n "
466
+ end
467
+
468
+ def cmd_install_widget(arg)
469
+ # install a widget (view? global?)
470
+ puts "\n STUB: #{__method__}\n "
471
+ end
472
+
473
+ def cmd_enable_widget(arg)
474
+ write_features({arg.to_sym => "1"}, @blog.view)
475
+ puts "\n Enabled #{arg}\n "
476
+ end
477
+
478
+ def cmd_disable_widget(arg)
479
+ write_features({arg.to_sym => "0"}, @blog.view)
480
+ puts "\n Disabled #{arg}\n "
481
+ end
482
+
483
+ def cmd_update_widget(arg)
484
+ # update widget code
485
+ puts "\n STUB: #{__method__}\n "
486
+ end
487
+
488
+
452
489
  Help = <<-EOS
453
490
 
454
491
  {Basics:} {Views:}
@@ -469,7 +506,18 @@ module RuneBlog::REPL
469
506
  {delete ID [ID...]} Remove multiple posts {rebuild} Regenerate all posts and relink
470
507
  {undelete ID} Undelete a post {publish} Publish (current view)
471
508
  {edit ID} Edit a post {ssh} Login to remote server
472
- {import ASSETS} Import assets (images, etc.) {manage WIDGET} Manage content/layout of a widget
509
+ {import ASSETS} Import assets (images, etc.)
510
+
511
+
512
+ {Widgets:}
513
+ -------------------------------------------
514
+ {lsw, list widgets} List all known widgets
515
+ {install WIDGET} Install a widget
516
+ {enable WIDGET} Use widget in this view
517
+ {disable WIDGET} Don't use in this view
518
+ {update WIDGET} Update code (this view)
519
+ {manage WIDGET} Manage content/layout
520
+
473
521
  EOS
474
522
 
475
523
  def cmd_help
@@ -114,7 +114,9 @@ class RuneBlog
114
114
 
115
115
  create_dirs(repo_root)
116
116
  Dir.chdir(repo_root) do
117
- create_dirs(:data, :config, :drafts, :views, :posts)
117
+ create_dirs(:data, :config, :widgets, :drafts, :views, :posts) # ?? widgets?
118
+ # FIXME
119
+ get_all_widgets("widgets")
118
120
  new_sequence
119
121
  end
120
122
  unless File.exist?(repo_root/"data/VIEW")
@@ -361,6 +363,8 @@ class RuneBlog
361
363
  Dir.chdir(@root) do
362
364
  cmd = "cp -r #{RuneBlog::Path}/../empty_view views/#{view_name}"
363
365
  system!(cmd)
366
+ cmd = "cp -r widgets views/#{view_name}"
367
+ system!(cmd)
364
368
  end
365
369
  rescue => err
366
370
  _tmp_error(err)
@@ -621,6 +625,7 @@ class RuneBlog
621
625
  nslug = fname.sub(/.lt3$/, "") # 0001-this-is-a-post
622
626
  aslug = nslug.sub(/\d\d\d\d-/, "") # this-is-a-post
623
627
  pnum = nslug[0..3] # 0001
628
+ hash = {}
624
629
  Dir.chdir(pdraft) do
625
630
  excerpt = File.read("teaser.txt")
626
631
  meta = read_metadata
@@ -629,29 +634,12 @@ class RuneBlog
629
634
  title = meta.title
630
635
  tags = meta.tags
631
636
  # FIXME simplify
632
- vars = <<~LIVE
633
- .set post.num = #{pnum}
634
- .heredoc post.aslug
635
- #{aslug}
636
- .end
637
- .heredoc post.date
638
- #{date}
639
- .end
640
- .heredoc title
641
- #{title.chomp}
642
- .end
643
- .heredoc post.tags
644
- #{tags.join(" ")}
645
- .end
646
- .heredoc teaser
647
- #{excerpt.chomp}
648
- .end
649
- .heredoc longdate
650
- #{longdate}
651
- .end
652
- LIVE
653
- File.open(pdraft/"vars.lt3", "w") {|f| f.puts vars }
637
+ addvar(hash, "post.num" => pnum, "post.aslug" => aslug,
638
+ "post.date" => date, title: title.chomp,
639
+ "post.tags" => tags.join(" "), teaser: excerpt.chomp,
640
+ longdate: longdate)
654
641
  end
642
+ hash
655
643
  rescue => err
656
644
  _tmp_error(err)
657
645
  end
@@ -660,14 +648,14 @@ class RuneBlog
660
648
  log!(enter: __method__, level: 2)
661
649
  vdir = @root/:views/view
662
650
  remote = vdir/:remote
663
- wdir = vdir/:themes/:standard/:widgets
651
+ wdir = vdir/:widgets
664
652
  widgets = Dir[wdir/"*"].select {|w| File.directory?(w) }
665
653
  widgets.each do |w|
666
654
  dir = File.basename(w)
667
- rem = w.sub(/themes.standard/, "remote")
655
+ rem = w.sub(/widgets/, "remote/widgets")
668
656
  create_dirs(rem)
669
657
  files = Dir[w/"*"]
670
- files = files.select {|x| x =~ /(html|css)$/ }
658
+ # files = files.select {|x| x =~ /(html|css)$/ }
671
659
  tag = File.basename(w)
672
660
  files.each {|file| system!("cp #{file} #{rem}", show: (tag == "zzz")) }
673
661
  end
@@ -677,8 +665,6 @@ class RuneBlog
677
665
 
678
666
  def _handle_post(draft, view_name = self.view.to_s)
679
667
  log!(enter: __method__, args: [draft, view_name], level: 2)
680
- # break into separate methods?
681
-
682
668
  return unless _check_view?(view_name)
683
669
 
684
670
  fname = File.basename(draft) # 0001-this-is-a-post.lt3
@@ -688,22 +674,17 @@ class RuneBlog
688
674
  pdraft = @root/:posts/nslug
689
675
  remote = @root/:views/view_name/:remote
690
676
  @theme = @root/:views/view_name/:themes/:standard
691
- # Step 1...
692
- create_dirs(pdraft)
693
- # FIXME dependencies?
694
- preprocess cwd: pdraft, src: draft, dst: "guts.html",
695
- mix: "liveblog" # , debug: true
696
- _post_metadata(draft, pdraft)
697
- # Step 2...
698
- vposts = @root/:views/view_name/:posts
677
+
678
+ create_dirs(pdraft) # Step 1...
679
+ preprocess cwd: pdraft, src: draft, # FIXME dependencies?
680
+ dst: "guts.html", mix: "liveblog"
681
+ hash = _post_metadata(draft, pdraft)
682
+ vposts = @root/:views/view_name/:posts # Step 2...
699
683
  copy!(pdraft, vposts) # ??
700
- # Step 3..
701
- copy(pdraft/"guts.html", @theme/:post)
702
- copy(pdraft/"vars.lt3", @theme/:post)
703
- # Step 4...
704
- preprocess cwd: @theme/:post, src: "generate.lt3", force: true,
705
- dst: remote/ahtml, # copy: @theme/:post,
706
- call: ".nopara" # , debug: true
684
+ copy(pdraft/"guts.html", @theme/:post) # Step 3...
685
+ preprocess cwd: @theme/:post, src: "generate.lt3", # Step 4...
686
+ force: true, vars: hash,
687
+ dst: remote/ahtml, call: ".nopara"
707
688
  FileUtils.rm_f(remote/"published")
708
689
  timelog("Generated", remote/"history")
709
690
  copy_widget_html(view_name)
@@ -3,7 +3,7 @@ if !defined?(RuneBlog::Path)
3
3
  # if ! (Object.constants.include?(:RuneBlog) && RuneBlog.constants.include?(:Path))
4
4
 
5
5
  class RuneBlog
6
- VERSION = "0.3.12"
6
+ VERSION = "0.3.17"
7
7
 
8
8
  path = Gem.find_files("runeblog").grep(/runeblog-/).first
9
9
  Path = File.dirname(path)
@@ -86,6 +86,41 @@ class ::RuneBlog::Widget
86
86
  end
87
87
  end
88
88
 
89
+ def manage
90
+ dir = @blog.view.dir/"widgets/pages"
91
+ # Assume child files already generated (and list.data??)
92
+ data = dir/"list.data"
93
+ lines = _get_data?(data)
94
+ hash = {}
95
+ lines.each do |line|
96
+ url, name = line.chomp.split(",")
97
+ source = url.sub(/.html$/, ".lt3")
98
+ hash[name] = source
99
+ end
100
+ new_item = "[New page]"
101
+ num, fname = STDSCR.menu(title: "Edit page:", items: hash.keys + [new_item])
102
+ return if fname.nil?
103
+ if fname == new_item
104
+ print "Page title: "
105
+ title = RubyText.gets
106
+ title.chomp!
107
+ print "File name (.lt3): "
108
+ fname = RubyText.gets
109
+ fname << ".lt3" unless fname.end_with?(".lt3")
110
+ fhtml = fname.sub(/.lt3$/, ".html")
111
+ File.open(data, "a") {|f| f.puts "#{fhtml},#{title}" }
112
+ new_file = dir/fname
113
+ File.open(new_file, "w") do |f|
114
+ f.puts "<h1>#{title}</h1>\n\n\n "
115
+ f.puts ".backlink"
116
+ end
117
+ edit_file(new_file)
118
+ else
119
+ target = hash[fname]
120
+ edit_file(dir/target)
121
+ end
122
+ end
123
+
89
124
  def edit_menu
90
125
  end
91
126
 
@@ -20,8 +20,8 @@ spec = Gem::Specification.new do |s|
20
20
  s.authors = ["Hal Fulton"]
21
21
  s.email = 'rubyhacker@gmail.com'
22
22
  s.executables << "blog"
23
- s.add_runtime_dependency 'livetext', '~> 0.9', '>= 0.9.02'
24
- s.add_runtime_dependency 'rubytext', '~> 0.1', '>= 0.1.20'
23
+ s.add_runtime_dependency 'livetext', '~> 0.9', '>= 0.9.04'
24
+ s.add_runtime_dependency 'rubytext', '~> 0.1', '>= 0.1.21'
25
25
 
26
26
  s.add_development_dependency 'minitest', '~> 5.10', '>= 5.10.0'
27
27
 
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.12
4
+ version: 0.3.17
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-12 00:00:00.000000000 Z
11
+ date: 2020-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: livetext
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '0.9'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.9.02
22
+ version: 0.9.04
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '0.9'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 0.9.02
32
+ version: 0.9.04
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rubytext
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: '0.1'
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 0.1.20
42
+ version: 0.1.21
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: '0.1'
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 0.1.20
52
+ version: 0.1.21
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: minitest
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -142,68 +142,13 @@ files:
142
142
  - empty_view/themes/standard/post/head.lt3
143
143
  - empty_view/themes/standard/post/index.lt3
144
144
  - empty_view/themes/standard/post/permalink.lt3
145
- - empty_view/themes/standard/widgets/README
146
- - empty_view/themes/standard/widgets/ad/ad.lt3
147
- - empty_view/themes/standard/widgets/ad/ad1.png
148
- - empty_view/themes/standard/widgets/ad/ad2.png
149
- - empty_view/themes/standard/widgets/ad/ad3.png
150
- - empty_view/themes/standard/widgets/ad/ad4.png
151
- - empty_view/themes/standard/widgets/bydates/README
152
- - empty_view/themes/standard/widgets/bydates/bydates.rb
153
- - empty_view/themes/standard/widgets/bydates/card.css
154
- - empty_view/themes/standard/widgets/bydates/custom.rb
155
- - empty_view/themes/standard/widgets/bydates/main.css
156
- - empty_view/themes/standard/widgets/links/README
157
- - empty_view/themes/standard/widgets/links/card.css
158
- - empty_view/themes/standard/widgets/links/custom.rb
159
- - empty_view/themes/standard/widgets/links/links.rb
160
- - empty_view/themes/standard/widgets/links/list.data
161
- - empty_view/themes/standard/widgets/links/main.css
162
- - empty_view/themes/standard/widgets/news/README
163
- - empty_view/themes/standard/widgets/news/card.css
164
- - empty_view/themes/standard/widgets/news/custom.rb
165
- - empty_view/themes/standard/widgets/news/list.data
166
- - empty_view/themes/standard/widgets/news/main.css
167
- - empty_view/themes/standard/widgets/news/news.rb
168
- - empty_view/themes/standard/widgets/pages/README
169
- - empty_view/themes/standard/widgets/pages/card.css
170
- - empty_view/themes/standard/widgets/pages/custom.rb
171
- - empty_view/themes/standard/widgets/pages/disclaim.lt3
172
- - empty_view/themes/standard/widgets/pages/faq.lt3
173
- - empty_view/themes/standard/widgets/pages/like-dislike.lt3
174
- - empty_view/themes/standard/widgets/pages/list.data
175
- - empty_view/themes/standard/widgets/pages/local.rb
176
- - empty_view/themes/standard/widgets/pages/main.css
177
- - empty_view/themes/standard/widgets/pages/other-stuff.lt3
178
- - empty_view/themes/standard/widgets/pages/pages.rb
179
- - empty_view/themes/standard/widgets/pinned/README
180
- - empty_view/themes/standard/widgets/pinned/card.css
181
- - empty_view/themes/standard/widgets/pinned/custom.rb
182
- - empty_view/themes/standard/widgets/pinned/main.css
183
- - empty_view/themes/standard/widgets/pinned/pinned.rb
184
- - empty_view/themes/standard/widgets/search/README
185
- - empty_view/themes/standard/widgets/search/card.css
186
- - empty_view/themes/standard/widgets/search/custom.rb
187
- - empty_view/themes/standard/widgets/search/main.css
188
- - empty_view/themes/standard/widgets/search/search.rb
189
- - empty_view/themes/standard/widgets/sitemap/README
190
- - empty_view/themes/standard/widgets/sitemap/card.css
191
- - empty_view/themes/standard/widgets/sitemap/custom.rb
192
- - empty_view/themes/standard/widgets/sitemap/main.css
193
- - empty_view/themes/standard/widgets/sitemap/sitemap.rb
194
- - empty_view/themes/standard/widgets/tag-cloud/OLD-example.lt3
195
- - empty_view/themes/standard/widgets/tag-cloud/README
196
- - empty_view/themes/standard/widgets/tag-cloud/card.css
197
- - empty_view/themes/standard/widgets/tag-cloud/custom.rb
198
- - empty_view/themes/standard/widgets/tag-cloud/main.css
199
- - empty_view/themes/standard/widgets/tag-cloud/tag-cloud.lt3
200
- - empty_view/themes/standard/widgets/tag-cloud/tag-cloud.rb
201
145
  - lib/Javascript.stuff
202
146
  - lib/helpers-blog.rb
203
147
  - lib/helpers-repl.rb
204
148
  - lib/liveblog.rb
205
149
  - lib/logging.rb
206
150
  - lib/lowlevel.rb
151
+ - lib/menus.rb
207
152
  - lib/pathmagic.rb
208
153
  - lib/post.rb
209
154
  - lib/processing.rb
@@ -212,6 +157,57 @@ files:
212
157
  - lib/runeblog.rb
213
158
  - lib/runeblog_version.rb
214
159
  - lib/view.rb
160
+ - lib/widgets/README
161
+ - lib/widgets/bydates/README
162
+ - lib/widgets/bydates/bydates.rb
163
+ - lib/widgets/bydates/card.css
164
+ - lib/widgets/bydates/custom.rb
165
+ - lib/widgets/bydates/main.css
166
+ - lib/widgets/links/README
167
+ - lib/widgets/links/card.css
168
+ - lib/widgets/links/custom.rb
169
+ - lib/widgets/links/links.rb
170
+ - lib/widgets/links/list.data
171
+ - lib/widgets/links/main.css
172
+ - lib/widgets/news/README
173
+ - lib/widgets/news/card.css
174
+ - lib/widgets/news/custom.rb
175
+ - lib/widgets/news/list.data
176
+ - lib/widgets/news/main.css
177
+ - lib/widgets/news/news.rb
178
+ - lib/widgets/pages/README
179
+ - lib/widgets/pages/card.css
180
+ - lib/widgets/pages/custom.rb
181
+ - lib/widgets/pages/disclaim.lt3
182
+ - lib/widgets/pages/faq.lt3
183
+ - lib/widgets/pages/like-dislike.lt3
184
+ - lib/widgets/pages/list.data
185
+ - lib/widgets/pages/local.rb
186
+ - lib/widgets/pages/main.css
187
+ - lib/widgets/pages/other-stuff.lt3
188
+ - lib/widgets/pages/pages.rb
189
+ - lib/widgets/pinned/README
190
+ - lib/widgets/pinned/card.css
191
+ - lib/widgets/pinned/custom.rb
192
+ - lib/widgets/pinned/main.css
193
+ - lib/widgets/pinned/pinned.rb
194
+ - lib/widgets/search/README
195
+ - lib/widgets/search/card.css
196
+ - lib/widgets/search/custom.rb
197
+ - lib/widgets/search/main.css
198
+ - lib/widgets/search/search.rb
199
+ - lib/widgets/sitemap/README
200
+ - lib/widgets/sitemap/card.css
201
+ - lib/widgets/sitemap/custom.rb
202
+ - lib/widgets/sitemap/main.css
203
+ - lib/widgets/sitemap/sitemap.rb
204
+ - lib/widgets/tag-cloud/OLD-example.lt3
205
+ - lib/widgets/tag-cloud/README
206
+ - lib/widgets/tag-cloud/card.css
207
+ - lib/widgets/tag-cloud/custom.rb
208
+ - lib/widgets/tag-cloud/main.css
209
+ - lib/widgets/tag-cloud/tag-cloud.lt3
210
+ - lib/widgets/tag-cloud/tag-cloud.rb
215
211
  - test/austin.rb
216
212
  - test/fakeimage.jpg
217
213
  - test/general_test.rb
@@ -1,22 +0,0 @@
1
- . In real life, ads won't work this way...
2
-
3
- .include vars.lt3
4
-
5
- .set classname="btn btn-light float-right"
6
- .set card.title="Advertisement"
7
- .set card.text="Build your amazing website with blabla.com."
8
- . set extra="bg-dark text-white"
9
-
10
- <!-- "$ad.image" -->
11
-
12
- <div class="card $extra mb-3">
13
- <div class="card-body">
14
- <!--
15
- <h5 class="card-title">$card.title</h5>
16
- <p class="card-text">$card.text</p>
17
- <a href="javascript: void(0)" onclick="javascript:open_main('widgets/ad/ad.html')" class="$classname">Visit page</a>
18
- -->
19
- <img style="max-height: 100%; max-width: 100%" src="$ad.image"></img>
20
- </div>
21
- </div>
22
-