Wiki on a Stick Official Forums

A personal wiki living in a self-modifying XHTML file

You are not logged in.

#1 16-11-2009 16:15:41

FBnil
WoaS typist
Registered: 13-11-2009
Posts: 141

Configurable 'new page'

A special page that can be programmed in Javascript, here is a demo:

http://www.sagradafamilia.nl/nilton/woas-0.9.6nil.htm

Offline

 

#2 17-11-2009 04:32:16

Little Girl
Moderator
Registered: 26-07-2009
Posts: 254
Website

Re: Configurable 'new page'

You are an absolute genius with code! smile

Beautiful job - I'm beside myself with admiration for the sheer elegance of what you've done! Not only did you fix a few niggling problems (like the search focus and image embedding in Firefox) and do a really nice job of cleaning up the existing code, but you added a bunch of delicious goodies for us backyard code junkies to poke around in and have fun with. Stunning, absolutely stunning!

Do you mind if those of us who have gone off in our own direction with WoaS also use your code in our wikis?


There is no spoon.

Offline

 

#3 17-11-2009 19:17:12

FBnil
WoaS typist
Registered: 13-11-2009
Posts: 141

Re: Configurable 'new page'

But of course! I'd love to see those things ported to BOAS!

Offline

 

#4 18-11-2009 06:59:23

Little Girl
Moderator
Registered: 26-07-2009
Posts: 254
Website

Re: Configurable 'new page'

Thank you! You're a sweetheart. <3

I was just about to release a new version when I saw the magic you created. The release is being postponed so your goodies can be added in, complete with Help pages to explain how to work them. Thanks to you, this is going to be a huge release!

By the way, you mentioned the forward slash bug on the Main Page of your wiki. That's caused by function _get_data(marker, source, full, start) and commenting out this part:

Code:

    if (body_ofs != -1) {
        // XHTML hotfixes (FF doesn't either save correctly)
        source = source.substring(0, body_ofs) + source.substring(body_ofs).
                replace(/<(img|hr|br|input|meta)[^>]*>/gi, function(str, tag) {
        var l=str.length;
        if (str.charAt(l-1)!='/')
            str = str.substr(0, l-1)+" />";
        return str;
    });

    }

gets rid of the slashes, but probably isn't the best fix.I occasionally play around with it to see if I can luck into figuring it out without destroying anything, but I'll bet you can perform your wizardry on that function to get it to behave itself so it doesn't need to be commented. smile

Last edited by Little Girl (18-11-2009 10:09:21)


There is no spoon.

Offline

 

#5 18-11-2009 08:12:51

Snaga
Experienced newbie
Registered: 04-04-2008
Posts: 85

Re: Configurable 'new page'

I'm not as competent as LG but I sure appreciate the fixes.

But due to my inexperience I want to ask a favor:

There are some really great things coming through the forums, even this week.  Long-awaited fixes, new features, etc.  May I ask that we all follow these guidelines for between-release code changes?

1) Leave the original code in place, commented out.

2) Sign, date, label, and hopefully document your changes immediately following that.  Mark what change goes with what feature.

3) Index all your changes in a ChangeLog:: page in your WoaS so nothing gets missed by someone who wants to try one of your fixes but not another.

It's not quite a plugin architecture, but separating things out like this would be very helpful.

Can we all agree on that?

Thanks

PS Major benefit of these best practices would be that things like Little Girl's fix for the 500 slashes of Bartholomew Cubbins could be tested and patched a lot quicker by folks like me who are not as used to navigating the scripts.

Last edited by Snaga (18-11-2009 08:24:21)


E noho iho i ka puweuweu,
ma ho'oki'eki'e.

Hawaiian proverb: "Stay among the clumps of grasses and do not elevate yourself."

Offline

 

#6 18-11-2009 10:21:45

Little Girl
Moderator
Registered: 26-07-2009
Posts: 254
Website

Re: Configurable 'new page'

Snaga wrote:

1) Leave the original code in place, commented out.

2) Sign, date, label, and hopefully document your changes immediately following that.  Mark what change goes with what feature.

I agree with this, and have to admit that I never dated any of my changes. I suppose I could go through my code and add  the dates of my releases into the code comments to at least give an approximation of when they were done.

As far as the changes I just merged into my code (ever so happily!) from FBNil's magical improvements, I began by doing exactly what you recommend (other than the dating, which I hadn't thought of), but there were so many changes, and with some of them, I wasn't fully sure of which were needed by which for what, specifically. There were also many fixes to the code where he took out white space or put brackets on the proper lines, etc. Commenting each of those would sort of defeat the purpose of the beauty he achieved by doing them, and hopefully anybody looking at the code in a diff program would be able to see that those were just corrections and not outright modifications. I have to admit that, in the end, I decided not to comment any of them in favor of commenting only some.

