Star Wars: The Card Game LCG on OCTGN

SW:LCG BoxFor the last month or so, I’ve been feverishly working on a OCTGN Plugin for Star Wars: The Card Game, by Fantasy Flight Games and I’ve finally released a polished version that I’m comfortable sharing with the world. So it’s now time to share the news and help people get started in the usual way.

So, Star Wars: The Card Game, is a “Living Card Game” release, much like Android:Netrunner or Warhamer:Invasion and it’s obvious on which theme it’s based on. The game has only gone out to stores this week if I am not mistaken so it’s brand new.

As a game, it is a somewhat asymmetric game, where each side (Light or Dark) has slightly different victory conditions, albeit their core gameplay does not differ all that much. Most of the differentiation happens in the kind of effects each Affiliation focuses on, much like the colours of Magic:The Gathering. I won’t go into much detail here as I’m sure you can find a lot of reviews online if you happen to need them.

I’ve played a dozen games or so by now, and I’m quite liking it. It may not be as deep or thematic as Android:Netrunner, but it has a lot of tough decisions to make and it’s the kind of game that you canot not see its depth of strategy from reading the rulebook and the spoilers, but rather you need to actually get down to the table and get your hands dirty. Even though I seem to completely suck at it (I’ve won 2 games only), it does show a lot of promise.

Game at v1.0.0

So for anyone interested in trying it out, you can now use my polished OCTGN plugin to do so.

EDIT @ 02/07/2013 : I’ve moved the installation instructions on to the dedicated page for this game definition. Please follow the step-by-step installation instructions for Star Wars: The Card Game there.

Once everything is set up, you need to find someone to play with. You can go to the Host/Join tab to see if anyone has a game waiting. If nobody does, host your own and put in the title that you’re a new player.

Once you find someone, one of you hosts and game and the other joins. Leave the two-sided checkbox checked and once the game is started, load your starter decks. Things should be fairly intuitive but keep in mind these basic things in relation to the OCTGN engine plugin.

  • First thing you do after you load a deck is Setup (Ctrl+Shift+S). This will check if your version is up to date, show you the Message of the Day, and also give you some Tips on playing the game.
  • The setup will put 4 objectives in your hand. You need to select one to put to the bottom of your deck. Once you’ve decided which one, simply mouse over it and press “Del”. Now that you have just three objectives in your hand, press Ctrl+Shift+S once more to place them on the table
  • Wait until your opponent has placed their objectives on the table as well and communicate if any of you wants to take a Mulligan. If not, then double-click on your objectives to reveal them and start the game.
  • To move from Phase to Phase and to start/end your turn, simply press Ctrl+Enter. This will automatically trigger any card effects that happen after that phase.
  • To attack an objective, target it and press Ctrl+A (or use the context menu on the table). Now you can assign attackers/defenders.
  • Most actions that you want to do, you can do by double-clicking on a card. The game will intuitively understand what you most likely want to achieve and do it. If you’re in an engagement, double-clicking on a non-participating unit will make it participate (turn it 90 degrees sideways). If a unit is participating, double clicking with it will perform a strike. If you’re trying to pay for a card, double clicking on a resource generating card will focus it to generate resources and so on. Double-Click is your friend.
  • If a card needs a target for its ability, simply use shift+click to target another card before you use it. Shift+Click again to clear a target.

I’ve made a video on how to play. It’s a bit outdated now that the new version is out, but I’ll update it in the near future

Enjoy!

Android:Netrunner plugin now available for OCTGN

You can now play the game while you’re waiting for it to be released in the stores ๐Ÿ˜‰

Yesterday night I finally managed to release the first working version of my Android:Netrunner plugin for OCTGN. The plugin came out so quickly because it’s a direct port of my Netrunner plugin, which is already at a very polished level. All I had to do this time was fork the code, carefully search and replace the various keywords and work on making the basic scripts (setup table, play card from hand, trash card, start/end turn) work with the new card properties.

I am very thankful to the people online who came forward to provide censored scans or cards and other paraphernalia, xml exports and even the image for my new table board. Thanks a lot everyone, you know who you are. I would never have done it so quickly without you.

