runeblog 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d9daecd282557ea33ae6a7ec914727a1a4077fc3
4
- data.tar.gz: 16a3d20f5e907f7725db1a9bd8342db88e2df8b1
2
+ SHA256:
3
+ metadata.gz: aef7d403afc6196d75ad2f03efd4cd17f20e9e3afe553719caf8ea9417d27470
4
+ data.tar.gz: ee65d44e639ff13c4817fec44df9899d0f38fb234fbcc6d4e8e19bfbb25f5284
5
5
  SHA512:
6
- metadata.gz: b3f80c6ebfd92fb7100c39a1281c6e1f41a7a89d7e627b82765381b97b819f6e5303415a7264a9d2e9a2f76eb4f323fe9c178599f3b6e542595e3aa2a62f4074
7
- data.tar.gz: 69a924c292dd44ac3490a0d2477808aa2bb66ed180228d06b6185831f04cb502b4ca90ea070533ece0c47d3deecdad5599613a83f57a34e6dc3657cba36860b7
6
+ metadata.gz: 6dd26d351a24e5b558fb897fb7cc818d370a01688c7eba89e9296bf763e31c6faa57ab42342306bb5ddbb349b0744460f590fd7ba74c4da3b830aeab5d861785
7
+ data.tar.gz: 255a1a568efaf58bd4ebe8f8ed47a58244d59cc0d5d5c849c240698ca048a4265688322360f16ef158de5c6ec5fc5f0f43d5066e72fff88414244207813c8087
data/bin/blog CHANGED
@@ -1,12 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $: << "./lib"
3
+ # $LOAD_PATH << "./lib"
4
4
 
5
+ require 'global'
6
+ require 'rubytext' if curses?
5
7
  require 'readline'
6
8
 
7
9
  require 'repl'
8
10
 
9
- trap("INT") { }
11
+ # trap("INT") { }
10
12
 
11
13
  include RuneBlog::REPL
12
14
 
@@ -34,7 +36,12 @@ if ! RuneBlog.exist?
34
36
  end
35
37
 
36
38
  def mainloop
37
- cmd = Readline.readline(red("\nblog> "), true)
39
+ if curses?
40
+ print red("blog> ")
41
+ cmd = gets
42
+ else
43
+ cmd = Readline.readline(red("\nblog> "), true)
44
+ end
38
45
  cmd_quit(nil) if cmd.nil? # ^D
39
46
  cmd.chomp!
40
47
  return if cmd.empty? # CR does nothing
@@ -45,6 +52,14 @@ rescue => err
45
52
  puts err
46
53
  end
47
54
 
55
+
56
+ puts curses?
57
+ sleep 6
58
+
59
+ if curses?
60
+ RubyText.start(:echo, :noraw, log: "debug.out")
61
+ end
62
+
48
63
  @blog = RuneBlog.new
49
64
 
50
65
  if cmd.nil? # REPL
@@ -17,6 +17,10 @@ class RuneBlog
17
17
  end
18
18
  end
19
19
 
20
+ def curses?
21
+ false
22
+ end
23
+
20
24
  def make_exception(sym, str)
21
25
  return if Object.constants.include?(sym)
22
26
  Object.const_set(sym, StandardError.dup)
@@ -6,7 +6,61 @@ make_exception(:CantDelete, "Can't open '$1'")
6
6
  make_exception(:InternalError, "Glitch: $1 got arg '$2'")
7
7
  make_exception(:CantCopy, "Can't copy $1 to $2")
8
8
 
9
+ module WithANSI
10
+ def clear
11
+ puts "\e[H\e[2J" # clear screen # CHANGE_FOR_CURSES?
12
+ end
13
+
14
+ def red(text)
15
+ "\e[31m#{text}\e[0m" # CHANGE_FOR_CURSES?
16
+ end
17
+
18
+ def blue(text)
19
+ "\e[34m#{text}\e[0m" # CHANGE_FOR_CURSES?
20
+ end
21
+
22
+ def bold(str)
23
+ "\e[1m#{str}\e[22m" # CHANGE_FOR_CURSES?
24
+ end
25
+
26
+ end
27
+
28
+ module NoANSI
29
+
30
+ def gets
31
+ str = ""
32
+ loop do
33
+ ch = ::STDSCR.getch
34
+ if ch == 10
35
+ # puts "\n\n "
36
+ break
37
+ end
38
+ str << ch
39
+ end
40
+ str
41
+ end
42
+
43
+ def clear
44
+ # puts "\e[H\e[2J" # clear screen # CHANGE_FOR_CURSES?
45
+ end
46
+
47
+ def red(text)
48
+ text
49
+ end
50
+
51
+ def blue(text)
52
+ text
53
+ end
54
+
55
+ def bold(str)
56
+ str
57
+ end
58
+ end
59
+
60
+
9
61
  module RuneBlog::REPL
