19 package org.turro.parser.wiki;
22 import java.io.IOException;
25 import java.util.TreeSet;
26 import java.util.logging.Level;
27 import java.util.logging.Logger;
28 import org.turro.action.Contacts;
29 import org.turro.elephant.context.IConstructor;
30 import org.turro.file.Folder;
31 import org.turro.marker.ElephantMarker;
32 import org.turro.plugin.contacts.IContact;
33 import org.turro.string.Strings;
43 if(contact ==
null) contact = constructor.
getUser();
44 String
template = locateTemplate(constructor, name);
45 if(!Strings.isBlank(
template)) {
47 marker.
put(
"help",
false);
48 marker.
put(
"end", name.startsWith(
"/"));
50 marker.
put(
"contact", checkContact(contact, pars));
51 return marker.
parse(TMPL_ROOT,
template);
58 String
template = locateTemplate(constructor, name);
59 if(!Strings.isBlank(
template)) {
61 marker.
put(
"help",
true);
62 marker.
put(
"end",
false);
63 return marker.
parse(TMPL_ROOT,
template);
70 private static final String TMPL_ROOT =
"widgets/mwiki";
75 Set<String> names =
new TreeSet<>();
78 root.documents(
"*Template.html").forEach(d -> {
79 names.add(d.name().replace(
"Template.html",
""));
81 }
catch (IOException ex) {
88 private String locateTemplate(
IConstructor constructor, String name) {
89 if(name.startsWith(
"/")) name = name.substring(1);
91 return file.exists() ? name :
null;
95 if(pars.containsKey(
"contact")) {
96 return Contacts.getContactById(pars.get(
"contact"));
static String templateRoot(IConstructor constructor, boolean mail)
static File fileTemplate(IConstructor constructor, boolean mail, String root, String name)
String parse(String rootTmpl, String tmpl)
Object put(Object key, Object value)
String expand(IConstructor constructor, IContact contact, String name, Map< String, String > pars)
Set< String > locateNames(IConstructor constructor)
String help(IConstructor constructor, String name)