runeblog 0.1.12 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/blog +7 -33
- data/lib/default.rb +89 -3
- data/lib/global.rb +13 -0
- data/lib/helpers-blog.rb +5 -5
- data/lib/helpers-repl.rb +6 -3
- data/lib/post.rb +47 -29
- data/lib/publish.rb +10 -2
- data/lib/repl.rb +44 -58
- data/lib/runeblog.rb +59 -29
- data/lib/version.rb +1 -1
- data/test/general.rb +44 -15
- data/test/make_blog.rb +6 -3
- 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: 36cbc21ab4f6f91bd7a64ce69394afee995e95450702aaedb39b0fc6ce2987f3
|
4
|
+
data.tar.gz: 9973a1a4cba61e6578ef2255993ddf104023f56b3281a789098daf85f7ed7c10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 222962f37116d5517ac776b6010d314a5d69e61f32858859b67b0f498d479e1dac339ac83289d0017613b1e8acdac541bd136922db163092a9dec5d03a0205dd
|
7
|
+
data.tar.gz: ffa549c4d4227724ccefda65d969b3a526b24d9882c3d6b4f5a123b0b847b3ad03e3929741823ff9f50260cec94d461b8c81f9512a5d18975a5ac27a44bca435
|
data/bin/blog
CHANGED
@@ -7,17 +7,8 @@ require 'rubytext'
|
|
7
7
|
|
8
8
|
require 'repl'
|
9
9
|
|
10
|
-
# trap("INT") { }
|
11
|
-
|
12
10
|
include RuneBlog::REPL
|
13
11
|
|
14
|
-
def get_argv
|
15
|
-
return nil if ARGV.size == 0
|
16
|
-
cmd = ARGV[0..1].join(" ")
|
17
|
-
arg = ARGV[2]
|
18
|
-
[cmd, arg]
|
19
|
-
end
|
20
|
-
|
21
12
|
def mainloop
|
22
13
|
print fx("blog> ", Red)
|
23
14
|
cmd = STDSCR.gets(history: @cmdhist)
|
@@ -31,15 +22,10 @@ rescue => err
|
|
31
22
|
puts err
|
32
23
|
end
|
33
24
|
|
34
|
-
|
35
|
-
###########
|
25
|
+
###
|
36
26
|
|
37
27
|
RubyText.start(:_echo, :keypad, scroll: true, log: "blogcmd.txt", fg: Blue, bg: White)
|
38
28
|
|
39
|
-
# STDOUT.sync = true
|
40
|
-
|
41
|
-
cmd, arg = get_argv
|
42
|
-
|
43
29
|
if ! RuneBlog.exist?
|
44
30
|
print "No blog found. Create new one? (y/n) "
|
45
31
|
resp = gets.chomp
|
@@ -52,22 +38,10 @@ end
|
|
52
38
|
|
53
39
|
@blog = RuneBlog.new
|
54
40
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
sleep 0.2
|
62
|
-
system("tput clear")
|
63
|
-
puts
|
64
|
-
else # one command
|
65
|
-
file = File.open("/dev/tty")
|
66
|
-
STDIN.reopen(file) # avoid ARGF dumbness
|
67
|
-
cmd = ARGV.join(" ")
|
68
|
-
meth, params = RuneBlog::REPL.choose_method(cmd)
|
69
|
-
str = send(meth, params)
|
70
|
-
puts str unless str.nil?
|
71
|
-
puts
|
72
|
-
end
|
41
|
+
puts fx("\n RuneBlog", :bold), fx(" v #{RuneBlog::VERSION}\n", Red)
|
42
|
+
@cmdhist = []
|
43
|
+
loop { mainloop }
|
44
|
+
sleep 0.2
|
45
|
+
system("tput clear")
|
46
|
+
puts
|
73
47
|
|
data/lib/default.rb
CHANGED
@@ -33,12 +33,98 @@ BlogTrailer = <<-TEXT
|
|
33
33
|
<!-- no blog trailer -->
|
34
34
|
TEXT
|
35
35
|
|
36
|
+
def RuneBlog.post_template(title: "No title", date: nil, view: "test_view",
|
37
|
+
teaser: "No teaser", body: "No body")
|
38
|
+
<<-TEXT
|
39
|
+
.mixin liveblog
|
40
|
+
|
41
|
+
.title #{title}
|
42
|
+
.pubdate #{date}
|
43
|
+
.views #{view}
|
44
|
+
.tags
|
45
|
+
|
46
|
+
.teaser
|
47
|
+
#{teaser}
|
48
|
+
.end
|
49
|
+
#{body}
|
50
|
+
TEXT
|
51
|
+
end
|
52
|
+
|
53
|
+
def RuneBlog.teaser_template(title: "No title", date: nil, view: "test_view",
|
54
|
+
teaser: "No teaser", body: "No body", slug: nil)
|
55
|
+
<<-TEXT
|
56
|
+
<html>
|
57
|
+
|
58
|
+
<body>
|
59
|
+
|
60
|
+
<script>
|
61
|
+
window.fbAsyncInit = function() {
|
62
|
+
FB.init({
|
63
|
+
appId : '1176481582378716',
|
64
|
+
xfbml : true,
|
65
|
+
version : 'v2.4'
|
66
|
+
});
|
67
|
+
};
|
68
|
+
|
69
|
+
(function(d, s, id){
|
70
|
+
var js, fjs = d.getElementsByTagName(s)[0];
|
71
|
+
if (d.getElementById(id)) {return;}
|
72
|
+
js = d.createElement(s); js.id = id;
|
73
|
+
js.src = '//connect.facebook.net/en_US/sdk.js';
|
74
|
+
fjs.parentNode.insertBefore(js, fjs);
|
75
|
+
}(document, 'script', 'facebook-jssdk'));
|
76
|
+
</script>
|
77
|
+
<!-- meta property='fb:admins' content='767352779' /> -->
|
78
|
+
<meta property='og:url' content='http://rubyhacker.com/blog2/#{slug}.html'/>
|
79
|
+
<meta property='og:type' content='article'/>
|
80
|
+
<meta property='og:title' content='#{title}'/>
|
81
|
+
<meta property='og:image' content='http://rubyhacker.com/blog2/blog3b.gif'/>
|
82
|
+
<meta property='og:description' content='#{teaser}'/>
|
83
|
+
|
84
|
+
<table bgcolor=#eeeeee cellspacing=5>
|
85
|
+
<tr>
|
86
|
+
<td valign=top>
|
87
|
+
<br> <font size=+2 color=red>#{title}</font> <br> #{date}
|
88
|
+
</td>
|
89
|
+
<td width=2% bgcolor=red></td>
|
90
|
+
<td valign=top>
|
91
|
+
<a href='https://twitter.com/share'
|
92
|
+
class='twitter-share-button'
|
93
|
+
data-text='#{title}'
|
94
|
+
data-url='#{'url'}'
|
95
|
+
data-via='hal_fulton'
|
96
|
+
data-related='hal_fulton'>Tweet</a>
|
97
|
+
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
|
98
|
+
<br>
|
99
|
+
<a href='https://twitter.com/hal_fulton' class='twitter-follow-button' data-show-count='false'>Follow @hal_fulton</a>
|
100
|
+
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
|
101
|
+
|
102
|
+
<br>
|
103
|
+
<div
|
104
|
+
class='fb-like'
|
105
|
+
data-share='true'
|
106
|
+
data-width='450'
|
107
|
+
data-show-faces='true'>
|
108
|
+
</div>
|
109
|
+
</td>
|
110
|
+
</tr>
|
111
|
+
</table>
|
112
|
+
<hr>
|
113
|
+
|
114
|
+
#{body}
|
115
|
+
|
116
|
+
<hr>
|
117
|
+
<a href="http://rubyhacker.com/blog2" style="text-decoration: none">Back</a>
|
118
|
+
<a href="http://rubyhacker.com" style="text-decoration: none">Home</a>
|
119
|
+
TEXT
|
120
|
+
end
|
121
|
+
|
36
122
|
PostTemplate = <<-'TEXT' # interpolate later
|
37
123
|
.mixin liveblog
|
38
124
|
|
39
|
-
.title
|
40
|
-
.pubdate
|
41
|
-
.views
|
125
|
+
.title #{@meta.title}
|
126
|
+
.pubdate #{@meta.date}
|
127
|
+
.views #{@meta.view}
|
42
128
|
.tags
|
43
129
|
|
44
130
|
.teaser
|
data/lib/global.rb
CHANGED
@@ -31,3 +31,16 @@ def prefix(num)
|
|
31
31
|
"#{'%04d' % num.to_i}"
|
32
32
|
end
|
33
33
|
|
34
|
+
def check_meta(meta, where = "")
|
35
|
+
str = "--- #{where}\n"
|
36
|
+
str << "\ncheck_meta: \n" + caller.join("\n") + "\n meta = #{meta.inspect}\n"
|
37
|
+
str << " title missing!\n" unless meta.title
|
38
|
+
str << " title missing! (empty)" if meta.title && meta.title.empty?
|
39
|
+
str << " num missing!\n" unless meta.num
|
40
|
+
if str =~ /missing!/
|
41
|
+
debug str
|
42
|
+
exit
|
43
|
+
raise str
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
data/lib/helpers-blog.rb
CHANGED
@@ -18,8 +18,8 @@ module RuneBlog::Helpers
|
|
18
18
|
end
|
19
19
|
return vals
|
20
20
|
rescue => err
|
21
|
-
puts "Something hit the fan: #{err}"
|
22
|
-
puts err.backtrace.join("\n")
|
21
|
+
puts "Something hit the fan: #{err}"
|
22
|
+
puts err.backtrace.join("\n")
|
23
23
|
puts "dir = #{Dir.pwd}"
|
24
24
|
exit
|
25
25
|
end
|
@@ -57,7 +57,7 @@ module RuneBlog::Helpers
|
|
57
57
|
dirs.reject! {|x| ! File.directory?("#@root/views/#{x}") }
|
58
58
|
dirs
|
59
59
|
rescue
|
60
|
-
STDERR.puts "Can't find dir '#{dir}'"
|
60
|
+
STDERR.puts "Can't find dir '#{dir}'"
|
61
61
|
exit
|
62
62
|
end
|
63
63
|
|
@@ -82,8 +82,8 @@ module RuneBlog::Helpers
|
|
82
82
|
|
83
83
|
def error(err) # Hmm, this is duplicated
|
84
84
|
str = "\n Error: #{err}"
|
85
|
-
puts str
|
86
|
-
puts err.backtrace.join("\n")
|
85
|
+
puts str
|
86
|
+
puts err.backtrace.join("\n")
|
87
87
|
end
|
88
88
|
|
89
89
|
def dump(obj, name)
|
data/lib/helpers-repl.rb
CHANGED
@@ -149,7 +149,9 @@ module RuneBlog::REPL
|
|
149
149
|
|
150
150
|
def ask(prompt, meth = :to_s)
|
151
151
|
print prompt
|
152
|
-
gets
|
152
|
+
str = gets
|
153
|
+
str.chomp!
|
154
|
+
str.send(meth)
|
153
155
|
end
|
154
156
|
|
155
157
|
def yesno(prompt, meth = :to_s)
|
@@ -224,7 +226,7 @@ module RuneBlog::REPL
|
|
224
226
|
name = arg
|
225
227
|
grep = `grep ^.title #{name}`
|
226
228
|
@title = grep.sub(/^.title /, "")
|
227
|
-
@slug = @blog.make_slug(@title)
|
229
|
+
@slug = @blog.make_slug(@title) # import (not impl)
|
228
230
|
@fname = @slug + ".lt3"
|
229
231
|
result = system("cp #{name} #@root/src/#@fname")
|
230
232
|
raise CantCopy(name, "#@root/src/#@fname") unless result
|
@@ -278,7 +280,8 @@ module RuneBlog::REPL
|
|
278
280
|
search_path = proc do |path|
|
279
281
|
full_path = path + asset_name
|
280
282
|
return full_path if File.exist?(full_path)
|
281
|
-
end
|
283
|
+
end
|
284
|
+
check_meta(@meta, "find_asset")
|
282
285
|
views = @meta.views
|
283
286
|
views.each do |view| search_path.call("#{view.dir}/#{@meta.slug}/assets/") end
|
284
287
|
views.each do |view| search_path.call(view.dir + "/assets/") end
|
data/lib/post.rb
CHANGED
@@ -5,7 +5,7 @@ make_exception(:NoBlogAccessor, "Runeblog.blog is not set")
|
|
5
5
|
|
6
6
|
class RuneBlog::Post
|
7
7
|
|
8
|
-
attr_reader :
|
8
|
+
attr_reader :num, :title, :date, :views, :num, :slug
|
9
9
|
|
10
10
|
include RuneBlog::Helpers
|
11
11
|
|
@@ -27,75 +27,93 @@ class RuneBlog::Post
|
|
27
27
|
meta.tags = meta.tags.split
|
28
28
|
meta.teaser = File.read("teaser.txt")
|
29
29
|
meta.body = File.read("body.txt")
|
30
|
+
check_meta(meta, "Post.load")
|
30
31
|
end
|
31
32
|
meta
|
32
33
|
end
|
33
34
|
|
34
35
|
def initialize(meta, view_name)
|
35
36
|
# FIXME weird logic here
|
36
|
-
|
37
|
-
@blog
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
@blog = RuneBlog.blog || raise(NoBlogAccessor)
|
38
|
+
@blog.make_slug(meta) # Post#initialize
|
39
|
+
meta.pubdate = Time.now.strftime("%Y-%m-%d")
|
40
|
+
meta.date = meta.pubdate # fix later
|
41
|
+
meta.views = [view_name]
|
42
|
+
check_meta(meta, "Post#initialize")
|
43
|
+
html = RuneBlog.post_template(title: meta.title, date: meta.pubdate,
|
44
|
+
view: meta.view, teaser: meta.teaser,
|
45
|
+
body: meta.body)
|
46
|
+
slug = meta.slug
|
43
47
|
@meta = meta
|
44
|
-
|
45
|
-
@draft = "#{@blog.root}/src/#@slug.lt3"
|
48
|
+
@draft = "#{@blog.root}/src/#{slug}.lt3"
|
46
49
|
dump(html, @draft)
|
50
|
+
rescue => err
|
51
|
+
puts err
|
52
|
+
puts err.backtrace
|
47
53
|
end
|
48
54
|
|
49
55
|
def edit
|
50
|
-
result = system("vi #@draft +8")
|
56
|
+
result = system("vi #@draft +8") # TODO improve this
|
51
57
|
raise EditorProblem(draft) unless result
|
52
58
|
nil
|
53
59
|
rescue => err
|
54
60
|
error(err)
|
55
61
|
end
|
56
62
|
|
57
|
-
def build
|
63
|
+
def build(meta=nil)
|
64
|
+
meta = @meta # FIXME
|
65
|
+
check_meta(meta, "Post.build")
|
58
66
|
livetext = Livetext.new(STDOUT)
|
59
|
-
|
60
|
-
|
67
|
+
puts "build: meta = #{meta.inspect}"
|
68
|
+
views = meta.views
|
69
|
+
@meta2 = livetext.process_file(@draft, binding)
|
70
|
+
@meta2.num = meta.num # dumb?
|
71
|
+
@meta2.views = views # extra dumb
|
72
|
+
check_meta(@meta2, "build2")
|
73
|
+
raise LivetextError(@draft) if @meta2.nil?
|
74
|
+
|
75
|
+
puts "build: cp 2 - meta2 = #{@meta2.inspect}"
|
76
|
+
|
77
|
+
# Hmm. @meta2 differs from meta -- views, etc.
|
61
78
|
|
62
79
|
# FIXME what if title changes?
|
63
80
|
|
64
|
-
@
|
81
|
+
@meta2.views.each do |view_name| # Create dir using slug (index.html, metadata?)
|
82
|
+
puts "build: cp 3 - view = #{view_name}"
|
65
83
|
view = @blog.str2view(view_name)
|
66
84
|
vdir = view.dir
|
67
|
-
dir = vdir +
|
85
|
+
dir = vdir + meta.slug + "/"
|
68
86
|
Dir.mkdir(dir)
|
69
87
|
Dir.chdir(dir) do
|
88
|
+
puts "build: cp 4 - view = #{view_name}"
|
70
89
|
create_post_subtree(vdir)
|
90
|
+
puts "build: cp 5 - view = #{view_name}"
|
71
91
|
@blog.generate_index(view)
|
92
|
+
puts "build: cp 6 - view = #{view_name}"
|
72
93
|
end
|
73
94
|
end
|
74
95
|
rescue => err
|
75
|
-
p err
|
76
|
-
puts err.backtrace.join("\n")
|
96
|
+
p err
|
97
|
+
puts err.backtrace.join("\n")
|
77
98
|
end
|
78
99
|
|
79
100
|
private
|
80
101
|
|
81
102
|
def create_post_subtree(vdir)
|
82
103
|
create_dir("assets")
|
83
|
-
|
84
|
-
|
85
|
-
|
104
|
+
check_meta(@meta2, "create_post_subtree")
|
105
|
+
write_metadata(@meta2)
|
106
|
+
meta = @meta2
|
107
|
+
text = RuneBlog.teaser_template(title: meta.title, date: meta.date,
|
108
|
+
view: meta.view, teaser: meta.teaser,
|
109
|
+
body: meta.body)
|
86
110
|
dump(text, "index.html") # FIXME write_index ?
|
87
111
|
end
|
88
112
|
|
89
|
-
def make_slug(postnum = nil)
|
90
|
-
postnum ||= @blog.next_sequence
|
91
|
-
num = prefix(postnum) # FIXME can do better
|
92
|
-
slug = @title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
|
93
|
-
[postnum, "#{num}-#{slug}"]
|
94
|
-
end
|
95
|
-
|
96
113
|
def write_metadata(meta)
|
97
114
|
fname2 = "metadata.txt"
|
98
115
|
hash = meta.to_h
|
116
|
+
debug "write_meta: #{hash.inspect}"
|
99
117
|
|
100
118
|
File.write("teaser.txt", hash[:teaser])
|
101
119
|
File.write("body.txt", hash[:body])
|
@@ -105,7 +123,7 @@ class RuneBlog::Post
|
|
105
123
|
hash[:views] = hash[:views].join(" ")
|
106
124
|
hash[:tags] = hash[:tags].join(" ")
|
107
125
|
|
108
|
-
fields = [:title, :date, :pubdate, :views, :tags]
|
126
|
+
fields = [:num, :title, :date, :pubdate, :views, :tags]
|
109
127
|
|
110
128
|
f2 = File.new(fname2, "w")
|
111
129
|
fields.each do |fld|
|
data/lib/publish.rb
CHANGED
@@ -30,8 +30,13 @@ class RuneBlog::Publishing
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def publish(files)
|
33
|
-
debug "files = #{files.inspect}"
|
34
33
|
reset_output
|
34
|
+
if files.empty?
|
35
|
+
puts "\n No files to publish"
|
36
|
+
output! "\n No files to publish"
|
37
|
+
return @out
|
38
|
+
end
|
39
|
+
debug "files = #{files.inspect}"
|
35
40
|
dir = "#@docroot/#@path"
|
36
41
|
result = system("ssh #@user@#@server -x mkdir -p #{dir}")
|
37
42
|
list = files.join(' ')
|
@@ -39,7 +44,10 @@ class RuneBlog::Publishing
|
|
39
44
|
output! "Publishing #{files.size} files...\n"
|
40
45
|
debug "cmd = #{cmd.inspect} - see /tmp/wtf"
|
41
46
|
result = system(cmd)
|
42
|
-
|
47
|
+
if not result
|
48
|
+
debug "error = #{File.read("/tmp/wtf")}"
|
49
|
+
raise PublishError
|
50
|
+
end
|
43
51
|
|
44
52
|
dump(files, "#{@blog.view.dir}/last_published")
|
45
53
|
output! "...finished.\n"
|
data/lib/repl.rb
CHANGED
@@ -14,7 +14,7 @@ module RuneBlog::REPL
|
|
14
14
|
STDSCR.clear
|
15
15
|
end
|
16
16
|
|
17
|
-
def cmd_quit(arg)
|
17
|
+
def cmd_quit(arg, testing = false)
|
18
18
|
check_empty(arg)
|
19
19
|
# system("tput rmcup")
|
20
20
|
RubyText.stop
|
@@ -22,20 +22,20 @@ module RuneBlog::REPL
|
|
22
22
|
exit
|
23
23
|
end
|
24
24
|
|
25
|
-
def cmd_clear(arg)
|
25
|
+
def cmd_clear(arg, testing = false)
|
26
26
|
check_empty(arg)
|
27
27
|
STDSCR.cwin.clear
|
28
28
|
STDSCR.cwin.refresh
|
29
29
|
end
|
30
30
|
|
31
|
-
def cmd_version(arg)
|
31
|
+
def cmd_version(arg, testing = false)
|
32
32
|
reset_output
|
33
33
|
check_empty(arg)
|
34
34
|
output RuneBlog::VERSION
|
35
35
|
[true, @out]
|
36
36
|
end
|
37
37
|
|
38
|
-
def cmd_config(arg)
|
38
|
+
def cmd_config(arg, testing = false)
|
39
39
|
check_empty(arg)
|
40
40
|
dir = @blog.view.dir
|
41
41
|
items = ["publish",
|
@@ -46,7 +46,7 @@ module RuneBlog::REPL
|
|
46
46
|
edit_file("#{dir}/#{fname}")
|
47
47
|
end
|
48
48
|
|
49
|
-
def cmd_browse(arg)
|
49
|
+
def cmd_browse(arg, testing = false)
|
50
50
|
reset_output
|
51
51
|
check_empty(arg)
|
52
52
|
url = @blog.view.publisher.url
|
@@ -60,7 +60,7 @@ module RuneBlog::REPL
|
|
60
60
|
nil
|
61
61
|
end
|
62
62
|
|
63
|
-
def cmd_preview(arg)
|
63
|
+
def cmd_preview(arg, testing = false)
|
64
64
|
reset_output
|
65
65
|
check_empty(arg)
|
66
66
|
local = @blog.view.index
|
@@ -68,51 +68,36 @@ module RuneBlog::REPL
|
|
68
68
|
raise CantOpen(local) unless result
|
69
69
|
end
|
70
70
|
|
71
|
-
def cmd_publish(arg) # FIXME non-string return expected in caller?
|
72
|
-
puts
|
71
|
+
def cmd_publish(arg, testing = false) # FIXME non-string return expected in caller?
|
72
|
+
puts unless testing
|
73
73
|
reset_output
|
74
74
|
check_empty(arg)
|
75
75
|
unless @blog.view.can_publish?
|
76
|
-
puts "Can't publish without entries in #{@blog.view.name}/publish"
|
76
|
+
puts "Can't publish without entries in #{@blog.view.name}/publish" unless testing
|
77
77
|
output! "Can't publish without entries in #{@blog.view.name}/publish"
|
78
78
|
return [false, @out]
|
79
79
|
end
|
80
80
|
RubyText.spinner { @blog.view.publish }
|
81
|
-
|
82
|
-
|
83
|
-
# output! "No files to publish"
|
84
|
-
# return [true, @out]
|
85
|
-
# end
|
86
|
-
|
87
|
-
# output "Files:"
|
88
|
-
# files.each {|f| output " #{f}\n" }
|
89
|
-
# output_newline
|
90
|
-
# dir = "#{sroot}/#{spath}"
|
91
|
-
# # FIXME - may or may not already exist
|
92
|
-
# result = system("ssh root@#{server} mkdir -p #{dir}")
|
93
|
-
#
|
94
|
-
# cmd = "scp -r #{files.join(' ')} root@#{server}:#{dir} >/dev/null 2>&1"
|
95
|
-
# output! "Publishing #{files.size} files...\n"
|
96
|
-
# result = system(cmd)
|
97
|
-
# raise PublishError unless result
|
98
|
-
|
99
|
-
dump(files, "#{vdir}/last_published")
|
100
|
-
puts " ...finished"
|
81
|
+
dump("fix this later", "#{vdir}/last_published")
|
82
|
+
puts " ...finished" unless testing
|
101
83
|
output! "...finished.\n"
|
102
84
|
return [false, @out]
|
103
85
|
end
|
104
86
|
|
105
|
-
def cmd_rebuild(arg)
|
87
|
+
def cmd_rebuild(arg, testing = false)
|
106
88
|
debug "Starting cmd_rebuild..."
|
107
89
|
reset_output
|
108
90
|
check_empty(arg)
|
109
|
-
puts
|
91
|
+
puts unless testing
|
92
|
+
debug "cp1"
|
110
93
|
files = @blog.find_src_slugs
|
94
|
+
debug "cp2"
|
111
95
|
files.each {|file| @blog.rebuild_post(file) }
|
96
|
+
debug "cp3"
|
112
97
|
nil
|
113
98
|
end
|
114
99
|
|
115
|
-
def cmd_relink(arg)
|
100
|
+
def cmd_relink(arg, testing = false)
|
116
101
|
reset_output
|
117
102
|
check_empty(arg)
|
118
103
|
@blog.relink
|
@@ -129,7 +114,7 @@ module RuneBlog::REPL
|
|
129
114
|
k, name = STDSCR.menu(title: "Views", items: viewnames, curr: n) unless testing
|
130
115
|
@blog.view = name
|
131
116
|
output name + "\n"
|
132
|
-
puts "\n ", fx(name, :bold), "\n"
|
117
|
+
puts "\n ", fx(name, :bold), "\n" unless testing
|
133
118
|
return [false, @out]
|
134
119
|
else
|
135
120
|
if @blog.view?(arg)
|
@@ -140,7 +125,7 @@ module RuneBlog::REPL
|
|
140
125
|
return [false, @out]
|
141
126
|
end
|
142
127
|
|
143
|
-
def cmd_new_view(arg)
|
128
|
+
def cmd_new_view(arg, testing = false)
|
144
129
|
reset_output
|
145
130
|
@blog.create_view(arg)
|
146
131
|
resp = yesno("Add publishing info now? ")
|
@@ -149,18 +134,19 @@ module RuneBlog::REPL
|
|
149
134
|
nil
|
150
135
|
end
|
151
136
|
|
152
|
-
def cmd_new_post(arg)
|
137
|
+
def cmd_new_post(arg, testing = false)
|
153
138
|
reset_output
|
154
139
|
check_empty(arg)
|
155
140
|
title = ask("\nTitle: ")
|
156
|
-
|
157
|
-
meta.title = title
|
158
|
-
@blog.create_new_post(meta)
|
141
|
+
@blog.create_new_post(title)
|
159
142
|
STDSCR.clear
|
160
143
|
nil
|
144
|
+
rescue => err
|
145
|
+
puts err
|
146
|
+
puts err.backtrace.join("\n")
|
161
147
|
end
|
162
148
|
|
163
|
-
def cmd_kill(arg)
|
149
|
+
def cmd_kill(arg, testing = false)
|
164
150
|
reset_output
|
165
151
|
args = arg.split
|
166
152
|
args.each do |x|
|
@@ -173,7 +159,7 @@ module RuneBlog::REPL
|
|
173
159
|
|
174
160
|
#-- FIXME affects linking, building, publishing...
|
175
161
|
|
176
|
-
def cmd_remove_post(arg, safe=true)
|
162
|
+
def cmd_remove_post(arg, testing = false, safe=true)
|
177
163
|
# FIXME - 'safe' is no longer a thing
|
178
164
|
reset_output
|
179
165
|
id = get_integer(arg)
|
@@ -184,7 +170,7 @@ module RuneBlog::REPL
|
|
184
170
|
|
185
171
|
#-- FIXME affects linking, building, publishing...
|
186
172
|
|
187
|
-
def cmd_edit_post(arg)
|
173
|
+
def cmd_edit_post(arg, testing = false)
|
188
174
|
reset_output
|
189
175
|
id = get_integer(arg)
|
190
176
|
# Simplify this
|
@@ -201,74 +187,74 @@ module RuneBlog::REPL
|
|
201
187
|
nil
|
202
188
|
end
|
203
189
|
|
204
|
-
def cmd_list_views(arg)
|
190
|
+
def cmd_list_views(arg, testing = false)
|
205
191
|
reset_output("\n")
|
206
192
|
check_empty(arg)
|
207
|
-
puts
|
193
|
+
puts unless testing
|
208
194
|
@blog.views.each do |v|
|
209
195
|
v = v.to_s
|
210
196
|
v = fx(v, :bold) if v == @blog.view.name
|
211
197
|
print " "
|
212
198
|
output v + "\n"
|
213
|
-
puts v
|
199
|
+
puts v unless testing
|
214
200
|
end
|
215
|
-
puts
|
201
|
+
puts unless testing
|
216
202
|
return [false, @out]
|
217
203
|
end
|
218
204
|
|
219
|
-
def cmd_list_posts(arg)
|
205
|
+
def cmd_list_posts(arg, testing = false)
|
220
206
|
reset_output
|
221
207
|
check_empty(arg)
|
222
208
|
posts = @blog.posts # current view
|
223
209
|
str = @blog.view.name + ":\n"
|
224
210
|
output str
|
225
|
-
puts
|
211
|
+
puts unless testing
|
226
212
|
print " "
|
227
|
-
puts fx(str, :bold)
|
213
|
+
puts fx(str, :bold) unless testing
|
228
214
|
if posts.empty?
|
229
215
|
output! bold("No posts")
|
230
|
-
puts fx(" No posts", :bold)
|
216
|
+
puts fx(" No posts", :bold) unless testing
|
231
217
|
else
|
232
218
|
posts.each do |post|
|
233
219
|
outstr " #{colored_slug(post)}\n"
|
234
220
|
base = post.sub(/.lt3$/, "")
|
235
221
|
num, rest = base[0..3], base[4..-1]
|
236
222
|
print " "
|
237
|
-
puts fx(num, Red), fx(rest, Blue)
|
223
|
+
puts fx(num, Red), fx(rest, Blue) unless testing
|
238
224
|
end
|
239
225
|
end
|
240
|
-
puts
|
226
|
+
puts unless testing
|
241
227
|
return [false, @out]
|
242
228
|
end
|
243
229
|
|
244
|
-
def cmd_list_drafts(arg)
|
230
|
+
def cmd_list_drafts(arg, testing = false)
|
245
231
|
reset_output
|
246
232
|
check_empty(arg)
|
247
233
|
drafts = @blog.drafts # current view
|
248
234
|
if drafts.empty?
|
249
235
|
output! "No drafts"
|
250
|
-
puts " No drafts"
|
236
|
+
puts " No drafts" unless testing
|
251
237
|
return [true, @out]
|
252
238
|
else
|
253
|
-
puts
|
239
|
+
puts unless testing
|
254
240
|
drafts.each do |draft|
|
255
241
|
outstr " #{colored_slug(draft.sub(/.lt3$/, ""))}\n"
|
256
242
|
base = draft.sub(/.lt3$/, "")
|
257
243
|
num, rest = base[0..3], base[4..-1]
|
258
244
|
print " "
|
259
|
-
puts fx(num, Red), fx(rest, Blue)
|
245
|
+
puts fx(num, Red), fx(rest, Blue) unless testing
|
260
246
|
end
|
261
247
|
end
|
262
|
-
puts
|
248
|
+
puts unless testing
|
263
249
|
return [false, @out]
|
264
250
|
end
|
265
251
|
|
266
|
-
def cmd_INVALID(arg)
|
252
|
+
def cmd_INVALID(arg, testing = false)
|
267
253
|
reset_output "\n Command '#{red(arg)}' was not understood."
|
268
254
|
return [true, @out]
|
269
255
|
end
|
270
256
|
|
271
|
-
def cmd_help(arg)
|
257
|
+
def cmd_help(arg, testing = false)
|
272
258
|
reset_output
|
273
259
|
check_empty(arg)
|
274
260
|
output(<<-EOS)
|
data/lib/runeblog.rb
CHANGED
@@ -53,6 +53,7 @@ class RuneBlog
|
|
53
53
|
rescue => err
|
54
54
|
puts "Can't create blog: '#{dir}' - #{err}" # CHANGE_FOR_CURSES?
|
55
55
|
puts err.backtrace.join("\n") # CHANGE_FOR_CURSES?
|
56
|
+
sleep 5
|
56
57
|
end
|
57
58
|
|
58
59
|
def initialize # assumes existing blog
|
@@ -101,7 +102,9 @@ class RuneBlog
|
|
101
102
|
end
|
102
103
|
|
103
104
|
def next_sequence
|
104
|
-
|
105
|
+
@sequence += 1
|
106
|
+
debug "seq = #@sequence caller = #{caller.join("\n")}"
|
107
|
+
dump(@sequence, "#@root/sequence")
|
105
108
|
@sequence
|
106
109
|
end
|
107
110
|
|
@@ -164,17 +167,25 @@ class RuneBlog
|
|
164
167
|
result
|
165
168
|
end
|
166
169
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
meta
|
171
|
-
|
170
|
+
def create_new_post(title, testing = false)
|
171
|
+
# FIXME maybe not distinguish between a post and its metadata??
|
172
|
+
debug "cnp title = #{title.inspect}"
|
173
|
+
meta = OpenStruct.new
|
174
|
+
meta.title = title
|
175
|
+
meta.teaser = "Teaser goes here."
|
176
|
+
meta.body = "Remainder of post goes here."
|
177
|
+
meta.num = self.next_sequence
|
178
|
+
check_meta(meta, "cnp1")
|
179
|
+
post = RuneBlog::Post.new(meta, @view.name) #???
|
172
180
|
post.edit unless testing
|
173
|
-
|
174
|
-
post.
|
181
|
+
check_meta(meta, "cnp2")
|
182
|
+
post.build(meta)
|
183
|
+
check_meta(meta, "cnp3")
|
184
|
+
meta.num
|
175
185
|
rescue => err
|
176
|
-
puts err
|
177
|
-
puts err.backtrace.join("\n")
|
186
|
+
puts err
|
187
|
+
puts err.backtrace.join("\n")
|
188
|
+
sleep 5
|
178
189
|
end
|
179
190
|
|
180
191
|
def edit_initial_post(file, testing = false)
|
@@ -184,6 +195,7 @@ class RuneBlog
|
|
184
195
|
nil
|
185
196
|
rescue => err
|
186
197
|
error(err)
|
198
|
+
sleep 5
|
187
199
|
end
|
188
200
|
|
189
201
|
def posts
|
@@ -206,24 +218,29 @@ class RuneBlog
|
|
206
218
|
end
|
207
219
|
|
208
220
|
def process_post(file)
|
221
|
+
debug "procpost 1: file = #{file.inspect}"
|
209
222
|
raise ArgumentError unless file.is_a?(String)
|
210
223
|
path = @root + "/src/#{file}"
|
211
224
|
raise FileNotFound(path) unless File.exist?(path)
|
212
225
|
livetext = Livetext.new(STDOUT) # (nil)
|
213
|
-
@
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
@
|
219
|
-
|
226
|
+
@meta2 = livetext.process_file(path, binding)
|
227
|
+
@meta2.num = file.to_i # dumb af
|
228
|
+
check_meta(@meta2, "procpost1")
|
229
|
+
raise LivetextError(path) if @meta2.nil?
|
230
|
+
|
231
|
+
self.make_slug(@meta2) # RuneBlog#process_post
|
232
|
+
# slug = file.sub(/.lt3$/, "")
|
233
|
+
# @meta.slug = slug
|
234
|
+
@meta2
|
220
235
|
rescue => err
|
221
236
|
error(err)
|
237
|
+
sleep 5
|
222
238
|
end
|
223
239
|
|
224
240
|
def build_post_view(view)
|
225
241
|
# Create dir using slug (index.html, metadata?)
|
226
242
|
vdir = self.viewdir(view) # FIXME
|
243
|
+
check_meta(@meta, "build_post_view")
|
227
244
|
dir = vdir + @meta.slug + "/"
|
228
245
|
create_dir(dir + "assets")
|
229
246
|
Dir.chdir(dir) do
|
@@ -237,6 +254,7 @@ class RuneBlog
|
|
237
254
|
generate_index(view)
|
238
255
|
rescue => err
|
239
256
|
error(err)
|
257
|
+
sleep 5
|
240
258
|
end
|
241
259
|
|
242
260
|
def generate_index(view)
|
@@ -261,6 +279,8 @@ class RuneBlog
|
|
261
279
|
pdir = vdir + "/" + post
|
262
280
|
Dir.chdir(pdir) do
|
263
281
|
meta = read_config("metadata.txt")
|
282
|
+
meta.num = post.to_i # first 4 digits
|
283
|
+
check_meta(meta, "gen_index")
|
264
284
|
meta.teaser = File.read("teaser.txt")
|
265
285
|
meta.body = File.read("body.txt")
|
266
286
|
end
|
@@ -273,6 +293,7 @@ class RuneBlog
|
|
273
293
|
end
|
274
294
|
rescue => err
|
275
295
|
error(err)
|
296
|
+
sleep 5
|
276
297
|
exit
|
277
298
|
end
|
278
299
|
|
@@ -281,8 +302,12 @@ class RuneBlog
|
|
281
302
|
end
|
282
303
|
|
283
304
|
def index_entry(view, meta)
|
305
|
+
check_meta(meta, "index_entry1")
|
306
|
+
debug "\nindex_entry: meta = #{meta.inspect}"
|
284
307
|
raise ArgumentError unless view.is_a?(String) || view.is_a?(RuneBlog::View)
|
285
|
-
meta
|
308
|
+
check_meta(meta, "index_entry2")
|
309
|
+
self.make_slug(meta) # RuneBlog#index_entry
|
310
|
+
check_meta(meta, "index_entry3")
|
286
311
|
# FIXME clean up and generalize
|
287
312
|
ref = "#{view}/#{meta.slug}/index.html"
|
288
313
|
<<-HTML
|
@@ -300,12 +325,13 @@ class RuneBlog
|
|
300
325
|
def rebuild_post(file)
|
301
326
|
debug "Called rebuild_post(#{file.inspect})"
|
302
327
|
raise ArgumentError unless file.is_a?(String)
|
303
|
-
@
|
304
|
-
@
|
305
|
-
|
306
|
-
|
328
|
+
@meta2 = process_post(file)
|
329
|
+
check_meta(@meta2, "rebuild_post")
|
330
|
+
debug "rebuild_post: @meta2 = #{@meta2.inspect}"
|
331
|
+
@meta2.views.each {|view| build_post_view(view) }
|
307
332
|
rescue => err
|
308
333
|
error(err)
|
334
|
+
sleep 5
|
309
335
|
end
|
310
336
|
|
311
337
|
def remove_post(num)
|
@@ -350,13 +376,17 @@ class RuneBlog
|
|
350
376
|
list.empty? ? nil : list
|
351
377
|
end
|
352
378
|
|
353
|
-
def make_slug(
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
379
|
+
def make_slug(meta)
|
380
|
+
check_meta(meta, "makeslug")
|
381
|
+
debug "mkslug 1: meta = #{meta.inspect}"
|
382
|
+
raise ArgumentError unless meta.title.is_a?(String)
|
383
|
+
label = '%04d' % meta.num # FIXME can do better
|
384
|
+
debug "mkslug 2: label = #{label.inspect}"
|
385
|
+
slug0 = meta.title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
|
386
|
+
debug "mkslug 2: slug0 = #{slug0.inspect}"
|
387
|
+
str = "#{label}-#{slug0}"
|
388
|
+
meta.slug = str
|
389
|
+
str
|
360
390
|
end
|
361
391
|
|
362
392
|
end
|
data/lib/version.rb
CHANGED
data/test/general.rb
CHANGED
@@ -27,14 +27,16 @@ class TestREPL < Minitest::Test
|
|
27
27
|
# Note: "Bang" methods depend on the data_test subtree
|
28
28
|
|
29
29
|
def test_001_cmd_help
|
30
|
-
|
30
|
+
# puts __method__
|
31
|
+
flag, out = cmd_help(nil, true)
|
31
32
|
assert out.is_a?(String), "Expected a string returned"
|
32
33
|
lines = out.split("\n").length
|
33
34
|
assert lines > 25, "Expecting lengthy help message"
|
34
35
|
end
|
35
36
|
|
36
37
|
def test_002_cmd_version
|
37
|
-
|
38
|
+
# puts __method__
|
39
|
+
flag, out = cmd_version(nil, true)
|
38
40
|
assert out.is_a?(String), "Expected a string returned"
|
39
41
|
lines = out
|
40
42
|
assert lines =~ /\d+\.\d+\.\d+/m,
|
@@ -42,34 +44,38 @@ class TestREPL < Minitest::Test
|
|
42
44
|
end
|
43
45
|
|
44
46
|
def test_003_list_views!
|
45
|
-
|
47
|
+
# puts __method__
|
48
|
+
flag, out = cmd_list_views(nil, true)
|
46
49
|
assert out.is_a?(String), "Expected a string returned"
|
47
50
|
lines = out.split("\n").length
|
48
|
-
p out
|
49
51
|
assert lines >= 2, "Expecting at least 2 lines"
|
50
52
|
end
|
51
53
|
|
52
54
|
def test_004_change_view!
|
55
|
+
# puts __method__
|
53
56
|
flag, out = cmd_change_view(nil, true) # no param, but testing
|
54
57
|
assert out.is_a?(String), "Expected a string; got: #{out.inspect}"
|
55
58
|
assert out =~ /alpha_view/m, "Expecting 'alpha_view' as default; got: #{out.inspect}"
|
56
59
|
end
|
57
60
|
|
58
61
|
def test_005_lsd!
|
59
|
-
|
62
|
+
# puts __method__
|
63
|
+
flag, out = cmd_list_drafts(nil, true)
|
60
64
|
assert out.is_a?(String), "Expected a string returned"
|
61
65
|
lines = out.split("\n").length
|
62
66
|
assert lines == 10, "Expecting 10 lines; got #{show_lines(out)}"
|
63
67
|
end
|
64
68
|
|
65
|
-
def
|
66
|
-
|
69
|
+
def xtest_006_lsp!
|
70
|
+
puts __method__
|
71
|
+
flag, out = cmd_list_posts(nil, true)
|
67
72
|
assert out.is_a?(String), "Expected a string returned; got: #{out.inspect}"
|
68
73
|
lines = out.split("\n").length
|
69
74
|
assert lines == 6, "Expecting 6 lines; got #{show_lines(out)}"
|
70
75
|
end
|
71
76
|
|
72
77
|
def test_007_parser
|
78
|
+
# puts __method__
|
73
79
|
parse_tests = {
|
74
80
|
# Loading/trailing blanks as well
|
75
81
|
"kill 81 82 83" => [:cmd_kill, "81 82 83"],
|
@@ -116,10 +122,12 @@ p out
|
|
116
122
|
end
|
117
123
|
|
118
124
|
def test_008_current_view!
|
125
|
+
# puts __method__
|
119
126
|
assert @blog.view.to_s == "alpha_view", "Current view wrong (#{@blog.view}, not alpha_view)"
|
120
127
|
end
|
121
128
|
|
122
129
|
def test_009_change_view!
|
130
|
+
# puts __method__
|
123
131
|
assert @blog.change_view("beta_view")
|
124
132
|
assert @blog.view.to_s == "beta_view", "Current view wrong (#{@blog.view}, not beta_view)"
|
125
133
|
assert @blog.change_view("alpha_view")
|
@@ -127,12 +135,14 @@ p out
|
|
127
135
|
end
|
128
136
|
|
129
137
|
def test_010_accessors!
|
138
|
+
# puts __method__
|
130
139
|
sorted_views = @blog.views.map(&:to_s).sort
|
131
140
|
assert sorted_views == ["alpha_view", "beta_view", "gamma_view", "test_view"],
|
132
141
|
"Got: #{sorted_views.inspect}"
|
133
142
|
end
|
134
143
|
|
135
144
|
def test_011_create_delete_view!
|
145
|
+
# puts __method__
|
136
146
|
@blog.create_view("anotherview")
|
137
147
|
sorted_views = @blog.views.map(&:to_s).sort
|
138
148
|
assert sorted_views == ["alpha_view", "anotherview", "beta_view", "gamma_view", "test_view"],
|
@@ -143,7 +153,8 @@ p out
|
|
143
153
|
"After delete: #{sorted_views.inspect}"
|
144
154
|
end
|
145
155
|
|
146
|
-
def
|
156
|
+
def xtest_012_create_remove_post!
|
157
|
+
# puts __method__
|
147
158
|
@blog.change_view("beta_view")
|
148
159
|
assert @blog.view.to_s == "beta_view", "Expected beta_view"
|
149
160
|
nposts = @blog.posts.size
|
@@ -163,6 +174,7 @@ p out
|
|
163
174
|
end
|
164
175
|
|
165
176
|
def test_013_slug_tests
|
177
|
+
puts __method__
|
166
178
|
hash = { "abcxyz" => "abcxyz", # 0-based
|
167
179
|
"abc'xyz" => "abcxyz",
|
168
180
|
'abc"xyz' => "abcxyz",
|
@@ -173,25 +185,30 @@ p out
|
|
173
185
|
}
|
174
186
|
hash.each_pair.with_index do |keys, i|
|
175
187
|
real, fixed = *keys
|
176
|
-
|
188
|
+
meta = OpenStruct.new
|
189
|
+
meta.title = real
|
190
|
+
meta.num = 99
|
191
|
+
result = @blog.make_slug(meta)[5..-1] # Skip num (test_013...)
|
177
192
|
assert result == fixed, "Case #{i}: expected: #{fixed.inspect}, got #{result.inspect}"
|
178
193
|
end
|
179
194
|
end
|
180
195
|
|
181
196
|
def test_014_remove_nonexistent_post!
|
197
|
+
# puts __method__
|
182
198
|
@blog.change_view("alpha_view")
|
183
|
-
flag, out = cmd_remove_post(99)
|
199
|
+
flag, out = cmd_remove_post(99, true)
|
184
200
|
assert out =~ /Post 99 not found/, "Expected error about nonexistent post, got: #{out}"
|
185
201
|
end
|
186
202
|
|
187
203
|
def test_015_kill_multiple_posts!
|
204
|
+
# puts __method__
|
188
205
|
@blog.change_view("alpha_view")
|
189
|
-
flag, out = cmd_list_posts(nil)
|
206
|
+
flag, out = cmd_list_posts(nil, true)
|
190
207
|
before = out.split("\n").length
|
191
|
-
flag, out = cmd_kill("1 2 7")
|
192
|
-
flag, out = cmd_list_posts(nil)
|
208
|
+
flag, out = cmd_kill("1 2 7", true)
|
209
|
+
flag, out = cmd_list_posts(nil, true)
|
193
210
|
after = out.split("\n").length
|
194
|
-
expecting = before -
|
211
|
+
expecting = before - 3
|
195
212
|
assert after == expecting, "list_posts saw #{before} posts, now #{after} (not #{expecting})"
|
196
213
|
@blog.undelete_post(1)
|
197
214
|
@blog.undelete_post(2)
|
@@ -201,6 +218,7 @@ p out
|
|
201
218
|
if File.exist?("testing.publish")
|
202
219
|
|
203
220
|
def test_016_can_publish
|
221
|
+
# puts __method__
|
204
222
|
x = OpenStruct.new
|
205
223
|
x.user, x.server, x.docroot, x.docroot, x.path, x.proto =
|
206
224
|
"root", "rubyhacker.com", "/var/www", "whatever", "http"
|
@@ -212,6 +230,7 @@ if File.exist?("testing.publish")
|
|
212
230
|
end
|
213
231
|
|
214
232
|
def test_017_cannot_publish_wrong_user
|
233
|
+
# puts __method__
|
215
234
|
x = OpenStruct.new
|
216
235
|
x.user, x.server, x.docroot, x.docroot, x.path, x.proto =
|
217
236
|
"bad_user", "rubyhacker.com", "/var/www", "whatever", "http"
|
@@ -221,6 +240,7 @@ if File.exist?("testing.publish")
|
|
221
240
|
end
|
222
241
|
|
223
242
|
def test_018_cannot_publish_bad_server
|
243
|
+
# puts __method__
|
224
244
|
x = OpenStruct.new
|
225
245
|
x.user, x.server, x.docroot, x.docroot, x.path, x.proto =
|
226
246
|
"root", "nonexistent123.com", "/var/www", "whatever", "http"
|
@@ -232,10 +252,12 @@ if File.exist?("testing.publish")
|
|
232
252
|
end # conditional tests
|
233
253
|
|
234
254
|
def test_019_exception_existing_blog
|
255
|
+
# puts __method__
|
235
256
|
assert_raises(BlogAlreadyExists) { RuneBlog.create_new_blog }
|
236
257
|
end
|
237
258
|
|
238
259
|
def test_020_exception_missing_blog_accessor
|
260
|
+
# puts __method__
|
239
261
|
save = RuneBlog.blog
|
240
262
|
RuneBlog.blog = nil
|
241
263
|
assert_raises(NoBlogAccessor) { RuneBlog::Post.load(1) }
|
@@ -243,24 +265,31 @@ end # conditional tests
|
|
243
265
|
end
|
244
266
|
|
245
267
|
def test_021_exception_cant_assign_view
|
268
|
+
# puts __method__
|
246
269
|
assert_raises(CantAssignView) { @blog.view = 99 }
|
247
270
|
end
|
248
271
|
|
249
272
|
def test_022_exception_no_such_view
|
273
|
+
# puts __method__
|
250
274
|
assert_raises(NoSuchView) { @blog.view = 'not_a_view_name' }
|
251
275
|
end
|
252
276
|
|
253
277
|
def test_023_exception_view_already_exists
|
278
|
+
# puts __method__
|
254
279
|
assert_raises(ViewAlreadyExists) { @blog.create_view('alpha_view') }
|
255
280
|
end
|
256
281
|
|
257
282
|
def xtest_024_exception_livetext_error # FIXME Doesn't work! Change Livetext
|
283
|
+
# puts __method__
|
258
284
|
testfile = "testfile.lt3"
|
259
285
|
path = @blog.root + "/src/" + testfile
|
260
286
|
cmd = "echo .no_such_command > #{path}"
|
261
287
|
system(cmd)
|
262
|
-
|
288
|
+
# system("ls -l #{path}")
|
289
|
+
save = STDERR
|
290
|
+
STDERR.reopen("/dev/null")
|
263
291
|
assert_raises(LivetextError) { @blog.process_post(testfile) }
|
292
|
+
STDERR.reopen(save)
|
264
293
|
File.rm(path)
|
265
294
|
end
|
266
295
|
|
data/test/make_blog.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
$LOAD_PATH << "."
|
2
2
|
|
3
3
|
require 'global'
|
4
|
-
require 'rubytext'
|
4
|
+
# require 'rubytext'
|
5
5
|
require 'repl'
|
6
6
|
|
7
|
+
def debug(str)
|
8
|
+
STDERR.puts str
|
9
|
+
end
|
10
|
+
|
7
11
|
def make_post(x, title)
|
8
12
|
meta = OpenStruct.new
|
9
|
-
|
10
|
-
num = x.create_new_post(meta, true)
|
13
|
+
num = x.create_new_post(title, true)
|
11
14
|
num
|
12
15
|
end
|
13
16
|
|
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.1.
|
4
|
+
version: 0.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hal Fulton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: livetext
|