Since I'm releasing v0.7 of BoaS tomorrow, it will go out without the comments. But I promise you that I'll go over all the code between now and v0.8 and comment the heck out of it, including dates. smile

Snaga wrote:

PS Major benefit of these best practices would be that things like Little Girl's fix for the 500 slashes of Bartholomew Cubbins could be tested and patched a lot quicker by folks like me who are not as used to navigating the scripts.

For the record, mine isn't officially a fix - it's a complete and utter cobble, and I should be ashamed of myself for even doing it. smile


There is no spoon.

Offline

 

#7 19-11-2009 00:09:12

FBnil
WoaS typist
Registered: 13-11-2009
Posts: 141

Re: Configurable 'new page'

Um, yes, I've modified stuff in quite a lot of places without 'purpose' other than making it easier on myself while reading the code, therefor, i've promised Legolas I'll start adding each feature with minimalistic changes, so they can be opted in or out in an easy way. Before 1.0 we will then cleanup the code, remove those unused functions, fuse functions, convert the space indentation to tabs (saving some bytes, I managed to save up a full 1kb, not much, but hey...)

Litle Girl! That's wonderful how you just say the right thing to let me find the bug. Let me explain the bug:

Our function does a replace on one of these tags "<(img|hr|br|input|meta)", which does good inside the user's pages, but wreaks havoc inside code like this:


function setHTMLImage() {
    setImage('<img src=\'','\'/>');
}

So setImage becomes:setImage('<img src=\'','\' / />');

The most easy solution is then to break the matching substring "<img" by doing this:

function setHTMLImage() {
    setImage('<'+'img src=\'','\'/>');
}

And thus, there are 2 'forgotten' matches (to a fix Legolas already committed? HEAD is 'different')

Offline

 

#8 20-11-2009 00:12:44

Little Girl
Moderator
Registered: 26-07-2009
Posts: 254
Website

Re: Configurable 'new page'

From everything I've seen, people don't want XML-style tags (<img src='URL' />) in user-created pages. The preference (which I share) is for HTML-style tags (<img src="URL">). So my counter-proposal for fixing that particular section of code is:

Code:

function setHTMLImage() {
    setImage('<'+'img src="','">');
}

The problem is that there are quite a few spots in the source code where unnecessary forward slashes are added when the wiki performs a self-cleaning, so each section has to be fixed manually. Also, any future code will have to be written the new way.

Is the offending function really necessary? My impression is that its purpose is to babysit potential sloppy code writing. If so, I'd be happy to just remove it entirely. If it were removed, the section of code above could be written like this:

Code:

function setHTMLImage() {
    setImage('<img src="','">');
}

Now that would be beautiful. smile

Last edited by Little Girl (20-11-2009 00:22:34)


There is no spoon.

Offline

 

#9 21-11-2009 18:32:00

Snaga
Experienced newbie
Registered: 04-04-2008
Posts: 85

Re: Configurable 'new page'

There's no way to selectively apply the XHTML hotfix only to the pages?


E noho iho i ka puweuweu,
ma ho'oki'eki'e.

Hawaiian proverb: "Stay among the clumps of grasses and do not elevate yourself."

Offline

 

#10 23-11-2009 07:18:51

Little Girl
Moderator
Registered: 26-07-2009
Posts: 254
Website

Re: Configurable 'new page'

Even if that section was rewritten to prevent it from acting on certain classes or IDs, it would still mess up any tags it finds outside of those areas. I'm still wondering why we need it to "fix" tags at all. smile


There is no spoon.

Offline

 

#11 23-11-2009 13:26:48

FBnil
WoaS typist
Registered: 13-11-2009
Posts: 141

Re: Configurable 'new page'

@Snaga: Yes, the pages are inside a huge array, which can be selected for search & replace.
@Little Girl: The code says its because valid html without closing tag is not valid xhtml and wont get saved. (Need to test this)

Offline

 

#12 26-11-2009 01:23:23

Little Girl
Moderator
Registered: 26-07-2009
Posts: 254
Website

Re: Configurable 'new page'

So far in my use the wiki if you change an <hr /> into an <hr> (or any of the other tags) in the body of the page inside the core code while the offending part of the code is commented out, there's no effect. Even changing /* ]] /> */ </script> to /* ]]> */ </script> seems to be allowed, and that's the one that worried me.

I realize that the doctype is declared in the first line of the script, and I can understand why one would want the entire wiki to be compliant with the declared type, but since not being compliant doesn't seem to do any harm, is it just a semantic issue? Or could we maybe declare a different doctype?


There is no spoon.

Offline

 

Board footer

Copyright © WoaS Project 2007~2010