empty_view/themes/standard/widgets/pages/pages.rb in runeblog-0.3.12 vs empty_view/themes/standard/widgets/pages/pages.rb in runeblog-0.3.13
- old
+ new
@@ -84,9 +84,44 @@
</div>
EOS
end
end
+ def manage
+ dir = @blog.view.dir/"themes/standard/widgets/pages"
+ # Assume child files already generated (and list.data??)
+ data = dir/"list.data"
+ lines = _get_data?(data)
+ hash = {}
+ lines.each do |line|
+ url, name = line.chomp.split(",")
+ source = url.sub(/.html$/, ".lt3")
+ hash[name] = source
+ end
+ new_item = "[New page]"
+ num, fname = STDSCR.menu(title: "Edit page:", items: hash.keys + [new_item])
+ return if fname.nil?
+ if fname == new_item
+ print "Page title: "
+ title = RubyText.gets
+ title.chomp!
+ print "File name (.lt3): "
+ fname = RubyText.gets
+ fname << ".lt3" unless fname.end_with?(".lt3")
+ fhtml = fname.sub(/.lt3$/, ".html")
+ File.open(data, "a") {|f| f.puts "#{fhtml},#{title}" }
+ new_file = dir/fname
+ File.open(new_file, "w") do |f|
+ f.puts "<h1>#{title}</h1>\n\n\n "
+ f.puts ".backlink"
+ end
+ edit_file(new_file)
+ else
+ target = hash[fname]
+ edit_file(dir/target)
+ end
+ end
+
def edit_menu
end
def refresh
end