And I’m still not done of course. I’m merely warming up in fact. There’s at least 2 more days of frantic coding ahead of me, so that I can bring the core set and the game to the same level of polish as the original netrunner. I need to put in all the scripts for the cards, tweak and bugfix the existing code (although there’s far less script crashes than I expected) and then, finally I can relax by starting to play Guild Wars 2 which will have just come up.

In fact GW2 should already be active for me, since I pre-purchased, but it’s just my luck that I’m working on the weekend. But even if I weren’t, I don’t think I would even try to play without getting ANR finished. I’m far too dedicated to it to stop now.

It’s actually weird just how much I’ve been hooked to coding for this card game. I haven’t even checked my RSS feed, of which the priority items only are already ~500. That’s going to be a PITA to get though.Worth it though.

Anyway, at the moment, anyone can download the basic first version as well as the required markers. One can also download the first set, in its censored version. You can find all the links in the forum.

Why is the first set censored you ask? Well from what people tell me, FFG, the creators of Android:Netrunner have this unwritten policy that they allow online versions of their LCGs, as long as the cards text is censored in some way for the first six months a set is out. Apparently they are likely to send you a nastygram or an outright DMCA request to your host if you don’t abide by this. I have no idea how true this is, as I’ve only heard it third hand, but there you have it.

Because of this, I’ve avoided uploading an uncensored set to my website as I’ve done with all my other CCGs, as I may wake up one morning with my site (or Google account, had I used google drive) taken down. I also didn’t upload the censored version because of the same concerns, given that this is, again all third hand knowledge.

To tell the truth, this whole policy is not only unnecesarry, but also counter-productive. From my experience, most people play card games online when there’s absolutely no other option (and maybe not even then). I’ve yet to see anyone who does it because they’re too cheap. This doubly goes for LCGs which do not have the collectible aspect and thus I can guarantee you that 95% of the people playing have bought the cards. If anything, having an online version is helpful as it increases exposure to the game, and it allows people to check it out and see if they like before they buy. It will absolutely boost sales, particularly with the price ranges of LCGs.

With Android:Netrunner, it’s makes even more sense to allow the uncensored cards at this moment. The game is not even out. Excitement is running out and letting people play a version online (which is never as fun as playing the actual game) can create more buzz and talk about your game. But because of this misguided overall policy of FFG, I’m afraid to do so, as it might lead to action against me. For doing something nice for others and FFG no less. But these are the pains of our culture of permission and intellectual lockdown. Company policies are just as often driven by their legal department, rather than what makes business sense.

But enough about that. Now is the time to grab the OCTGN plugin, a friend and give the whole thing a whirl. And remember, the version you play now is about 10 times worse than the final one I’m going to be releasing in a day or two. So even if you’re not impressed with it currently, check back again when the automations are in place and see what you think then.

The rigors of OCTGN development

Developing in OCTGN is like drinking pure lemon juice every 5 minutes. Lemon juice LACED WITH CRACK!

I must have spent 16 hours a day on the weekend coding my netrunner plugin and yesterday I stayed until 5am coding the latest features. I don’t know why, but this kind of thing is addicting to me. I just can’t tear away from my computer while my code is still not working. If I don’t get to a working state, I won’t go to bed. And given the sorry state of the OCTGN debugger, something that I think will have fixed in 20 minutes, ends up taking 1.5 hours. Of course my wife is none too impressed by this, since I end up telling her that I’ll be going to bed “soon” and when I get there, it’s not even in the same timezone as “soon”.

WTF is this shit?!

And speaking ofย  a debugger, can I rant about the one, or rather lack of one in OCTGN 3 for a moment? Dear gawds I want to rip someone’s head out at times. It is so bad that the only thing I get is a python syntax check when I try to install a new version of the plugin, and even then, when it finds unexpected sytax (eg, a missing closing parenthesis, a bad indentation etc) it will report the correct issue, but then point to the wrong line of code! You can see that in the screenshot on the right, where I removed a colon after a loop opened, so it got confused by the line break. It then reported a line 30 lines above it! it seems that the more deep in the code the error is, the larger the offset of the line reported. This makes finding syntax errors an absolute pain in the cohones. But this is nowhere near as bad as how non-existent runtime debugging is.

