txt.conf wizard
git-svn-id: file:///srv/svn/repo/kosuzu/trunk@36 eb64cd80-c68d-6f47-b6a3-0ada418499da
This commit is contained in:
@@ -5,9 +5,26 @@ let targets pubdir = List.fold_left
|
|||||||
[]
|
[]
|
||||||
["htm,atom", "public_html/"; "gmi,gmi-atom", "public_gemini/"; "", "public_gopher/"]
|
["htm,atom", "public_html/"; "gmi,gmi-atom", "public_gemini/"; "", "public_gopher/"]
|
||||||
|
|
||||||
|
let wizard () =
|
||||||
|
print_endline "No txt.conf found. It's required for the repository name & id. Create one? (y/N)";
|
||||||
|
match input_line stdin with
|
||||||
|
|"y"->
|
||||||
|
let title =
|
||||||
|
print_endline "Title for repository: ";
|
||||||
|
input_line stdin in
|
||||||
|
let authors =
|
||||||
|
print_endline "Authors (format: name <name@email> <http://website>): ";
|
||||||
|
input_line stdin in
|
||||||
|
Logarion.File_store.file "txt.conf"
|
||||||
|
(Printf.sprintf "Id: %s\nTitle: %s\nAuthors: %s\n" (Logarion.Id.generate ()) title authors);
|
||||||
|
Logarion.File_store.of_kv_file ()
|
||||||
|
| _ -> print_endline "Create a txt.conf and run publish again"; exit 1
|
||||||
|
|
||||||
open Logarion
|
open Logarion
|
||||||
let publish pubdir ids =
|
let publish pubdir ids =
|
||||||
let kv = Logarion.File_store.of_kv_file () in
|
let kv =
|
||||||
|
match Logarion.File_store.of_kv_file ()
|
||||||
|
with x when x = Logarion.Store.KV.empty -> wizard () | x -> x in
|
||||||
let predicate t = List.mem t.Text.id ids in
|
let predicate t = List.mem t.Text.id ids in
|
||||||
let pubdir_source, pubdir = match pubdir with Some d -> "--pubdir ", d | None ->
|
let pubdir_source, pubdir = match pubdir with Some d -> "--pubdir ", d | None ->
|
||||||
try "txt.conf:Pubdir", Logarion.Store.KV.find "Pubdir" kv with Not_found ->
|
try "txt.conf:Pubdir", Logarion.Store.KV.find "Pubdir" kv with Not_found ->
|
||||||
@@ -15,7 +32,8 @@ let publish pubdir ids =
|
|||||||
in
|
in
|
||||||
let targets = targets pubdir in
|
let targets = targets pubdir in
|
||||||
if targets = [] then
|
if targets = [] then
|
||||||
Printf.eprintf "No target directories in %s='%s'\n" pubdir_source pubdir
|
Printf.eprintf "No target directories in %s='%s' (for example %s)\n"
|
||||||
|
pubdir_source pubdir (Filename.concat pubdir "public_html")
|
||||||
else begin
|
else begin
|
||||||
let pub_dirs = List.map (fun x -> snd x) targets in
|
let pub_dirs = List.map (fun x -> snd x) targets in
|
||||||
File_store.iter ~predicate (fun (_t, p) ->
|
File_store.iter ~predicate (fun (_t, p) ->
|
||||||
|
|||||||
Reference in New Issue
Block a user