62
+ include curses? ? NoANSI : WithANSI
63
+
10
64
  Patterns =
11
65
  {"help" => :cmd_help,
12
66
  "h" => :cmd_help,
@@ -160,22 +214,6 @@ module RuneBlog::REPL
160
214
  end
161
215
  end
162
216
 
163
- def clear
164
- puts "\e[H\e[2J" # clear screen # CHANGE_FOR_CURSES?
165
- end
166
-
167
- def red(text)
168
- "\e[31m#{text}\e[0m" # CHANGE_FOR_CURSES?
169
- end
170
-
171
- def blue(text)
172
- "\e[34m#{text}\e[0m" # CHANGE_FOR_CURSES?
173
- end
174
-
175
- def bold(str)
176
- "\e[1m#{str}\e[22m" # CHANGE_FOR_CURSES?
177
- end
178
-
179
217
  def colored_slug(slug)
180
218
  red(slug[0..3])+blue(slug[4..-1]) # CHANGE_FOR_CURSES?
181
219
  end
@@ -57,6 +57,10 @@ module RuneBlog::REPL
57
57
  def cmd_publish(arg) # FIXME non-string return expected in caller?
58
58
  reset_output
59
59
  check_empty(arg)
60
+ unless @blog.view.can_publish?
61
+ output! "Can't publish without entries in #{@blog.view}/publish"
62
+ return @out
63
+ end
60
64
  @blog.view.publish
61
65
  user, server, sroot, spath = *@publish[@blog.view]
62
66
  if files.empty? # FIXME baloney
@@ -130,7 +130,8 @@ class RuneBlog
130
130
  create_dir('custom')
131
131
  create_dir('assets')
132
132
  # FIXME dump method??
133
- dump("", "publish")
133
+ pub = "user: xxx\nserver: xxx\ndocroot: xxx\npath: xxx\nproto: xxx\n"
134
+ dump(pub, "publish") # FIXME publish
134
135
  dump(x::BlogHeader, "custom/blog_header.html")
135
136
  dump(x::BlogTrailer, "custom/blog_trailer.html")
136
137
  dump(x::PostTemplate, "custom/post_template.html")
@@ -1,6 +1,6 @@
1
1
 
2
2
  class RuneBlog
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
 
5
5
  Path = File.expand_path(File.join(File.dirname(__FILE__)))
6
6
  end
@@ -11,8 +11,12 @@ class RuneBlog::View
11
11
  raise NoBlogAccessor if RuneBlog.blog.nil?
12
12
  @blog = RuneBlog.blog
13
13
  @name = name
14
- dep_file = @blog.root + "/views/#@name/publish"
15
- @publisher = read_config(dep_file)
14
+ @can_publish = false
15
+ pub_file = @blog.root + "/views/#@name/publish"
16
+ unless File.size(pub_file) == 0
17
+ @publisher = RuneBlog::Publishing.new(read_config(pub_file))
18
+ @can_publish = true
19
+ end
16
20
  end
17
21
 
18
22
  def dir
@@ -36,6 +40,10 @@ class RuneBlog::View
36
40
  files
37
41
  end
38
42
 
43
+ def can_publish?
44
+ @can_publish
45
+ end
46
+
39
47
  def publish
40
48
  # ?? @blog.view.publisher.publish
41
49
  # output "Files:"
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.1
4
+ version: 0.1.2
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-11-05 00:00:00.000000000 Z
11
+ date: 2018-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: livetext
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  version: '0'
75
75
  requirements: []
76
76
  rubyforge_project:
77
- rubygems_version: 2.2.2
77
+ rubygems_version: 2.7.7
78
78
  signing_key:
79
79
  specification_version: 4
80
80
  summary: A command-line blogging system