If an error appears during runtime (e.g. trying to read a variable that doesn’t exist, like a typo), the only thing I get is a python aborting error that mentions the very first function I called in OCTGN. So if I have a complex structure where the first function can call upwards of 20 others, included nested calls etc, then imagine one script failing with this error. There is absolutely no clue where to begin looking! I used to have to manually enter short pop-up windows in the code, that would inform me where I’m at in the code, so that I can begin to even track the issue. Tracking a small case-sensitive typo could take from 5 to 20 minutes, depending on how much code I wrote in between. Now? I’ve written my own “soft” debugger inside the python script, which accepts levels of verbosity and spits out messages such as which function I am entering/leaving, and what the result of regex commands are. It’s not perfect, but at least it narrows down my search considerably, and I don’t have to repackage the plugin just to insert some error tracking code.

Why would I repackage the whole plugin to test a line of code, you ask? Fool! A sane development environment of course provides some way to alter code on the fly, not to mention a runtime debugger. But OCTGN is no same development environment. If anything, it’s actively taxing your sanity as you spend 10 minutes for the 1000th time, trying to track which of the 10 variables in a function failed to receive a value somewhere. But if that wasn’t enough, the lack of a way to modify your code while in the game, means that the only way to make small changes in order to try and fix issues is to:

  1. Exit the game you’re currently in.
  2. Make your changes in the python code and save the file.
  3. This is what you get if you try to install a new version of a plugin with the same filename as the previous version.

    Re-add the python file into your .o8g file (a simply .zip, renamed). I use 7zip’s handy function to remember the previous names of files you’ve compressed into, so I just select the relevant directory, “compress to” and then select the name. So it adds and replaces to the existing .o8s files with the same name in the current directory. But make sure the .o8g file you’re putting it into does not have the same name as the .o8g file you used last time! Since OCTGN always keeps the current plugin files open in the system, if you try to reinstall a file with the same name, it will fail. So what I do is keep two .o8g in the folder, Netrunner-OCTGN.o8g and Netrunner-OCTGNa.o8g, and every time add the latest changes to the other one.

  4. Go to the Game tab.
  5. Select “Install Game”.
  6. Find your new .o8g file and select it. This takes 2 extra clicks for me since for some reason Windows 7 or OCTGN, I don’t know which, refuses to remember the name of the previous directory I was in last time I installed a game.
  7. Press OK to install it. Hope you didn’t miss any syntax errors. If you did, you have to close the almost-useless error pointer, go back, fix the issue, and then start from step 2 again. But THIS time you have to use the same .o8g name you just used, as it didn’t actually install it, so it’s still using the old one. Make sure you remember that info, because this shit’s written nowhere…
  8. If you had no syntax errors, then it will allow the plugin to be updated after a confirmation dialogue (extra click there.)
  9. Once your plugin is updated, reinstall the sets, if I’ve made any changes to the autoscripts of the cards. Fortunately, those don’t lock the files, so I can re-use the same filenames and don’t have to keep track of which file I installed last time.
  10. OCTGN randomly decided to keep one file open. Why OCTGN? Whhhhhy?

    However, sometimes OCTGN will decide to keep one of your set files open anyway, usually because you looked at one of those cards last (although OCTGN is using an internal DB now). In case you see those lovely red errors when installing the sets, the quickest way to fix it is to restart OCTGN, including logging-in again. Mmmm, I loves me some time wasters…

  11. Go to the game Host/Join tab.
  12. Click “Host” to start a game lobby.
  13. Select the Game you will play from the list.
  14. Provide a lobby name (or click OK to accept the previous one.)
  15. Press Start.
  16. Wait 5 – 10 seconds for the board to load.
  17. Load my debugger (which I’ve conveniently coded so that it spawns 6 cards with abilities I’d like to check and the environment to use them in. In the past I had to always load a deck, use the Setup function, and then fish for the cards I wanted to check.)
  18. Test the new code.

My now I’ve gotten so proficient at this, that I can do this whole procedure in under a minute. However I need to do this for everything. From the smallest typo, to the biggest code blunder in the universe. Can you imagine the overhead of this? I can tell you, it’s absolutely ludicrous. I would code 50 times faster, if I could make code changes and re-run the same code WITHOUT FRIGGING EXITING, REPACKAGING,REINSTALLING and RESTARTING MY GAME EVERY TIME! The fuck!

