runeblog 0.3.26 → 0.3.28
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 +4 -4
- data/README.lt3 +8 -5
- data/README.md +3 -1
- data/bin/blog +5 -3
- data/bin/blog.rb +237 -0
- data/data/global.lt3 +1 -1
- data/empty_view/config/reddit/redpost.rb +1 -6
- data/lib/helpers-blog.rb +0 -7
- data/lib/liveblog.rb +92 -91
- data/lib/lowlevel.rb +6 -5
- data/lib/menus.rb +96 -22
- data/lib/processing.rb +6 -3
- data/lib/repl.rb +18 -25
- data/lib/runeblog.rb +32 -43
- data/lib/runeblog_version.rb +1 -1
- data/lib/view.rb +2 -2
- data/runeblog.gemspec +1 -1
- metadata +18 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0f9a3b31f1adc96704b1781f04e2eb4227ca341ebc3f118a0ead49c3be65859
|
4
|
+
data.tar.gz: 573d4f8ba2778d476b9b327e1c994863745f1d643f6b633cc771d3d4b2872af6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acaaf9714332878e5f60b26576c86286672f221717b8c66901749cf9e9e4a257baee45ec5a2fe42d1eea3c64746cd959d10bbba1b08828cb15075ca9af85ae40
|
7
|
+
data.tar.gz: 43b9c4d21d1c5d82f6c7e1b1ce291f304e1dd52f12b46b36200f4aebe2db127603b15ab1dcaca43cc8ea607a515263019abf20c4b88d8e0da620a41187639a9a
|
data/README.lt3
CHANGED
@@ -10,14 +10,16 @@
|
|
10
10
|
<li>It's based on Livetext (highly extensible Ruby-based markup)</li>
|
11
11
|
<li>It has the concept of multiple "views" for a blog</li>
|
12
12
|
<li>The multiple views are in effect multiple blogs managed with the same backend.</li>
|
13
|
+
<li>Each view may have its own "look and feel" (and even be hosted on differing domains)</li>
|
13
14
|
</ul>
|
14
15
|
|
15
16
|
|
16
17
|
|
17
18
|
.h2 What is Livetext?
|
18
19
|
|
19
|
-
Livetext is a markup format that is a throwback to the old,
|
20
|
-
formatters such as ``nroff. It's very flexible, and it is
|
20
|
+
Livetext is a markup format (media generator?) that is a throwback to the old,
|
21
|
+
old days of text formatters such as ``nroff. It's very flexible, and it is
|
22
|
+
extensible _[in Ruby].
|
21
23
|
|
22
24
|
It is far from mature or full-featured, but it is usable. Runeblog uses Livetext,
|
23
25
|
along with some custom definitions, to try to ease the formatting of a blog entry.
|
@@ -45,8 +47,8 @@ Any post can be in more than one view
|
|
45
47
|
.h2 The <tt>blog</tt> environment
|
46
48
|
|
47
49
|
There is a command-line tool called `blog which is a REPL (read-eval-print loop).
|
48
|
-
Note that this tool is a curses-based environment (mainly so it can display
|
49
|
-
and such to the user).
|
50
|
+
Note that this tool is a curses-based environment (mainly so that it can display
|
51
|
+
menus and such to the user).
|
50
52
|
|
51
53
|
The help message looks like this:
|
52
54
|
|
@@ -57,7 +59,7 @@ The help message looks like this:
|
|
57
59
|
<b>q, quit</b> Exit the program <b>cv VIEW</b> Change current view
|
58
60
|
<b>v, version</b> Print version information <b>new view</b> Create a new view
|
59
61
|
<b>clear</b> Clear screen <b>list views</b> List all views available
|
60
|
-
|
62
|
+
<b>lsv</b> Same as: list views
|
61
63
|
<br>
|
62
64
|
<b>Posts:</b> <b>Advanced:</b>
|
63
65
|
------------------------------------------- -------------------------------------------
|
@@ -82,6 +84,7 @@ You'll then enter the editor (vim for now) to add configuration info to the `glo
|
|
82
84
|
|
83
85
|
<!-- <pre><b>FIXME add menu screenshot here</b></pre> -->
|
84
86
|
<!-- <pre><b>FIXME add vim screenshot here</b></pre> -->
|
87
|
+
|
85
88
|
<img src="readme/vim-global.png" width="494" height="696" align="center"></img>
|
86
89
|
|
87
90
|
The next thing you should do is to create at least one view of your own. Use the `[new view]
|
data/README.md
CHANGED
@@ -44,6 +44,7 @@ But the important points are these:
|
|
44
44
|
* Each view can have its own look and feel, and it can be linked/published separately from the others.
|
45
45
|
* Each view can be hosted in a different location and/or a different server and domain
|
46
46
|
* Any post can be in more than one view
|
47
|
+
|
47
48
|
## The <tt>blog</tt> environment
|
48
49
|
There is a command-line tool called <font size=+1><tt>blog</tt></font> which is a REPL (read-eval-print loop).
|
49
50
|
Note that this tool is a curses-based environment (mainly so it can display menus
|
@@ -60,7 +61,7 @@ The help message looks like this:
|
|
60
61
|
<b>q, quit</b> Exit the program <b>cv VIEW</b> Change current view
|
61
62
|
<b>v, version</b> Print version information <b>new view</b> Create a new view
|
62
63
|
<b>clear</b> Clear screen <b>list views</b> List all views available
|
63
|
-
|
64
|
+
<b>lsv</b> Same as: list views
|
64
65
|
<br>
|
65
66
|
<b>Posts:</b> <b>Advanced:</b>
|
66
67
|
------------------------------------------- -------------------------------------------
|
@@ -73,6 +74,7 @@ The help message looks like this:
|
|
73
74
|
<b>edit ID</b> Edit a post <b>ssh</b> Login to remote server
|
74
75
|
<b>import ASSETS</b> Import assets (images, etc.) <b>manage WIDGET</b> Manage content/layout of a widget
|
75
76
|
</pre>
|
77
|
+
|
76
78
|
## Getting started
|
77
79
|
But when you first run the REPL, it checks for an existing blog repository under
|
78
80
|
the <font size=+1><tt>.blogs</tt></font> directory. If it doesn't find one, it asks whether you want to create
|
data/bin/blog
CHANGED
@@ -87,7 +87,7 @@ def get_started
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def mainloop
|
90
|
-
info = @blog.view
|
90
|
+
info = @blog.view.name rescue "No view"
|
91
91
|
print fx("[#{info}] ", Red, :bold)
|
92
92
|
cmd = STDSCR.gets(history: @cmdhist, tab: @tabcom, capture: [" "])
|
93
93
|
case cmd
|
@@ -107,6 +107,8 @@ def mainloop
|
|
107
107
|
puts "Don't understand '#{cmd.inspect}'\n "
|
108
108
|
end
|
109
109
|
rescue => err
|
110
|
+
# puts "----- ML_RESCUE err = #{err.inspect} VIEW = #{@blog.view.inspect}"
|
111
|
+
puts "----- ML_RESCUE err = #{err.inspect} "
|
110
112
|
log!(str: err.to_s)
|
111
113
|
log!(str: err.backtrace.join("\n")) if err.respond_to?(:backtrace)
|
112
114
|
puts "Current dir = #{Dir.pwd}"
|
@@ -148,7 +150,7 @@ end
|
|
148
150
|
|
149
151
|
def handle_cmdline
|
150
152
|
cmd = ARGV[0]
|
151
|
-
@blog = RuneBlog.new
|
153
|
+
@blog = RuneBlog.read # was .new
|
152
154
|
abort "No blog found" if @blog.nil?
|
153
155
|
|
154
156
|
case cmd
|
@@ -197,7 +199,7 @@ def create_new_repo?
|
|
197
199
|
new_repo = true
|
198
200
|
end
|
199
201
|
|
200
|
-
@blog = RuneBlog.new
|
202
|
+
@blog = RuneBlog.read # was .new
|
201
203
|
get_started if new_repo
|
202
204
|
rescue => err
|
203
205
|
STDERR.puts "Error - #{err.to_s}"
|
data/bin/blog.rb
ADDED
@@ -0,0 +1,237 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# $LOAD_PATH << "./lib"
|
4
|
+
|
5
|
+
require 'runeblog'
|
6
|
+
require 'rubytext'
|
7
|
+
|
8
|
+
require 'menus'
|
9
|
+
|
10
|
+
require 'repl'
|
11
|
+
|
12
|
+
include RuneBlog::REPL
|
13
|
+
|
14
|
+
def yesno(question, noskip=false)
|
15
|
+
puts fx("\n #{question}", :bold)
|
16
|
+
puts unless noskip
|
17
|
+
STDSCR.yesno
|
18
|
+
end
|
19
|
+
|
20
|
+
def pick_editor
|
21
|
+
choices = %w[vim emacs vi nano]
|
22
|
+
r, c = STDSCR.rc
|
23
|
+
num, name = STDSCR.menu(r: r, c: c+6, title: "Default editor", items: choices)
|
24
|
+
file = `which #{name}`.chomp
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_universal
|
28
|
+
univ = "#{@blog.root}/data/universal.lt3"
|
29
|
+
if yesno("Faster initial setup? (no: edit universal.lt3)")
|
30
|
+
# author = ask!(" Author name: ")
|
31
|
+
# site = ask!(" Site/domain: ")
|
32
|
+
# Temporarily, for speed:
|
33
|
+
author, site = "Hal Fulton", "somedomain.com"
|
34
|
+
puts " Author name: #{author}"
|
35
|
+
puts " Site/domain: #{site}"
|
36
|
+
# Now stash it...
|
37
|
+
str = File.read(univ)
|
38
|
+
str = str.gsub(/AUTHOR/, author)
|
39
|
+
str = str.gsub(/SITE_DOMAIN/, site)
|
40
|
+
File.write(univ, str)
|
41
|
+
else
|
42
|
+
vim_params = '-c ":set hlsearch" -c ":hi Search ctermfg=2 ctermbg=6" +/"\(AUTHOR.*\|SITE.*\)"'
|
43
|
+
edit_file(univ, vim: vim_params)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def get_global
|
48
|
+
view_name = ask!(" Filename: ")
|
49
|
+
@blog.create_view(view_name) # call change_view??
|
50
|
+
if yesno("Faster view setup? (no: edit global.lt3)")
|
51
|
+
title = ask!(" View title: ")
|
52
|
+
subtitle = ask!(" Subtitle : ")
|
53
|
+
domain = ask!(" Domain : ")
|
54
|
+
modify_view_global(view_name)
|
55
|
+
modify_view_settings(name: view_name, title: title, subtitle: subtitle,
|
56
|
+
domain: domain)
|
57
|
+
else
|
58
|
+
vim_params = '-c ":set hlsearch" -c ":hi Search ctermfg=2 ctermbg=6" +/"\(VIEW_.*\|SITE.*\)"'
|
59
|
+
edit_file(@blog.view.dir/"themes/standard/global.lt3", vim: vim_params)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def get_started
|
64
|
+
if yesno("Do you want to qo a quick setup?")
|
65
|
+
puts " First choose your editor."
|
66
|
+
@blog.editor = pick_editor
|
67
|
+
File.write("#{@blog.root}/data/EDITOR", @blog.editor)
|
68
|
+
print " Default editor is "
|
69
|
+
puts fx(@blog.editor, :bold)
|
70
|
+
|
71
|
+
get_universal
|
72
|
+
# Now create a custom global.lt3
|
73
|
+
@blog._generate_global
|
74
|
+
puts fx("\n Quick setup complete!", :bold)
|
75
|
+
if yesno("Create your first view now?")
|
76
|
+
get_global
|
77
|
+
puts fx("\n View #{@blog.view} created!\n ", :bold)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
print fx(" For help", :bold); puts " type h or help."
|
82
|
+
print fx(" Create a view", :bold); puts " with: new view"
|
83
|
+
print fx(" Create a post", :bold); puts " (within current view): new post"
|
84
|
+
end
|
85
|
+
|
86
|
+
def mainloop
|
87
|
+
info = @blog.view || "no view"
|
88
|
+
print fx("[#{info}] ", Red, :bold)
|
89
|
+
cmd = STDSCR.gets(history: @cmdhist, tab: @tabcom, capture: [" "]).chomp
|
90
|
+
case cmd
|
91
|
+
when " ", RubyText::Keys::Escape
|
92
|
+
Dir.chdir(@blog.view.dir)
|
93
|
+
show_top_menu
|
94
|
+
puts
|
95
|
+
return
|
96
|
+
when RubyText::Keys::CtlD # ^D
|
97
|
+
cmd_quit
|
98
|
+
when String
|
99
|
+
return if cmd.empty? # CR does nothing
|
100
|
+
invoking = RuneBlog::REPL.choose_method(cmd)
|
101
|
+
ret = send(*invoking)
|
102
|
+
else
|
103
|
+
puts "Don't understand '#{cmd.inspect}'\n "
|
104
|
+
end
|
105
|
+
rescue => err
|
106
|
+
log!(str: err.to_s)
|
107
|
+
log!(str: err.backtrace.join("\n")) if err.respond_to?(:backtrace)
|
108
|
+
puts "Current dir = #{Dir.pwd}"
|
109
|
+
puts err
|
110
|
+
puts err.backtrace.join("\n")
|
111
|
+
puts "Pausing..."; gets
|
112
|
+
end
|
113
|
+
|
114
|
+
def cmdline_preview
|
115
|
+
_need_view
|
116
|
+
local = @blog.view.local_index
|
117
|
+
result = system("open #{local}")
|
118
|
+
end
|
119
|
+
|
120
|
+
def cmdline_publish
|
121
|
+
abort "Not implemented yet"
|
122
|
+
_need_view
|
123
|
+
end
|
124
|
+
|
125
|
+
def cmdline_browse
|
126
|
+
abort "Not implemented yet"
|
127
|
+
_need_view
|
128
|
+
end
|
129
|
+
|
130
|
+
def _need_view
|
131
|
+
@view = ARGV[1]
|
132
|
+
abort "Need 'view' parameter" if @view.nil?
|
133
|
+
abort "No such view '#{view}'" unless @blog.view?(@view)
|
134
|
+
end
|
135
|
+
|
136
|
+
def cmdline_rebuild
|
137
|
+
_need_view
|
138
|
+
print "Generating view... "
|
139
|
+
@blog.generate_view(@view)
|
140
|
+
print "Generating index... "
|
141
|
+
num = @blog.generate_index(@view)
|
142
|
+
puts "#{num} posts\n "
|
143
|
+
end
|
144
|
+
|
145
|
+
def handle_cmdline
|
146
|
+
cmd = ARGV[0]
|
147
|
+
@blog = RuneBlog.new
|
148
|
+
abort "No blog found" if @blog.nil?
|
149
|
+
|
150
|
+
case cmd
|
151
|
+
when "rebuild"; cmdline_rebuild
|
152
|
+
when "publish"; cmdline_publish
|
153
|
+
when "preview"; cmdline_preview
|
154
|
+
when "browse"; cmdline_browse
|
155
|
+
else
|
156
|
+
puts "Command '#{cmd}' is unknown"
|
157
|
+
end
|
158
|
+
exit
|
159
|
+
end
|
160
|
+
|
161
|
+
def check_ruby_version
|
162
|
+
major, minor = RUBY_VERSION.split(".").values_at(0,1)
|
163
|
+
ver = major.to_i*10 + minor.to_i
|
164
|
+
unless ver >= 24
|
165
|
+
RubyText.stop
|
166
|
+
sleep 0.2
|
167
|
+
puts "Needs Ruby 2.4 or greater"
|
168
|
+
exit
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def reopen_stderr
|
173
|
+
errfile = File.new("stderr.out", "w")
|
174
|
+
STDERR.reopen(errfile)
|
175
|
+
end
|
176
|
+
|
177
|
+
def set_fgbg
|
178
|
+
# read a .rubytext file here?? Call it something else?
|
179
|
+
home = ENV['HOME']
|
180
|
+
@fg, @bg = Blue, White ## FIXME!! try_read_config("#{home}/.rubytext", fg: Blue, bg: White)
|
181
|
+
@fg = @fg.downcase.to_sym
|
182
|
+
@bg = @bg.downcase.to_sym
|
183
|
+
|
184
|
+
RubyText.start(:_echo, :keypad, scroll: true, log: "binblog.txt", fg: @fg, bg: @bg)
|
185
|
+
end
|
186
|
+
|
187
|
+
def create_new_repo?
|
188
|
+
new_repo = false
|
189
|
+
if ! RuneBlog.exist?
|
190
|
+
exit unless yesno("No blog repo found. Create new one?")
|
191
|
+
RuneBlog.create_new_blog_repo
|
192
|
+
puts fx(" Blog repo successfully created.", :bold)
|
193
|
+
new_repo = true
|
194
|
+
end
|
195
|
+
|
196
|
+
@blog = RuneBlog.new
|
197
|
+
get_started if new_repo
|
198
|
+
rescue => err
|
199
|
+
STDERR.puts "Error - #{err.to_s}"
|
200
|
+
STDERR.puts err.backtrace if err.respond_to?(:backtrace)
|
201
|
+
end
|
202
|
+
|
203
|
+
def print_intro
|
204
|
+
print fx(" For help", :bold)
|
205
|
+
puts " type h or help.\n "
|
206
|
+
|
207
|
+
puts fx("\n RuneBlog", :bold), fx(" v #{RuneBlog::VERSION}\n", Red)
|
208
|
+
end
|
209
|
+
|
210
|
+
def cmd_history_etc
|
211
|
+
@cmdhist = []
|
212
|
+
@tabcom = RuneBlog::REPL::Patterns.keys.uniq - RuneBlog::REPL::Abbr.keys
|
213
|
+
@tabcom.map! {|x| x.sub(/ [\$\>].*/, "") + " " }
|
214
|
+
@tabcom.sort!
|
215
|
+
end
|
216
|
+
|
217
|
+
def exit_repl
|
218
|
+
# RubyText.stop
|
219
|
+
sleep 0.2
|
220
|
+
puts
|
221
|
+
end
|
222
|
+
|
223
|
+
### Main
|
224
|
+
|
225
|
+
include RuneBlog::Helpers # for try_read_config
|
226
|
+
|
227
|
+
reopen_stderr
|
228
|
+
check_ruby_version
|
229
|
+
|
230
|
+
handle_cmdline unless ARGV.empty?
|
231
|
+
set_fgbg
|
232
|
+
print_intro
|
233
|
+
create_new_repo?
|
234
|
+
|
235
|
+
cmd_history_etc
|
236
|
+
loop { mainloop }
|
237
|
+
exit_repl
|
data/data/global.lt3
CHANGED
@@ -2,15 +2,12 @@ app_name = "raido1"
|
|
2
2
|
app_client = "rAyZILgqGB7uHQ"
|
3
3
|
secret = "0CqLXyFu6ABb1MrErWRsB7Bo-i8"
|
4
4
|
|
5
|
-
https://www.reddit.com/api/v1/authorize?client_id=rAyZILgqGB7uHQ&response_type=code&state=abc237def&redirect_uri=http%3A%2F%2Frubyhacker.com&duration=permanent&scope=identity%20edit%20flair%20history%20modconfig%20modflair%20modlog%20modposts%20modwiki%20mysubreddits%20privatemessages%20read%20report%20save%20submit%20subscribe%20vote%20wikiedit%20wikiread
|
6
|
-
|
7
|
-
|
5
|
+
# https://www.reddit.com/api/v1/authorize?client_id=rAyZILgqGB7uHQ&response_type=code&state=abc237def&redirect_uri=http%3A%2F%2Frubyhacker.com&duration=permanent&scope=identity%20edit%20flair%20history%20modconfig%20modflair%20modlog%20modposts%20modwiki%20mysubreddits%20privatemessages%20read%20report%20save%20submit%20subscribe%20vote%20wikiedit%20wikiread
|
8
6
|
|
9
7
|
require 'net/http'
|
10
8
|
require 'uri'
|
11
9
|
require 'json'
|
12
10
|
|
13
|
-
|
14
11
|
=begin
|
15
12
|
get_token = URI.parse("https://www.reddit.com/api/v1/access_token")
|
16
13
|
data = {
|
@@ -20,8 +17,6 @@ data = {
|
|
20
17
|
}
|
21
18
|
=end
|
22
19
|
|
23
|
-
|
24
|
-
|
25
20
|
uri = URI.parse("http://reddit.com/api/submit")
|
26
21
|
|
27
22
|
header = {'Content-Type': 'text/json'}
|
data/lib/helpers-blog.rb
CHANGED
@@ -24,7 +24,6 @@ module RuneBlog::Helpers
|
|
24
24
|
dir = root/:views/view/:settings
|
25
25
|
end
|
26
26
|
file = dir/"features.txt"
|
27
|
-
# puts "-- in #{Dir.pwd} trying to read #{file}"
|
28
27
|
pairs = read_pairs(file)
|
29
28
|
enabled = {}
|
30
29
|
pairs.each {|k,v| enabled[k] = (v == "1") }
|
@@ -108,12 +107,6 @@ module RuneBlog::Helpers
|
|
108
107
|
stop_RubyText rescue nil
|
109
108
|
end
|
110
109
|
|
111
|
-
def retrieve_views # read from filesystem
|
112
|
-
log!(enter: __method__, level: 3)
|
113
|
-
dirs = subdirs("#@root/views/").sort
|
114
|
-
dirs.map {|name| RuneBlog::View.new(name) }
|
115
|
-
end
|
116
|
-
|
117
110
|
def write_repo_config(root: "#{Dir.pwd}/.blogs", view: nil, editor: "/usr/local/bin/vim")
|
118
111
|
view ||= File.read("#{root}/data/VIEW").chomp rescue "[no view]"
|
119
112
|
File.write(root + "/data/ROOT", root + "\n")
|