Archive for the 'Web' Category

Uservoice feedback widget: Changing its style

Wednesday, September 30th, 2009

I have a feedback tab that’s blocking vital content on a website. Here’s how to alter the style of the Uservoice Feedback Tab — for instance the vertical offset: You have to insert this AFTER your widget js code, so that it will effectively overwrite the CSS declarations generated by Uservoice. Also it’s pretty annoying that it shows up on printed media, so the last style block is to remove it from print.

<style type="text/css">
  body a#uservoice-feedback-tab,
  body a#uservoice-feedback-tab:link
  {
    margin-top: 10px !important;
  }
</style>
<style rel="stylesheet" type="text/css" media="print">
  body a#uservoice-feedback-tab,
  body a#uservoice-feedback-tab:link
  {
    display: none !important;
  }
</style>

MarkItUp Markdown footnote button

Wednesday, September 9th, 2009

Here’s a simple addition to markItUp, that will prompt the user for a footnote number, a footnote text and then insert the number after the selection and the footnote text at the end of the full text. As handy extra feature, the plugin will save the previous entered footnote and not ask for further numbers during the session, but instead increment the number each time the button is pressed.

Add this to your code to set.js inside your settings object:

{name:'Insert footnote',
	beforeInsert: function(h) {
		instructions = "Type in the number of the footnote:)";
		if (!h.last_footnote) {
			h.last_footnote = prompt(instructions);
		} else {
			if (!isNaN(h.last_footnote))
				h.last_footnote = parseInt(h.last_footnote) +1;
			else
				h.last_footnote = prompt(instructions);
		}
		h.footnote_content = prompt("Type in the text of the footnote:");
	},
	closeWith: function(h) {
		return '[^' + h.last_footnote + ']';
	},
	afterInsert: function(h) {
		h.textarea.value += '[^' + h.last_footnote + ']: ' +
			h.footnote_content;
	}},

And put this icon in the set’s images folder: footnote

After that be sure to modify style.css so it says something like (if 14 was the placement of the footnote button):

.markItUp .markItUpButton14 a	{
	background-image:url(images/footnote.png);
}

Tip: Extending Django flatpages

Saturday, July 12th, 2008

I did a Google search and since nothing came up, I’m writing this little tip on creating your own CMS by extending Django’s flatpages. What’s good about flatpages is that they’re included in Django and has some basic code to get you started. But clearly they’re not enough if you want other people to administer a site.. you’ll want to add extra fields and special help texts for the admin. But we still don’t want to rewrite those ~150 lines of code, and they can really help you get past all the boring stuff and into the action.

Simply do the following:

cp -R /usr/share/python-support/python-django/django/contrib/flatpages my_project/my_flatpages

views.py

1
from my_project.my_flatpages.models import FlatPage

middleware.py

1
from my_project.my_flatpages.views import flatpage

urls.py

3
4
5
urlpatterns = patterns('my_project.my_flatpages.views',
    (r'^(?P<url>.*)$', 'flatpage'),
)

my_project.my_flatpages.middleware.FlatpageFallbackMiddleware has to be added to your MIDDLEWARE_CLASSES and my_project.my_flatpages to your INSTALLED_APPS and you’ll need to run manage.py syncdb, possibly changing the table name in models.py, so it doesn’t conflict with the old flatpages table. That’s basically it. After that you can work on the templates as described in the other howto’s, but now you have your own model to extend.

A web-based clipboard – useful at least!

Tuesday, October 11th, 2005

Here’s your problem: You’re working on different computers. Maybe because you’re at school doing an assignment, maybe because you’re at work making notes for tonights TV Schedule, maybe you own a KVM Switch or maybe because you’re running back and forth doing system administration.

This is what you usually do: Copy text to some file on a LAN share, send yourself an e-mail, an SMS or even worse: You write it on paper!

Well, now you won’t have to do that anymore! With your new OSS PHP Clipboard you can just type in whatever you like and press save. Your content will then remain accessible until you choose to save something else.

Go try the demo or download it and put it on your own server:

Installation is easy! Just put the .php file on your webserver somewhere safe from people and bots. Chmod the file 777 and it’ll work.

This is an early version, but please help me develope the idea and the code. Right now I’m thinking that it should be able to do optional IP and/or login checking. And maybe there should be a file upload feature, too…

SuDoKu – A JavaScript version

Sunday, October 9th, 2005

The Linux Format Bounty round 1 has finished, and I was one of the competers. I ended up doing a JS version of SuDoKu because of my own skills and the fact that JS/HTML is so cross-platform and easy to do GUIs in. I also thought that SuDoKu would be easy on performance, but I was wrong there. It takes alot of resources and JS is slow as a politician’s brain. Anyways, it all ended up very playable.

Anyways, check out the game or grab a version with readable, commented JS.

Important update: I fixed a bug showing off solutions for every field in “field info”. It was worth a few laughs, though =)