So imagine doing all that, and then realizing you didn’t fix the issue at all. Imagine you don’t even know where to being looking for the error, so you have to do this whole process 2 or 4 times, just to enter enough messages and error hooks in the places you suspect the problem is, just so that can begin to track it down. I’ve spent hours in issues that would have normally taken me seconds, just because I couldn’t track it easily (think: regression bug) Fun!!!

Fuck you OCTGN! FUCK! YOUUUUUUUUUUUUUUU!

Oh yeah, did you see that wonderful error above. This is the totality of the console I have in the game. A lot of goddamn scrolling involved to perhaps get an idea where the error happened. As you can see, by default, it tells you fuck-all where the error would be. Not only that,ย  but the error will appear before ALL the notification you’ve put in the code, because python processes the code faster than OCTGN puts out notifications. So first you see the error, and then you see your debugging messages you’ve inserted into the code. Talk about mindfuck.

Oh sure, you see that it was the “useAbility()” function, but that’s just where the rabbit hole starts. In fact, this particular error was caused by a regex which I hadn’t configured to process numbers in the text of special Autoscripted announcements. So one group in the regex results was empty. This was the 10th function or so called from useAbility()…It took me half an hour to track that down, and that was WITH my custom-made debugger spitting out the actual last function used until now. Good fucking luck figuring that out just from that message…

You need to be a goddamn zen coder to not be ripping your testicle hairs out with OCTGN. You need to be able to write flawless code the first time around, because if you don’t, you’d better write your own debugger first before you even begin to write any sort of advanced plugin. And then you’d better have the patience of a Go grandmaster…

Why yes, I have asked the developers for more debugging tools, more than 4 months ago, multiple times, why do you ask..?

Phew! Glad that’s out of my system

However, for all its failings, OCTGN is still top of the line among card game engines, primarily because of its integration of Iron Python. It has its quirks (some of them quirkier than others) but the flexibility and power of using python in the backend just can’t be topped. Other card games like GCCG also support some sort of scripting, but then you have to learn its own internal syntax, which is definitely not as advanced as the capabilities of python. This is why, for all its failings and frustrations, I still stick with OCTGN. It’s the first engine that allowed me to fully realize my vision for how a card game engine online should work (i.e. automation up the arse!).

Hopefully the new version that’s in development will have *something* better than this sorry situation. But I swear if they have to break my existing python code in 20 different ways due to a new interpreter (like what happened when moving from OCTGN 2 to OCTGN 3) without giving me a proper debugger, I’m going to cry…Imagine having to debug 3000 lines of code times 4 plugins…

Aaaanyway, it is what it is. Still, through the fire and flames, I’ve still created a plugin I am proud of, and soon I’ll be using the existing code to implement Android: Netrunner. So why don’t you give the current plugin a run and let me know what ya think. You don’t want to let all that past frustration go to waste, do you? Do you?

Bastard.

 

 

OCTGN reminded me how much I love programming

Just expressing how happy I am to be hacking again.

example of Python language

Ever since I’ve started coding games on OCTGN and working significantly with python, my ethusiasm for programming has been rekindled. So much so that I’ve pretty much stopped doing almost all other things I was doing lately, including reading reddit.

Today, after I went to bed coding and woke up to code afresh, I got to thinking why I ever stopped doing it. The truth is that I stopped doing it (or rather, never fully started) because I didn’t have a good base at modern programming languages and because I didn’t have a project to draw my interest in doing learning them. This is actually a big problem for me. Due to the way my ADHD-addled brain works, I find it nearly impossible to work on something that A) doesn’t excite me, B) doesn’t give me a clear short-term goal. And because of this, the thought of first learning a programming language before trying to use to code something I want to have, was overwhelming.

I always wanted to get into python, and I did start with a few introductory texts, but I quickly lost attention. Not being able to do, or having something to do with what I learned, killed my interest. And this is where OCTGN helped: It allowed me to start slow (small incremental improvements), on a working base to work on (other games), on something that interested me (making defunct CCGs I love work online).

