From b9ac38a361cac129fff7c28af584e84af1968799 Mon Sep 17 00:00:00 2001 From: "psyc://psyced.org/~lynX" <@> Date: Mon, 1 Mar 2010 17:46:42 +0100 Subject: [PATCH] no textdb proliferation necessary --- world/drivers/ldmud/master/accept.c | 12 ++++++------ world/net/library/htbasics.c | 7 ++++--- world/net/place/archetype.gen | 12 +++++++++--- world/net/place/threads.c | 20 +++++++++++++------- 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/world/drivers/ldmud/master/accept.c b/world/drivers/ldmud/master/accept.c index 880c8ff..b5c849c 100644 --- a/world/drivers/ldmud/master/accept.c +++ b/world/drivers/ldmud/master/accept.c @@ -384,12 +384,6 @@ object compile_object(string file) { return rob; } # endif - if (sscanf(file, "%s/text.c", path) && path != "") { - rob = clone_object(NET_PATH "text"); - rob -> sPath(path); - D2(if (rob) PP(("DB CLONED: %O becomes %s/text\n", rob, path));) - return rob; - } if (sscanf(file, "place/%s.c", name) && name != "") { #ifdef SANDBOX string t; @@ -450,6 +444,12 @@ object compile_object(string file) { rob, name, path));) return rob; } + if (sscanf(file, "%s/text.c", path) && path != "") { + rob = clone_object(NET_PATH "text"); + rob -> sPath(path); + D2(if (rob) PP(("DB CLONED: %O becomes %s/text\n", rob, path));) + return rob; + } # ifdef JABBER_PATH if (abbrev("S:xmpp:", file)) { rob = clone_object(JABBER_PATH "gateway"); diff --git a/world/net/library/htbasics.c b/world/net/library/htbasics.c index 7d92f33..3186093 100644 --- a/world/net/library/htbasics.c +++ b/world/net/library/htbasics.c @@ -4,15 +4,16 @@ // html-escaping of generic strings -lynx // to make sure they won't trigger -// html commands +// html commands. this should become an inline macro, maybe use +// regreplace if that is faster, or even better, be implemented in C +// together with an auto hyperlink and a linebreak conversion option. // -varargs string htquote(string s, int newlines) { +varargs string htquote(string s) { ASSERT("htquote", stringp(s), s) s = replace(s, "&", "&"); // s = replace(s, "\"", """); //" s = replace(s, "<", "<"); s = replace(s, ">", ">"); - if (newlines) s = replace(s, "\n", "
\n"); return s; } diff --git a/world/net/place/archetype.gen b/world/net/place/archetype.gen index 4bb4935..8151ced 100644 --- a/world/net/place/archetype.gen +++ b/world/net/place/archetype.gen @@ -216,13 +216,17 @@ int qSaveImmediately() { #endif } +#ifdef _limit_amount_history_persistent int qHistoryPersistentLimit() { return _limit_amount_history_persistent; } +#endif +#ifdef _limit_amount_history_export int qHistoryExportLimit() { return _limit_amount_history_export; } +#endif // to be overloaded by place.gen qNewsfeed() { return 0; } @@ -281,7 +285,7 @@ msgView(source, mc, data, vars, showingLog) { s = psyctext( T(mc, ""), vars, data, source ); if (strlen(s) < 7) return; s = s[..<2]; -// htquote ist nicht so gründlich wie für javascript notwendig +// htquote doesn't do the job as necessary for javascript s = regreplace(s, "\&", "\\\&", 1); s = regreplace(s, "<", "\\\<", 1); s = regreplace(s, ">", "\\\>", 1); @@ -468,7 +472,8 @@ showTopic(rcpt, verbose, mc) { htget(prot, query, headers, qs, data, noprocess) { //P3((">> archetype.gen:htget(%O, %O, %O, %O, %O, %O)\n", prot, query, headers, qs, data, noprocess)) # ifdef PLACE_SCRATCHPAD - sTextPath(query["layout"] || MYNICK, query["lang"], "html"); + // we *could* allow each place to define its own textdb.. but why? + sTextPath(query["layout"] /* || MYNICK */, query["lang"], "html"); if (!noprocess && (!qs || query["scratchpad"])) { string rand, buf, len; // microscopic wiki functionality .. cheap imitation of tobi's save.pike @@ -607,8 +612,9 @@ htget(prot, query, headers, qs, data, noprocess) { break; #endif default: - sTextPath(query["layout"] || MYNICK, query["lang"], "html"); + sTextPath(query["layout"], query["lang"], "html"); htok(prot); + // we could output a css something here.. // w("_HTML_head"); write("\n\n"); logView(a, "html", 15); diff --git a/world/net/place/threads.c b/world/net/place/threads.c index 22fe4dd..973b108 100644 --- a/world/net/place/threads.c +++ b/world/net/place/threads.c @@ -274,8 +274,12 @@ varargs string htmlComments(array(mixed) entries, int level) { string ht = "", style; foreach(entry : entries) { vars = entry[LOG_VARS]; + ht = htquote(vars["_text"]); + ht = replace(ht, "\n", "
\n"); + style = level ? "style='padding-left: " + level + "em'" : ""; - ht += "
" + vars["_nick"] + ": " + htquote(vars["_text"], 1) + "
\n"; + ht += "
" + vars["_nick"] + ": "+ ht +"
\n"; + if (sizeof(entry) >= LOG_CHILDREN + 1) ht += htmlComments(entry[LOG_CHILDREN], level + 1); } return ht; @@ -295,8 +299,7 @@ varargs string htmlEntries(array(mixed) entries, int nojs, string chan, string s foreach (entry : entries) { P3((">>> entry: %O\n", entry)) vars = entry[LOG_VARS]; - - text = htquote(vars["_text"], 1); + text = replace(htquote(vars["_text"]), "\n", "
\n"); string comments = ""; if (sizeof(entry) >= LOG_CHILDREN + 1) comments = htmlComments(entry[LOG_CHILDREN]); @@ -349,13 +352,17 @@ string rssEntries(array(mixed) entries) { "\n"; mapping entry, vars; + string ht; foreach (entry : entries) { vars = entry[LOG_VARS]; + ht = htquote(vars["_text"]); + // does RSS define
for linebreaks? + //ht = replace(ht, "\n", "
\n"); rss += "\n\n" "\t"+ (vars["_title"] || "no title") +"\n" "\thttp://" + HTTP_OR_HTTPS_URL + "/" + pathName() + "?id=" + vars["_id"] + "\n" - "\t" + vars["_text"] + "\n" + "\t"+ ht +"\n" "\t" + isotime(ctime(vars["_time_place"]), 1) + "\n" "\t" + vars["_nick"] + "\n" "\n"; @@ -379,6 +386,7 @@ string jsEntries(array(mixed) entries) { mapping entry, vars; foreach (entry : entries) { vars = entry[LOG_VARS]; + // should probably be htquoted too js += "new Entry(" + vars["_id"] + "," "\"" + vars["_title"] + "\"," "\"" + vars["_nick"] + "\"," @@ -447,8 +455,7 @@ htget(prot, query, headers, qs, data) { int limit = to_int(query["limit"]) || DEFAULT_BACKLOG; int offset = to_int(query["offset"]); string webact = PLACE_PATH + MYLOWERNICK; - // shouldnt it be "html" here? - sTextPath(query["layout"] || MYNICK, query["lang"], "ht"); + sTextPath(query["layout"], query["lang"], "html"); // Kommentare anzeigen if (query["id"]) { @@ -545,7 +552,6 @@ htget(prot, query, headers, qs, data) { } else if (export == "rss" || export == "rdf") { // export als RSS // scheinbar gibt es ein limit von 15 items / channel - // htquote auch hier anwenden // check If-Modified-Since header htok3(prot, "text/xml", ""); rssExport(limit, offset);