Nov. 9th, 2011

andrewducker: (Livejournal)
So I saw a picture. And I thought "what the fuck is that?" and went googling and discovered the Wikipedia entry for a unique parasite.
Cut for disturbing picture )
andrewducker: (livejournal blackout)
I'm adding the templating function to my link poster, so that different people can have different looking posts.

And I figure that if I'm doing that then I should have a "reset to default" button, to set it back to an unfucked state.

Should be simple enough - all I need is a button that you click, and a function that sets some text in the textarea holding the template. How hard can it be?

The first thing that got me was that my button was called "ResetTemplate" and my function was called "ResetTemplate" and when I called "ResetTemplate()" from the onClick of the button, guess what happened?

Did you guess "Nothing at all"? Because that's exactly what happened. Which left me completely baffled for about 45 minutes until I created a "test" function, which worked, and then slowly tweaked it until it contained exactly the same text as the ResetTemplate function, at which point the only possible explanation was the name of the function. Which wasn't my idea of fun.

And then, having got that far, I reasoned that as I had a document, containing a form, containing a fieldset, containing a textarea, I should have something like:
document.DeliciousPoster.TemplateFields.PostTemplate.value = "Replacement Text";

But no, that doesn't work either. Because, it transpires, the PostTemplate textarea isn't part of the TemplateFields fieldset. It's directly part of the form. Which makes no sense to me at all, but there you go, apparently that's how it works.

So if anyone would like to point me in the direction of a good book, or tutorial, or somesuch, that would help me avoid constantly falling into these pitfalls, then I would appreciate it.

(I'm also constantly frustrated by the lack of autocomplete. Having to actually remember the names of functions/methods/properties feels hopelessly old-fashioned. But I don't think there's much I can do about that...)
andrewducker: (Made of Love)
After much faffing around with Javascript and the like, the templating is now in.

It's not for people that don't understand code at all, but I can't see much of a way to make it simpler.

The current default template looks like this:
<ul class="links">
#foreach($link in $links)
<li class="link"><A href="$link.URL">$link.Title</A>
#if($link.Description)<BR><span class="link-description">$link.Description</span>#end
<BR><span class="link-tags">(tags:#foreach($tag in $link.Tags) <A href="$tag.TagURL">$tag.Tag</A>#end )</span>
</li>
<BR><BR>
#end
</ul>

which basically says:
  • Start a list
  • For each link in the collection of links:
    • Create a new list item and put the link title in it, and make that title a hyperlink to the URL of the link.
    • If the link has a description, then put it in, on a new line.
    • Add a new line, and then put in each tag, turning it into a hyperlink back to the site that the links came from (i.e. delicious or pinboard)
    • end the list item
  • end the list


If you're going to play around with it then use the "Test" input and output settings, so that you're not constantly scraping the source links/posting to your journal. If you completely mess it up then hit the "Reset Templates" button to restore the original template.

Next up - a template for the subject line/title.

August 2025

S M T W T F S
      1 2
3 4 5 6 7 8 9
10111213141516
17181920212223
24252627282930
31      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 9th, 2025 01:11 pm
Powered by Dreamwidth Studios