How to share code on a WordPress.com blog

  • Author
    Posts
  • #546396

    exphpkun
    Member

    I’m trying to share a program I wrote in Ruby, and WordPress.com is really getting on my nerves with this obsession with embedded media. It only lets you upload VERY specific filetypes, and it embeds all of them. My program totals 975 lines of code written across 4 files (and this isn’t even counting 674-line file I need to include for the GPL license). I wish I could just let visitors download a .zip file and save it to their computer.

    But since I can’t do that, how exactly CAN I share my code? How do other people with programming-related blogs on WordPress.com do it?

    Currently, I’m copying and pasting the contents of each file under the More tag, and I’m using blockquote and pre tags to format them. It’s huge.

    By the way, I don’t want to consider the possibility of using an external hosting site like Rapidshare and Mediafire. I want to ensure that the code will be available for as long as the blog is around.

    The blog I need help with is exphpkun.wordpress.com.

    #546562

    airodyssey
    Member

    Hi. Depending on the language you use for the code, the following option may be helpful:
    http://en.support.wordpress.com/code/posting-source-code/

    #546576

    exphpkun
    Member

    I’ll tell you what: That option is helpful even regardless of the language.

    Thanks airodyssey. The [sourcecode] tag works very nicely, and looks professional to boot. I’m using collapse=”true” to make it start out small.

    Some complaints: There doesn’t appear to be a button for recollapsing something after expanding it, and there’s also no way to add a vertical scrollbar to it (so if you have a large code file, you shouldn’t use wraplines=”false” because the user would have to scroll all the way down the page to find the horizontal scrollbar)… but considering that my other option is to blockquote preformatted text, it’s an improvement.

    If I write something in a language it doesn’t support, I’ll just set the language to “text”.

    #546579

    airodyssey
    Member

    Glad I could help :-)

    You may want to send your suggestions to staff for consideration:
    http://en.support.wordpress.com/contact/

The topic ‘How to share code on a WordPress.com blog’ is closed to new replies.