thbishop / code-paste

A rails based paste bin app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Code Paste

This is another paste bin app written in rails that was heavily inspired by pastie.org. Since that code isn’t open source, this project was born. It doesn’t have as many features as the pastie.org app, but just what was needed at the time.

Overview

Out of the box, this app provides syntax highlighting for the following languages:

  • CSS

  • HTML

  • HTML (ERB/Rails)

  • Java

  • Javascript

  • JSON

  • Perl

  • Plain Text

  • Ruby

  • Ruby on Rails

  • XML

  • YAML

And only one syntax highlighting theme (blackboard for you textmate users).

Setup

This app uses the ultraviolet gem (ultraviolet.rubyforge.org/) for syntax highlighting. This gem depends on the textpow gem (textpow.rubyforge.org/), which depends on the Oniguruma library (www.geocities.jp/kosako3/oniguruma/) and related ruby bindings (rubyforge.org/projects/oniguruma).

Depending on what platform you are on, you may need to download and compile the source for Oniguruma. I had to do so on my mac (couldn’t get the mac port to work correctly).

Once that’s done, you’ll need to make sure you have all of the necessary gems installed on your box. From the root dire of the rails app, run (sudo may be required):

bundle install

After populating your config/database.yml appropriately, run the migrations

rake db:migrate

And then populate the seed data

rake db:seed

Now just fire up the the app and give it a whirl.

Customization

Want more languages? As long as its a language that’s already supported by ultraviolet, it’s simple to add. You just to create a new parser record for the desired language. Set the name attribute to the name that ultraviolet uses and the display_name attribute to whatever you want it to show up as within the app.

To get the list of languages supported by ultraviolet, you can run this from the command line

uv -l syntax

Since there is no controller (or views) for the parser model, you can either add it to db/seeds.rb to be added during the initial seed population or just add it through script/console.

If I wanted to add support for PHP for example, I would do the following

rails console
Loading development environment (Rails 2.3.2)
>> p = Parser.create!(:name => 'php', :display_name => 'PHP')
=> #<Parser id: 13, display_name: "PHP", name: "php", created_at: "2009-08-08 05:19:56", updated_at: "2009-08-08 05:19:56">

That’s it!

Contributing

  • Fork the project.

  • Make your feature addition or bug fix (with tests) in a topic branch.

  • Send a pull request and I’ll get it integrated.

Copyright © 2010 - 2011 Thomas Bishop. See LICENSE (MIT) for details.

About

A rails based paste bin app

License:MIT License


Languages

Language:Ruby 67.9%Language:JavaScript 32.1%