Older blog entries for cdent (starting at number 74)

13 Mar 2012 (updated 13 Mar 2012 at 19:13 UTC) »

20120313

At some point /_tiddlywiki stopped working, so will need to figure that out before making much more progress on TiddlyWikiNeeds.

Turns out this is the result of the recent changes to fat in TiddlyWeb.

Similar changes also needed (and done) in the TiddlySpaceFollowingPlugin



I extracted the csrf protection code that bengillies wrote into its own plugin: tiddlywebplugins.csrf. The rationale is that TiddlyWeb is perfectly capable of supporting other apps that might want to do form POSTs, not just TiddlySpace.



Both of the above changes are now in a new tiddlyspace 1.0.91, deployed on tiddlyspace.com.

Syndicated 2012-03-13 11:16:28 (Updated 2012-03-13 18:31:12) from cdent

minlog

minlog

Syndicated 2012-03-13 11:15:53 (Updated 2012-03-13 11:17:49) from cdent

monkeypatch

monkeypatch

Here is some content

Syndicated 2012-03-13 10:48:19 from cdent

InlineJavaScriptPlugin

NameInlineJavascriptPlugin
Sourcehttp://www.TiddlyTools.com/#InlineJavascriptPlugin
Documentationhttp://www.TiddlyTools.com/#InlineJavascriptPluginInfo
Version1.9.6
AuthorEric Shulman
Licensehttp://www.TiddlyTools.com/#LegalStatements
CoreVersion2.1
Typeplugin
DescriptionInsert Javascript executable code directly into your tiddler content.
Call directly into TW core utility routines, define new functions, calculate values, add dynamically-generated TiddlyWiki-formatted output into tiddler content, or perform any other programmatic actions each time the tiddler is rendered.
Documentation
see InlineJavascriptPluginInfo
Revisions
2010.12.15 1.9.6 allow (but ignore) type="..." syntax
please see InlineJavascriptPluginInfo for additional revision details
2005.11.08 1.0.0 initial release
Code
version.extensions.InlineJavascriptPlugin= {major: 1, minor: 9, revision: 6, date: new Date(2010,12,15)};

