Mir.Localizer=mircoders.localizer.basic.MirBasicLocalizer
Mir.Localizer.Logfile=log/localizer.log
-Mir.Localizer.ProducerConfigFile=templates/producer/producers.xml
+# The location of the producer specifiations
+Mir.Localizer.ProducerConfigFile=templates/producer/producers.xml
+# Which producers need to be called after an article (resp. a comment) is posted
+Mir.Localizer.OpenPosting.ContentProducers= media.new;content.new;startpage.new;synchronization.run
+Mir.Localizer.OpenPosting.CommentProducers= content.new;synchronization.run
#note that you can't make pdf's without making fo's
GenerateFO=yes
ServletModule.Language.ConfirmTemplate=admin/confirm.template
ServletModule.Language.ObjektTemplate=admin/language.template
ServletModule.Language.ListTemplate=admin/languagelist.template
-
-
-#
-# producer-related configs below
-#
-
-Producer.ExtLinkName=extlink.gif
-Producer.IntLinkName=intlink.gif
-Producer.MailLinkName=maillink.gif
-Producer.Logfile=log/producer.log
-
-Producer.Navigation.Template=producer/navigation.template
-
-Producer.Content.Template=producer/content.template
-Producer.Content.Batchsize=10
-
-Producer.PrintableContent.Template=producer/printablecontent.template
-Producer.PrintableContent.html2foStyleSheetName=producer/html2fo.xsl
-
-Producer.Startseite.Template=producer/startseite.template
-Producer.Startseite.Entries=7
-Producer.Startseite.Pages=10
-Producer.Startseite.Termine=5
-
-Producer.Themen.Template=producer/themen.template
-Producer.Themen.Entries=7
-Producer.Themen.Pages=3
-
-Producer.Schwerpunkte.Template=producer/schwerpunkte.template
-Producer.Schwerpunkte.Entries=7
-Producer.Schwerpunkte.Pages=3
-
-Producer.Overview.MonthTemplate=producer/ov_month.template
-Producer.Overview.YearTemplate=producer/ov_year.template
-
-Producer.List.Template=producer/list.template
-Producer.TopicList.Template=producer/topiclist.template
-Producer.OpenPosting.Template=producer/openposting.template
-Producer.FeatureList.Template=producer/featurelist.template
-
-Producer.StartPage.Template=producer/startpage.template
-Producer.FeaturesRSS.Template=producer/featuresRSS.template
-Producer.StartPage.Items=10
-Producer.StartPage.Newswire=30
-
-
-# todo: do we need those?
-
-Xsl.Content=producer/content.xsl
-Xsl.Fo.Content=producer/frontpage_fo.xsl
-Xsl.StartPage=producer/index.xsl
-Xsl.TopicList=producer/topic.xsl
-Xsl.OpenList=producer/open.xsl
-Xsl.Wap=producer/wml2.xsl
-ClearXslCache=no
\ No newline at end of file
public TemplateModel get(String aKey) throws TemplateModelException {
try {
- if (!valuesCache.containsKey(aKey)) {
- Object value = map.get(aKey);
+ if (!valuesCache.containsKey(aKey)) {
+ Object value = map.get(aKey);
- if (value == null && !map.containsKey(aKey))
- throw new TemplateModelException("MapAdapter: no key "+aKey+" available");
+ if (value == null && !map.containsKey(aKey)) {
+ throw new TemplateModelException("MapAdapter: no key "+aKey+" available");
+ }
- valuesCache.put(aKey, makeAdapter(value));
- }
+ valuesCache.put(aKey, makeAdapter(value));
+ }
- return (TemplateModel) valuesCache.get(aKey);
- }
- catch (TemplateModelException e) {
- throw e;
- }
- catch (Throwable t) {
- throw new TemplateModelException(t.getMessage());
- }
+ return (TemplateModel) valuesCache.get(aKey);
+ }
+ catch (TemplateModelException e) {
+ throw e;
+ }
+ catch (Throwable t) {
+ throw new TemplateModelException(t.getMessage());
+ }
}
}
} catch (Throwable t) {}
}
+ public static Map allSettings() {
+ return configHash;
+ }
+
}
super();
};
- public void parseFile(String aFileName, ProducerNodeBuilderLibrary aBuilderLibrary, Map aProducerFactories) throws ConfigFailure {
+ public void parseFile(String aFileName, ProducerNodeBuilderLibrary aBuilderLibrary, Map aProducerFactories) throws ProducerConfigFailure {
parseFile(aFileName, aBuilderLibrary, aProducerFactories, new Vector());
-
}
- public void parseFile(String aFileName, ProducerNodeBuilderLibrary aBuilderLibrary, Map aProducerFactories, List aUsedFiles) throws ConfigFailure {
+ public void parseFile(String aFileName, ProducerNodeBuilderLibrary aBuilderLibrary, Map aProducerFactories, List aUsedFiles) throws ProducerConfigFailure {
try {
builderLibrary = aBuilderLibrary;
scriptedNodeBuilderLibrary = new ProducerNodeBuilderLibrary();
handler.includeFile(aFileName);
}
catch (Throwable e) {
- if (e instanceof SAXParseException && ((SAXParseException) e).getException() instanceof ConfigFailure) {
- throw (ConfigFailure) ((SAXParseException) e).getException();
+ if (e instanceof SAXParseException && ((SAXParseException) e).getException() instanceof ProducerConfigFailure) {
+ throw (ProducerConfigFailure) ((SAXParseException) e).getException();
}
else {
- e.printStackTrace();
- throw new ConfigFailure( e.getMessage() );
+ throw new ProducerConfigFailure( e );
}
}
}
locator=aLocator;
}
- private void includeFile(String aFileName) throws ConfigFailure, SAXParseException, SAXException {
+ private void includeFile(String aFileName) throws ProducerConfigExc, ProducerConfigFailure, SAXParseException, SAXException {
File file;
SAXParser parser;
System.err.println("about to include "+file.getCanonicalPath());
if (includeFileStack.contains(file.getCanonicalPath())) {
- throw new ConfigFailure("recursive inclusion of file "+file.getCanonicalPath(), getLocatorDescription(locator));
+ throw new ProducerConfigExc("recursive inclusion of file "+file.getCanonicalPath());
}
usedFiles.add(file);
}
}
catch (ParserConfigurationException e) {
- throw new ConfigFailure("Internal exception while including \""+aFileName+"\": "+e.getMessage(), e, getLocatorDescription(locator));
+ throw new ProducerConfigExc("Internal exception while including \""+aFileName+"\": "+e.getMessage());
}
catch (SAXParseException e) {
throw e;
}
- catch (ConfigFailure e) {
+ catch (ProducerConfigFailure e) {
throw e;
}
catch (FileNotFoundException e) {
- throw new ConfigFailure("Include file \""+aFileName+"\" not found: "+e.getMessage(), e, getLocatorDescription(locator));
+ throw new ProducerConfigExc("Include file \""+aFileName+"\" not found: "+e.getMessage());
}
catch (IOException e) {
- throw new ConfigFailure("unable to open include file \""+aFileName+"\": "+e.getMessage(), e, getLocatorDescription(locator));
+ throw new ProducerConfigExc("unable to open include file \""+aFileName+"\": "+e.getMessage());
}
}
String fileName=anAttributes.getValue("file");
if (fileName==null) {
- throw new ConfigFailure("include has no file attribute", getLocatorDescription(locator));
+ throw new ProducerConfigExc("include has no file attribute");
}
includeFile(fileName);
manager.pushHandler( manager.currentHandler().startElement(aQualifiedName, attributesMap) );
}
}
+ catch (ProducerConfigExc e) {
+ throw new SAXParseException(e.getMessage(), locator, new ProducerConfigExc("Config error at ["+getLocatorDescription(locator)+"]: "+e.getMessage()));
+ }
catch (Exception e) {
- e.printStackTrace(System.out);
throw new SAXException(e);
}
}
}
}
}
+ catch (ProducerConfigExc e) {
+ throw new SAXParseException(e.getMessage(), locator, new ProducerConfigExc("Config error at ["+getLocatorDescription(locator)+"]: "+e.getMessage()));
+ }
catch (Exception e) {
- e.printStackTrace(System.out);
throw new SAXException(e);
}
}
public void characters(char[] aBuffer, int aStart, int anEnd) throws SAXParseException {
String text = new String(aBuffer, aStart, anEnd).trim();
if ( text.length() > 0) {
- throw new SAXParseException("Text not allowed", locator, new ConfigFailure("text not allowed", getLocatorDescription(locator)));
+ throw new SAXParseException("Text not allowed", locator, new ProducerConfigExc("Config error at ["+getLocatorDescription(locator)+"]: Text not allowed"));
}
}
}
private final static String PRODUCER_VERB_NAME_ATTRIBUTE = "name";
+ private final static String PRODUCER_VERB_DESCRIPTION_ATTRIBUTE = "description";
private final static String PRODUCER_VERB_DEFAULT_ATTRIBUTE = "default";
private final static String[] PRODUCER_VERB_REQUIRED_ATTRIBUTES = { PRODUCER_VERB_NAME_ATTRIBUTE };
- private final static String[] PRODUCER_VERB_OPTIONAL_ATTRIBUTES = { PRODUCER_VERB_DEFAULT_ATTRIBUTE };
+ private final static String[] PRODUCER_VERB_OPTIONAL_ATTRIBUTES = { PRODUCER_VERB_DEFAULT_ATTRIBUTE, PRODUCER_VERB_DESCRIPTION_ATTRIBUTE };
public class ProducerVerbsSectionHandler extends SectionHandler {
private Map verbs;
private String defaultVerb;
private String currentVerb;
+ private String currentVerbDescription;
public ProducerVerbsSectionHandler() {
verbs = new HashMap();
defaultVerb = currentVerb;
}
+ if (anAttributes.containsKey( PRODUCER_VERB_DESCRIPTION_ATTRIBUTE ))
+ currentVerbDescription = (String) anAttributes.get( PRODUCER_VERB_DESCRIPTION_ATTRIBUTE );
+ else
+ currentVerbDescription = "";
+
return new ProducerNodeSectionHandler();
}
else throw new ProducerConfigExc("Only 'verb' tags allowed here, '" + aTag + "' encountered.");
import multex.Exc;
import java.util.*;
+import mir.generator.*;
public class ParameterExpander {
final static String NODE_SEPARATOR = ".";
return parseUntil(MAX_OPERATOR_LEVEL);
}
- private Object parseSet() {
+ private List parseList() {
Token token;
Object expression;
- Set result = new HashSet();
+ List result = new Vector();
token = scanner.scan();
if (!(token instanceof LeftParenthesisToken)) {
- throw new RuntimeException("( expected after in keyword");
+ throw new RuntimeException("( expected");
}
if (scanner.peek() instanceof RightParenthesisToken) {
Token token;
Object currentValue = valueMap;
Object qualifier;
+ List parameters;
do {
token = scanner.scan();
token = scanner.scan();
if (!(token instanceof RightSquareBraceToken))
throw new RuntimeException("] expected");
+
+ if (currentValue instanceof Map) {
+ currentValue = ((Map) currentValue).get(qualifier);
+ }
+ else {
+ throw new RuntimeException("cannot reference into anything other than a map");
+ }
}
else if (token instanceof IdentifierToken) {
qualifier = ((IdentifierToken) token).getName();
- }
- else
- throw new RuntimeException("fieldname or [ expected");
- if (currentValue!=null) {
if (currentValue instanceof Map) {
currentValue = ((Map) currentValue).get(qualifier);
}
throw new RuntimeException("cannot reference into anything other than a map");
}
}
- else {
- // throw? or allow null.null?
+ else if (token instanceof LeftParenthesisToken) {
+ if (currentValue instanceof Generator.GeneratorFunction) {
+ parameters = parseList();
+ try {
+ currentValue = ((Generator.GeneratorFunction) currentValue).perform(parameters);
+ }
+ catch (GeneratorExc t) {
+ throw new RuntimeException(t.getMessage());
+ }
+ }
+ else
+ throw new RuntimeException("not a function");
}
+ else
+ throw new RuntimeException("fieldname or [ expected");
- if (scanner.peek() instanceof PeriodToken)
- {
- scanner.scan();
+ if (scanner.peek() instanceof PeriodToken ||
+ scanner.peek() instanceof LeftSquareBraceToken ||
+ scanner.peek() instanceof LeftParenthesisToken) {
done = false;
+
+ if (scanner.peek() instanceof PeriodToken)
+ scanner.scan();
}
else
done = true;
scanner.scan();
if (isINOperator(token)) {
- value2 = parseSet();
+ value2 = parseList();
}
else {
value2 = parseUntil(binaryOperatorLevel(token));
private Object expandOperatorExpression(Token aToken, Object aValue1, Object aValue2) {
if (isINOperator(aToken)) {
- if (!(aValue2 instanceof Set)) {
- throw new RuntimeException("Internal error: set expected");
+ if (!(aValue2 instanceof List)) {
+ throw new RuntimeException("Internal error: List expected");
}
- Iterator i = ((Set) aValue2).iterator();
+ Iterator i = ((List) aValue2).iterator();
while (i.hasNext()) {
if (areEqual(aValue1, i.next()))
package mir.util;
import java.util.*;
+import gnu.regexp.*;
public class StringRoutines {
do {
nextPosition = indexOfCharacters(aText, CHARACTERS_TO_ESCAPE, position);
- System.out.println("encodeHTML: "+ position + ":" + aText + " : " + nextPosition);
if (nextPosition<0)
nextPosition = aText.length();
return result.toString();
}
+
+ public static String performRegularExpressionReplacement(String aSource,
+ String aSearchExpression, String aReplacement) throws Exception {
+
+ RE regularExpression;
+
+ regularExpression = new RE(aSearchExpression);
+
+ return regularExpression.substituteAll(aSource, aReplacement);
+ }
+
+ public static boolean performRegularExpressionSearch(String aSource,
+ String aSearchExpression) throws REException {
+ RE regularExpression;
+
+ regularExpression = new RE(aSearchExpression);
+
+ return regularExpression.isMatch(aSource);
+ }
+
+/*
+ return StringUtil.createHTML(
+ StringUtil.deleteForbiddenTags(aText),
+ MirGlobal.getConfigProperty("Producer.ImageRoot"),
+ MirGlobal.getConfigProperty("Producer.MailLinkName"),
+ MirGlobal.getConfigProperty("Producer.ExtLinkName"),
+ MirGlobal.getConfigProperty("Producer.IntLinkName")
+ );
+ public static String createHTML(String content){
+ content=convertNewline2Break(content);
+ content=convertNewline2P(content);
+ content=createMailLinks(content);
+ content=createURLLinks(content);
+ return content;
+
+ public static String convertNewline2Break(String haystack) {
+ return re_newline2br.substituteAll(haystack,"$0<br />");
+ }
+
+ public static String convertNewline2P(String haystack) {
+ return re_brbr2p.substituteAll(haystack,"\n</p><p>");
+ }
+
+ public static String createMailLinks(String haystack, String imageRoot, String mailImage) {
+ return re_mail.substituteAll(haystack,"<img src=\""+imageRoot+"/"+mailImage+"\" border=\"0\"/> <a href=\"mailto:$0\">$0</a>");
+ }
+
+ public static String createURLLinks(String haystack, String title, String imageRoot,String extImage) {
+ if (title == null) {
+ return re_url.substituteAll(haystack,"<img src=\""+imageRoot+"/"+extImage+"\" border=\"0\"/> <a href=\"$0\">$0</a>");
+ } else {
+ title = removeHTMLTags(title);
+ return re_url.substituteAll(haystack,"<img src=\""+imageRoot+"/"+extImage+"\" border=\"0\"/> <a href=\"$0\">"+title+"</a>");
+ }
+ }
+
+ }
+*/
}
\ No newline at end of file
}
public void addJob(String aProducerFactory, String aVerb) {
-// ML: TODO: should check if a similar job is already pending
producerJobQueue.appendJob(new ProducerJob(aProducerFactory, aVerb));
log.println(aProducerFactory+"."+aVerb+" added to queue");
log.flush();
}
+ public void addTask(ProducerTask aTask) {
+ addJob(aTask.getProducer(), aTask.getVerb());
+ }
+
+ public void addTasks(List aTasks) {
+ Iterator i = aTasks.iterator();
+
+ while (i.hasNext()) {
+ addTask((ProducerTask) i.next());
+ }
+ }
+
public void printQueueStatus(PrintWriter aWriter) {
Iterator iterator = producerJobQueue.makeJobListSnapshot().iterator();
producerJobQueue.cleanupJobs();
}
}
+ public static class ProducerTask {
+ private String producer;
+ private String verb;
+
+ public ProducerTask(String aProducer, String aVerb) {
+ producer = aProducer;
+ verb = aVerb;
+ }
+
+ public String getVerb() {
+ return verb;
+ }
+
+ public String getProducer() {
+ return producer;
+ }
+ }
}
\ No newline at end of file
import javax.servlet.http.*;
import mir.misc.*;
+import mir.util.*;
import mircoders.global.*;
import mircoders.localizer.*;
import mircoders.entity.*;
public class MirBasicOpenPostingLocalizer implements MirOpenPostingLocalizer {
+ private List afterContentProducerTasks;
+ private List afterCommentProducerTasks;
+
protected static Logfile logger = Logfile.getInstance( MirGlobal.getConfigProperty("Home") + "/" + MirGlobal.getConfigProperty("Mir.Localizer.Logfile"));
+ public MirBasicOpenPostingLocalizer() {
+ String contentProducers = MirGlobal.getConfigProperty("Mir.Localizer.OpenPosting.ContentProducers");
+ String commentProducers = MirGlobal.getConfigProperty("Mir.Localizer.OpenPosting.CommentProducers");
+
+ afterContentProducerTasks = parseProducerTaskList(contentProducers);
+ afterCommentProducerTasks = parseProducerTaskList(commentProducers);
+ }
+
public void afterContentPosting() {
- MirGlobal.producerEngine().addJob("media", "new");
- MirGlobal.producerEngine().addJob("content", "new");
- MirGlobal.producerEngine().addJob("startpage", "(default)");
- MirGlobal.producerEngine().addJob("synchronization", "run");
-
- MirGlobal.producerEngine().addJob("openposting", "new");
- MirGlobal.producerEngine().addJob("topics", "new");
- MirGlobal.producerEngine().addJob("synchronization", "run");
+ MirGlobal.producerEngine().addTasks(afterContentProducerTasks);
}
public void afterContentPosting(EntityContent aContent) {
afterContentPosting();
}
-
+
public void afterCommentPosting() {
- MirGlobal.producerEngine().addJob("content", "new");
- MirGlobal.producerEngine().addJob("synchronization", "run");
+ MirGlobal.producerEngine().addTasks(afterCommentProducerTasks);
}
public void afterCommentPosting(EntityComment aComment) {
return locale.getLanguage();
}
+
+ protected List parseProducerTaskList(String aList) {
+ Iterator i;
+ List result = new Vector();
+
+ i = ParameterExpander.splitString(aList, ";").iterator();
+ while (i.hasNext()) {
+ String taskExpression = (String) i.next();
+ List parts = ParameterExpander.splitString(taskExpression, ".");
+
+ if (parts.size()!=2)
+ logger.printError("Invalid producer expression: '" + taskExpression + "'");
+ else
+ result.add(new ProducerEngine.ProducerTask((String) parts.get(0), (String) parts.get(1)));
+ }
+
+ return result;
+ }
}
import freemarker.template.utility.*;
import mir.misc.*;
import mir.entity.*;
+import mir.entity.adapter.*;
import mir.util.*;
import mircoders.module.*;
import mircoders.storage.*;
protected static Logfile logger = Logfile.getInstance( MirGlobal.getConfigProperty("Home") + "/" + MirGlobal.getConfigProperty("Mir.Localizer.Logfile"));
public void initializeGenerationValueSet(Map aValueSet) {
- // ML: these config settings will be included more beautifully as soon as the new config system is in place
+ Iterator i;
Map configMap = new HashMap();
Map utilityMap = new HashMap();
+// obsolete:
configMap.put("producerDocRoot", MirGlobal.getConfigProperty("Producer.DocRoot"));
configMap.put("storageRoot", MirGlobal.getConfigProperty("Producer.StorageRoot"));
configMap.put("productionHost", MirGlobal.getConfigProperty("Producer.ProductionHost"));
configMap.put("imagePath", MirGlobal.getConfigProperty("Producer.Image.Path"));
configMap.put("mirVersion", MirGlobal.getConfigProperty("Mir.Version"));
configMap.put("defEncoding", MirGlobal.getConfigProperty("Mir.DefaultEncoding"));
- configMap.put("all", Configuration.getConfs());
+
+// "new":
+ configMap.putAll( MirConfig.allSettings() );
utilityMap.put("compressWhitespace", new freemarker.template.utility.CompressWhitespace() );
utilityMap.put("encodeHTML", new GeneratorHTMLFunctions.encodeHTMLGeneratorFunction());
EntityList languageList=null;
try {
-// ModuleLinksImcs linksImcsModule = new ModuleLinksImcs(DatabaseLinksImcs.getInstance());
ModuleTopics topicsModule = new ModuleTopics(DatabaseTopics.getInstance());
ModuleLanguage languageModule = new ModuleLanguage(DatabaseLanguage.getInstance());
topicList = topicsModule.getTopicsList();
-// entityList = linksImcsModule.getByWhereClause("", "sortpriority, title", -1);
-// parentList = linksImcsModule.getByWhereClause("to_parent_id=NULL", "sortpriority, title", -1);
languageList = languageModule.getByWhereClause("", "id", -1);
}
catch (Throwable t) {
articleTypeMap.put("feature", "2");
articleTypeMap.put("topicspecial", "3");
articleTypeMap.put("startspecial", "4");
+
+ try {
+ i = new EntityIteratorAdapter( "", "", 20, MirGlobal.localizer().dataModel().adapterModel(), "articleType" );
+
+ while (i.hasNext()) {
+ EntityAdapter articleType = (EntityAdapter) i.next();
+
+ articleTypeMap.put(articleType.get("name"), articleType.get("id"));
+ }
+ }
+ catch (Throwable t) {
+ logger.printError("initializeGenerationValueSet: Exception "+t.getMessage());
+ }
+
aValueSet.put("articletype", articleTypeMap);
};