Slowly I’ve been building up steam and learning python as I go, which is the only way I know that works for me. The result is that I spent almost all day yesterday getting the automation for the Dune CCG work, and then re-writing the code to be more intuitive and succinct. This shit’s addicting!

My hope is that once I’ve perfected all the games I want to on OCTGN, I’ll be able to use the knowledge and familiarity I’ve achieved in python to move to some of the other projects currently sitting in the back-burner of my brain.

Preparing for a long-time-coming upgrade

After squashing a showstopping bug, I’m finally ready to upgrade my theme to the newest version and hopefully jump start its development, on my own if necessary.

The Keyboard Parade
Image by theopie via Flickr

I’m finally preparing to upgrade my theme to the latest version (ie the next part in my ongoing attempts to upgrade) as I really should finally start using wordpress widgets. Unfortunately the theme seems to be unmaintained at the moment and the author MIA since April this year. Also the theme still hasn’t been moved to the shiny new official WordPress repository which tells me that Nalin must have lost all interest in it.

Hopefully I’m wrong. I’ve sent him an email and left a forum post asking to add to the repository and allow me to pickup the maintenance if he’s not interested anymore. If he doesn’t come back to me, I’ll unfortunately have to fork it in order to make it compatible with newer version of WordPress and to merge the changes I’ve made into it for others to use. We’ll see.

Some of the things I’m planning to add/modify are

  • Support for the new way of styling so that it works properly with Zemanta and builtin alignments.
  • Option to enable drop-down menus for the header (as you see above) through suckerfish and possibly superfish in the future.
  • More options to tweak.
  • Widgetize the single-post sidebar to allow some content in the generally empty area on the left.
  • Hardcoded support for the various plugins I’m currently using. So for example, if you install emo-vote, there code will already be in your theme to activate it but nothing will be visible if the plugin is missing. I will probably add support for tweaking these plugins in the options page as well.

And that’s for starters. Fortunately I see that the community around this theme is still alive so I’m guessing I’ll be getting more ideas for addition from there as well.

I’m still running my old theme since I managed to debug the suckerfish issue a few minutes before I left for work today, but now that my biggest hurdle is resolved, I’ll soon my changing into “fresh clothes” so to speak.

Reblog this post [with Zemanta]

Is Dreamhost PS simply a way for Dreamhost to wash their hands of support?

I’ve moved the site to Dreamhost’s VPS offering but my support experience since has been less than optimal. Are we on our own?

Another month, another total crapdown of my sites which are hosted at the moment in Dreamhost’s Virtual Private Server offering. Once again the story begins in the usual way, all three of my  sites start puking Internal Server Errors all over the place which generally means that you are out of available RAM on your server. As I generally have about 180 Mb of availability, it would meant that either I have a huge amount of traffic that my Cache did not alleviate, or that something is going wrong on the server.

Going to the Resource Management, I am greeted by a classic figure

Up, up and away!
Up, up and away!

Having looked at my traffic already which had stayed steady in the last days, I know that this is certainly caused by some server/app malfunction. I know this from experience because the same goddamn problem happens to me so regularly, it’s not even funny anymore.

Since this happened while I was at work, I could troubleshoot it through the terminal as they have the ssh ports blocked so I had to wait until I came back home to investigate. Once I arrived, I fired up an ssh connection and checked what processes were running. As expected, it was PHP in CGI mode that was sucking my life’s blood.

Bad PHP. Baaaad!
Bad PHP. Baaaad!

Now mind you, I know all this because I’ve done it before where I had to google around and learn which commands to use to discover this info. The first time it happened, my ram usage was slowly creeping upwards in jumps of 30 Mb per week or so. After that, it simply happens all at once suddenly.

Now this is extremelly difficult to troubleshoot as you can have no idea what is causing this. A php5.cgi process can be anything under the sun that runs on PHP. Basically the whole wordpress interface or any of the dozens of plugins I have installed. You can kill the processes but this will not tell you what is happening and as it does not happen persistently, you can’t figure out which plugin might be causing it as shutting down a plugin does not stop the process and you don’t know when a process will get stuck again.

Unfortunately, and this is what is annoying me mostly, Dreamhost’s answer in the past has been that “It’s not our fault. Figure it out yourself”. A very unfulfilling answer as you might guess. But at least I know that I can expect very little help from them anymore so I avoid them.