config.formatters.push( {
	name: "inlineJavascript",
	match: "\\<script",
	lookahead: "\\<script(?: type=\\\"[^\\\"]*\\\")?(?: src=\\\"([^\\\"]*)\\\")?(?: label=\\\"([^\\\"]*)\\\")?(?: title=\\\"([^\\\"]*)\\\")?(?: key=\\\"([^\\\"]*)\\\")?( show)?\\>((?:.|\\n)*?)\\</script\\>",
	handler: function(w) {
		var lookaheadRegExp = new RegExp(this.lookahead,"mg");
		lookaheadRegExp.lastIndex = w.matchStart;
		var lookaheadMatch = lookaheadRegExp.exec(w.source)
		if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
			var src=lookaheadMatch[1];
			var label=lookaheadMatch[2];
			var tip=lookaheadMatch[3];
			var key=lookaheadMatch[4];
			var show=lookaheadMatch[5];
			var code=lookaheadMatch[6];
			if (src) { // external script library
				var script = document.createElement("script"); script.src = src;
				document.body.appendChild(script); document.body.removeChild(script);
			}
			if (code) { // inline code
				if (show) // display source in tiddler
					wikify("{{{\n"+lookaheadMatch[0]+"\n}}}\n",w.output);
				if (label) { // create 'onclick' command link
					var link=createTiddlyElement(w.output,"a",null,"tiddlyLinkExisting",wikifyPlainText(label));
					var fixup=code.replace(/document.write\s*\(/gi,'place.bufferedHTML+=(');
					link.code="function _out(place,tiddler){"+fixup+"\n};_out(this,this.tiddler);"
					link.tiddler=w.tiddler;
					link.onclick=function(){
						this.bufferedHTML="";
						try{ var r=eval(this.code);
							if(this.bufferedHTML.length || (typeof(r)==="string")&&r.length)
								var s=this.parentNode.insertBefore(document.createElement("span"),this.nextSibling);
							if(this.bufferedHTML.length)
								s.innerHTML=this.bufferedHTML;
							if((typeof(r)==="string")&&r.length) {
								wikify(r,s,null,this.tiddler);
								return false;
							} else return r!==undefined?r:false;
						} catch(e){alert(e.description||e.toString());return false;}
					};
					link.setAttribute("title",tip||"");
					var URIcode='javascript:void(eval(decodeURIComponent(%22(function(){try{';
					URIcode+=encodeURIComponent(encodeURIComponent(code.replace(/\n/g,' ')));
					URIcode+='}catch(e){alert(e.description||e.toString())}})()%22)))';
					link.setAttribute("href",URIcode);
					link.style.cursor="pointer";
					if (key) link.accessKey=key.substr(0,1); // single character only
				}
				else { // run script immediately
					var fixup=code.replace(/document.write\s*\(/gi,'place.innerHTML+=(');
					var c="function _out(place,tiddler){"+fixup+"\n};_out(w.output,w.tiddler);";
					try	 { var out=eval(c); }
					catch(e) { out=e.description?e.description:e.toString(); }
					if (out && out.length) wikify(out,w.output,w.highlightRegExp,w.tiddler);
				}
			}
			w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length;
		}
	}
} )

Backward-compatibility for TW2.1.x and earlier
if (typeof(wikifyPlainText)=="undefined") window.wikifyPlainText=function(text,limit,tiddler) {
	if(limit > 0) text = text.substr(0,limit);
	var wikifier = new Wikifier(text,formatter,null,tiddler);
	return wikifier.wikifyPlain();
}

GLOBAL FUNCTION: $(...) 'shorthand' convenience syntax for document.getElementById()
if (typeof($)=='undefined') { function $(id) { return document.getElementById(id.replace(/^#/,'')); } }

Syndicated 2012-03-13 10:43:58 from cdent

TestForm2

Tiddler Title:

<script label="Create Tiddler" title="Create Tiddler from Inside Javascript" key="X">


Create Tiddler based on User Input to HTML Form

var myTitle;
myTitle = document.getElementById("theTitle").value;
myTitle = myTitle.trim();

if (myTitle == || myTitle == 'none')
{
alert('Title is Empty\nMust Enter Title to Continue');
}
else
{
alert('Tiddler will be Titled "'+myTitle+'"');

myText = "!"+myTitle+"\nHere is some content";

var tid = new Tiddler(myTitle);
tid.title = myTitle;
tid.text = myText;
tid.tags = new Array("tag1 tag2 tag3");
tid.creator = config.extensions.tiddlyweb.username;
tid.fields = merge({}, config.defaultCustomFields)
tid = store.saveTiddler(tid);
autoSaveChanges(null, [tid]);

}


Trim Function - Removes Leading & Trailing Spaces

String.prototype.trim = function() {
return this.replace(/(^\s*)|(\s*$)/g,"")
}


</script>

Syndicated 2012-03-13 10:42:35 (Updated 2012-03-13 10:47:36) from cdent

20120312

Did some thinking about TiddlyWikiNeeds, particularly the downloaded TiddlyWiki, resulting in a groups posting and a github branch called downloadlite.

The basic idea is that the downloaded TiddlyWiki should be "lite", meaning not having extraneous stuff in it.

Syndicated 2012-03-12 17:28:52 from cdent

zzzeek : Pycon 2012 : Hand Coded Applications with SQLAlchemy

Here's the slides from my Pycon 2012 talk, "Hand Coded Applications with SQLAlchemy".
zzzeek : Pycon 2012 : Hand Coded Applications with SQLAlchemy

Syndicated 2012-03-12 08:49:24 from cdent

13 Mar 2012 (updated 14 Mar 2012 at 22:12 UTC) »

20120311

I endeavored to do some testing of the twp.mysql2 to twp.mysql3 transition today, but without complete success. On my main dev machine, I've upgraded to mysql 5.5. I did that to ensure that the new code solves the problems of working with 5.5. However, on 5.5 the old code doesn't work so I can't do a test migration on that machine. I have a few others to choose from.

The migration process is primarily documented here but there are some additional details:

  • Put up the 503 error setup on tiddlyspace.com
  • Turn off all the database related cronjobs
  • Make a full backup of the database
  • Put innodb support back in mysql by editing my.cnf
  • Before the migration the mysql3 branch of the TiddlySpace code should be merged to master.
  • Shutdown memcached, remove tiddlywebplugins.caching as the store, switching back to direct twp.tiddlyspace.store.
  • Migrate according to the other docs.
  • After the data is migrated but before the web server is started back up, the new code (from the branch) needs to be installed.
  • turn back on the cronjobs (in /etc/cron.d and /etc/cron.daily)

Syndicated 2012-03-11 15:33:46 (Updated 2012-03-14 21:40:57) from cdent

20120309

  • Released a new version of TiddlyWeb with a fix from fnd: render and fat on JSON tiddler and tiddlers are now mutually independent. This now makes it possible to get JSON that has a render field but doesn't have a text field.
  • Scheduled Maintenance 14 March, 2012.
  • Made sure that the auxbags branch of the TiddlySpace code is still working after merging in the latest master. I would still like to see some kind of AuxBags thing happen, but it's hard to say that we need it badly.

Syndicated 2012-03-09 17:26:08 (Updated 2012-03-09 18:19:55) from cdent

Scheduled Maintenance 14 March, 2012

After 11:59pm on the 14th of March there will be a 6 hour maintenance window during which tiddlyspace.com will be unavailable. See the google groups announcement.

Syndicated 2012-03-09 17:02:55 (Updated 2012-03-09 17:02:05) from cdent

65 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!