So then I got to process killing. Unfortunately this time it seems that I had found a resistant strain of bug. As soon as I killed a process, 5 seconds later and a new one would be spawned, then another and another, until all my RAM was eaten up, no matter how much I increased my available. At this point I was fast reaching a deadend with my current skills as I couldn’t make the problem go away. I couldn’t even access my wordpress’ admin panel to disable plugins.

At this point, a former colleague suggested that this might be caused by a known PHP 5.2 bug which leaves processes hanging when done with them. I thought this might be a good thing to suggest to Dreamhost support to check so I fired up a support ticket.

A while later, I noticed that the RAM usage seemed to have dropped off so I thought that the problem had resolved itself. Unfortunately, while the main page was working the admin panel refused to work.

What admin panel. There's no such thing here
What admin panel. There's no such thing here

In desperation I did a quick server reboot and this was the point where the universe b0rked. After the reboot the whole site was off and my memory usage was stuck at around 20Mb which means that basically the whole thing failed to load. I fired a new ticket to support and waited.

I had to wait until today for an answer which basically told me that they managed to get the sites running again but advised me that my RAM usage was high so I should be checking that and no, they still can’t help me. Thanks Sherlock…

Looking around the interwebs however, I did stumble on a page in the dreamhost wiki where there was a note under supercache under caching that warned not to utilize the “super” part of WP Super Cache as it may drive resource use up on Private Servers. Gee, it would be nice if I knew of this a bit before. It would also be nice if Super Cache was not installed as part of the standard one-click installation of WordPress by Dreamhost which makes people assume that if anything, this plugin will be working well.

So I disabled Supercache on the Division by Zer0 and on the Wesnoth Journals and killed the remaining php processes. Lo and behold, no more processes were spawned. Unfortunately I was lucky that I could access the admin panel of these two sites after I increased my available resources to some ungawdly amount (1.5Gb of RAM or so). Unfortunately I was not so lucky in the Antichristian Phenomenon where not only I could not access the admin panel (never finished loading) anymore but the php processes kept spawning repeatedly and fast.

I tried deleting the plugin directory which led to my whole page being turned off. I tried fixing the .htaccess file. Nothing. Anything I tried, I couldn’t get the site to work properly. So I did the only thing I could do, renamed the whole wordpress directory and reinstalled again. At least this gave me an opportunity to finally rename the prefix of my database tables which helps avoid zero-day exploits by script kiddies. After a few hours, the site was back online.

Unfortunately the latest ordeal has really disillusioned me about Dreamhost’s PS and their support of those. From the 3 times I’ve contacted them about issues in randomly increasing resources, their reply has been “Deal with it yourself” because apparently now I control everything on the server and if anything goes wrong, it must be my own scripts or whatever. Seeing as I only use standard software like WordPress and Gallery this reply does not help me much.

Basically what seems to be happening is that when one decides to go to a PS in order to get a bit more speed (since shared hosting seems at time to be powered by hamsters) you’re on your own. If you’re not a (quite) techical user and have made the grave error of installing wordpress plugins on your site, you’re fucked. It seems that as far as Dreamhost is concerned, you shouldn’t be running plugins in the first place. Just vanilla WordPress for you.

Luckily for me, I know a few UNIX commands and how to use an ssh shell to do some troubleshooting. However even for me this kind of response is definitelly inferior. It would be nice if I could expect the Dreamhost support to ask questions like “Are you using WP Super Cache?”, or something similar. It would be nice to expect the support people to know of a few issues that generally might cause this kind of trouble. Is this is all too much to ask? Is it too much to ask to expect some attempt to help your users?

Last time I was delighted when the support tech gave me a simple command to help me trouble shoot but since then, all replies have been to explain me that it’s my own damn fault and this is very disheartening. To everyone considering the Private Server offering, if you’re not very technical and open to spending a few hours now and then to troubleshoot random issues that occur without you changing anything, then stay away from it and stick to simple shared hosting.

As for me, now my sites are all in the classic WP Cache mode and I’ve used Hyper Cache for the ACP to see how it goes. If all goes fine, I will switch everything to Hyper Cache and drop Super Cache altogether. ‘Till next time my site craps down…

Reblog this post [with Zemanta]

I love WordPress! Now I've got a series plugin

As I’ve been progressing with my misunderstanding communism series it has become to me painfully obvious that I need a better way to organise the links and the format of it in a much better way than what I’ve been doing until now. Specifically, what I have been doing was to copy paste a small introduction text within a style-customized <div> and then manually update the links towards the previous and next articles.

This is what I had been doing in my self-hosting with WordPress series as well and, frankly it was an annoying process. I thought that there must be a more optimal way to go about doing this and fortunately others had the same idea as me.

A quick search for relevant plugins immediately landed me two results. Without knowing the difference, I simply went for the one which has been updated more recently (plugin developers, this is why it pays to keep your code up to date): Organise Series

This one takes the more exciting road of actually using the wordpres taxonomy capabilities and creating a new one. As such I do not have to mix up my already existing tags or categories (which would appear in the various parts of my theme) and I can rest assured that I will not b0rk it by mistake.

I faced the first hurdle when I discovered that the plugin did not have the correct link structure for the options page and eventually that it is not yet ready for WordPress 2.6. However actually opening my eyes a bit more showed me that some kind soul has already submitted patches for this and the beta versions are working. Thus, since I had already initialized it anyway, I took the dive and upgraded to the developer version No problems there.

Then I set about making it look good. It took me a while to figure it out but the author of the plugin has gone into the trouble of writing a use howto…well, series, which goes quite in depth. Eventually I figured it out and made my pages look readable again. But as always, I wanted more bling. So, since I’m already using scriptaculous through backlinks, why not make my series description available without crowding the actual post, through the nice toggle function. And lo, there was code!

The following went into my “Series Meta”, which is the text that appears very first on the post, announcing it as part of the series.


<div class="seriesmeta">This entry is part %series_part% of %total_posts_in_series% in the series %series_title% - <a href="#" onclick="Effect.toggle('series_description', 'slide')">%series_icon_linked% About this series</a></div>%postcontent%

This goes into my Series post list Template:

<div class="seriesbox" id="series_description" style="display:none;">
%series_description%<hr/>
<ul class="serieslist-ul">%post_title_list%</ul>
</div>%postcontent%

And thus, after customizing the css a bit, you get the nice result you see now in any post in the series where you can click on the link and the description of the series, along with the whole list of posts drops down for your viewing pleasure. And I didn’t even had to hack my theme as you can do all this from the options page. Sweet!

The plugin has other nice options like the ability to assign an icon/image to a series, a standalone series page and the capability to read all the posts in a row when clicking on their series link. Unfortunately for me the last does not work as it simply kills the html loading of the page. I assume this is because it’s not yet fully compatible with 2.6 but I’m going to soon open a bug about it.

All in all, I like!

How to load a javascript through your wordpress plugin

I’ve been struggling today to manage to make Backlinks to use the Scriptaculous script library in order to have the list of backlinks hidden until the viewer chooses to see them. While in the Division by Zer0 I already have those libraries loaded for my navigation, it’s certain that not everyone who is going to use it does the same.

Initially I was thinking of simply asking everyone to use a plugin loading these libraries as a dependency but that’s simply over the top for something this simple. Instead I decided to find out how to load the script within the plugin and to my delight I found out that not only does wordpress has functions explicitly for this purpose, but it already includes most common javascript libraries, inclusing Scriptaculous.

Unfortunately, although there were a number of guides trying to explain how to use this, none of them was complete. Simply adding enqueue_script in my function didn’t work and I couldn’t see a full example.

Fortunately someone had thought to add a mailing list discussion which gave me the solution after a few pages. I need to use the template_redirect hook (wp_head is not good, I tried) and I need to put that at the very start of my plugin, after the information but before any function begins. It then needs to call a function which enqueues the scriptaculous effects of which “blind” is used by Backlinks

The end result looks like this

add_action('template_redirect', 'addeffects');
function addeffects() {
if (function_exists('wp_enqueue_script')) wp_enqueue_script('scriptaculous-effects');
}

Of course, the name of the function can be anything you like and you can call any javascript library you wish instead of scriptaculous-effects. Feel free to download the whole plugin to see the whole code.

Backlinks

I just created a new plugin which allows you to display backlinks for your posts similar to the way it exists in Blogger. It is called, appropriately Backlinks.

If you do not like that wordpress does not display links coming from blogs that utilize trackbacks, or if you simply want a simply list of incoming links (instead of having them scattered in your comments), this is for you.

If it still in the very first version so it is quite basic. I plan in the future that have a configuration page, the ability to hide or display the links (just in case the list gets too long) though scriptalicious etc. For the moment you can simply put it anywhere in a template and it will automatically show you blogs linking there.

Let me know what you think or if you have any ideas that might make it better.

UPDATE: I’ve now managed to get the plugin to hide the results until the header/link is clicked. This will save people with a lot of incoming links from having a huge list in the middle.

Last.fm activity now in Complexlife

Last.fm is one of the top, if not the best music service out there and it’s something I’ve been using for quite a while now. While last.fm includes things like groups, friends, forums and other aspects of a social network, your activities in these was never provided. In the latest version these activities (new friends, loved songs etc) were shown in the form of a little block in the sidebar but unfortunately there has been no way to grab that for use in Complexlife.

I knew there is a way to get these activities somehow as Friendfeed does show you when you love a track but having asked directly about it in the forum, I was told that getting this in a feed was just not an option.

Fortunately web-mastered stepped up and created a yahoo pipe which grabs the last.fm latest activities API and returns it as a feed. Very useful but unfrotunately I noticed that it wasn’t exactly in the format I needed. If I used that in Complexlife then you would only see the title (a generic “New activity from <username>”) and having no date info in the feed, b0rked the sort by date of Simplepie.

Thus I had to modify the pipe in a way that

  1. Made the content become the title of the post (removing any html which might break Complexlife)
  2. Provide the date in the RSS so that the item can be sorted

Creating the title

It took me a while to figure it out, but making the content become the title was the easiest part of it all. Since yahoo pipes provides a handy renaming function, all I needed to do is tell it to rename the content as the title

Renaming the content as Title
Renaming the content as Title

The first part copies the whole content as the date field. I will later use this get the date. The second part renames the current content to the title so that it is displayed in whole. If I didn’t do it, I would get only part of the content displayed with elipsis after 30 characters or so.

Now I need to remove all the html code the activity stream has in. As it includes links to my profile as well as to artists and tracks, this would break the link complexlife puts for each row. The only way to remove the unecessary parts is of course through regular expressions and yahoo pipes gives exactly that function.

Removing the unecessary parts from the content
Removing the unnecessary parts from the content

This part actually goes before the renaming/copying as I remove various parts I also don’t need from the date field. Thus when I copy, I save duplicating the work.
The most interesting part is the previous the last field, wherein I tell it to remove all html tags (anything between < and >) and all their settings (i.e. target=”_blank”). Thus I’m left with the title in plain text.

Creating the date

This was a more tricky part as not only does the last.fm activity stream API consider it a good idea to put the date on the content but it also puts it in as a relevant entry to the current date.

Putting the date in the correct field was the easy part as all I needed to do was copy the content in the date field and remove everything except the date. As right before the date there was a fullstop, it was fairly simple to use another regex to delete anything until the last fullstop

The regular expression removes everything until the last fullstop
With a little regex magic, anything except the date is gone

The more difficult part was to make the relevant fuzzy date to become something that is expected to be in an RSS feed, which is something very specific in time and format. Fortunately, I noticed that there is a specific module that does exactly that: Date builder. How convenient.

Unfortunately this module accepts only strings so I could not really parse my whole feed through it unless I had a loop. Oh wait…

With a loop I can make all date items in the correct format
With a loop I can make all date items in the correct format

Sweetness. Unfortunately one problem remains which is that because the date provided is always fuzzy, I end up getting a rolling date for the item each time the pipe is run. For example, an item which has a date of “one month ago” today will point to Aug 28, tomorrow on Aug 29 etc. There’s not much I can do about it other than wait until (and if) last.fm deems it worthy to give us a proper feed.

And now my new shiny feed is in exactly the format I need to have for Complexlife to use it. A little hacking later and version 0.9.8 is ready to go. The last.fm activity stream is finally lifestreamable ๐Ÿ™‚

Reblog this post [with Zemanta]