-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
854 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
class PastesController < ApplicationController | ||
# GET /pastes | ||
# GET /pastes.xml | ||
def index | ||
@pastes = Paste.find(:all) | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.xml { render :xml => @pastes } | ||
end | ||
end | ||
|
||
# GET /pastes/1 | ||
# GET /pastes/1.xml | ||
def show | ||
@paste = Paste.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.xml { render :xml => @paste } | ||
end | ||
end | ||
|
||
# GET /pastes/new | ||
# GET /pastes/new.xml | ||
def new | ||
@paste = Paste.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.xml { render :xml => @paste } | ||
end | ||
end | ||
|
||
# GET /pastes/1/edit | ||
def edit | ||
@paste = Paste.find(params[:id]) | ||
end | ||
|
||
# POST /pastes | ||
# POST /pastes.xml | ||
def create | ||
@paste = Paste.new(params[:paste]) | ||
|
||
respond_to do |format| | ||
if @paste.save | ||
flash[:notice] = 'Paste was successfully created.' | ||
format.html { redirect_to(@paste) } | ||
format.xml { render :xml => @paste, :status => :created, :location => @paste } | ||
else | ||
format.html { render :action => "new" } | ||
format.xml { render :xml => @paste.errors, :status => :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /pastes/1 | ||
# PUT /pastes/1.xml | ||
def update | ||
@paste = Paste.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @paste.update_attributes(params[:paste]) | ||
flash[:notice] = 'Paste was successfully updated.' | ||
format.html { redirect_to(@paste) } | ||
format.xml { head :ok } | ||
else | ||
format.html { render :action => "edit" } | ||
format.xml { render :xml => @paste.errors, :status => :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /pastes/1 | ||
# DELETE /pastes/1.xml | ||
def destroy | ||
@paste = Paste.find(params[:id]) | ||
@paste.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to(pastes_url) } | ||
format.xml { head :ok } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,31 @@ | ||
# Methods added to this helper will be available to all templates in the application. | ||
module ApplicationHelper | ||
module ApplicationHelper | ||
def render_bundled_js_include_tags_for_dev | ||
js = asset_dir("js").map { |js| "#{js}" } | ||
javascript_include_tag(*js) | ||
end | ||
|
||
def render_bundled_stylesheet_link_tags_for_dev | ||
|
||
styles = asset_dir("css").map { |css| "#{css}" } | ||
styles << {:media => "screen"} | ||
stylesheet_link_tag(*styles) | ||
end | ||
|
||
private | ||
def asset_dir(which) | ||
case which | ||
when "js" | ||
directory = "javascripts" | ||
format = "js" | ||
when "css" | ||
directory = "stylesheets" | ||
format = "css" | ||
end | ||
|
||
Dir.glob("#{RAILS_ROOT}/public/#{directory}//**/*.#{format}").map {|path| | ||
path.split("//")[1].sub(".#{which}", "") | ||
}.sort | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module PastesHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class Language < ActiveRecord::Base | ||
has_many :pastes | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
class Paste < ActiveRecord::Base | ||
belongs_to :language | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
!!! | ||
%html{:xmlns=>"http://www.w3.org/1999/xhtml"} | ||
%head | ||
= javascript_include_tag :all | ||
= render_bundled_stylesheet_link_tags_for_dev | ||
|
||
= yield :head | ||
|
||
%body.mbx | ||
#doc3{:class => "pastebin yui-t7 #{params[:controller]} #{params[:action]}"} | ||
#bd.bd | ||
#yui-main | ||
.yui-b | ||
.main_content | ||
= yield :layout | ||
.yui-b | ||
.sidebar | ||
= yield :sidebar | ||
|
||
= render :partial => "shared/bottom_javascript" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
- form_for(@paste) do |f| | ||
= f.error_messages | ||
%p | ||
= f.label :content | ||
= f.text_area :content | ||
%p | ||
= f.label :title | ||
= f.text_field :title | ||
%p | ||
= f.label :language | ||
= f.select :language_id, Language.find(:all).collect { |l| [ l.name, l.id ]} | ||
%p | ||
= f.submit "Create" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
%h1 | ||
Editing paste | ||
|
||
= render :partial => "form" | ||
|
||
= link_to 'Show', @paste | ||
| | ||
= link_to 'Back', pastes_path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<h1>Listing pastes</h1> | ||
|
||
<table> | ||
<tr> | ||
<th>Content</th> | ||
<th>Title</th> | ||
<th>Language</th> | ||
</tr> | ||
|
||
<% for paste in @pastes %> | ||
<tr> | ||
<td><%=h paste.content %></td> | ||
<td><%=h paste.title %></td> | ||
<td><%=h paste.language_id %></td> | ||
<td><%= link_to 'Show', paste %></td> | ||
<td><%= link_to 'Edit', edit_paste_path(paste) %></td> | ||
<td><%= link_to 'Destroy', paste, :confirm => 'Are you sure?', :method => :delete %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
<br /> | ||
|
||
<%= link_to 'New paste', new_paste_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
%h1 | ||
New Paste | ||
|
||
= render :partial => "form" | ||
|
||
= link_to 'Back', pastes_path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<p> | ||
<b>Content:</b> | ||
<%= Uv.parse(@paste.content, "xhtml", @paste.language.name, "true", "sunburst") %> | ||
</p> | ||
|
||
<p> | ||
<b>Title:</b> | ||
<%=h @paste.title %> | ||
</p> | ||
|
||
<p> | ||
<b>Language:</b> | ||
<%=h @paste.language_id %> | ||
</p> | ||
|
||
|
||
<%= link_to 'Edit', edit_paste_path(@paste) %> | | ||
<%= link_to 'Back', pastes_path %> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'uv' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class CreateLanguages < ActiveRecord::Migration | ||
def self.up | ||
create_table :languages do |t| | ||
t.string :name | ||
t.timestamps | ||
end | ||
["javascript", "actionscript", "css", "ruby", "ruby_on_rails", "html", "plain_text"].each do |name| | ||
Language.create(:name => name) | ||
end | ||
end | ||
|
||
def self.down | ||
drop_table :languages | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# This file is auto-generated from the current state of the database. Instead of editing this file, | ||
# please use the migrations feature of Active Record to incrementally modify your database, and | ||
# then regenerate this schema definition. | ||
# | ||
# Note that this schema.rb definition is the authoritative source for your database schema. If you need | ||
# to create the application database on another system, you should be using db:schema:load, not running | ||
# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations | ||
# you'll amass, the slower it'll run and the greater likelihood for issues). | ||
# | ||
# It's strongly recommended to check this file into your version control system. | ||
|
||
ActiveRecord::Schema.define(:version => 20081230174420) do | ||
|
||
create_table "languages", :force => true do |t| | ||
t.string "name" | ||
t.datetime "created_at" | ||
t.datetime "updated_at" | ||
end | ||
|
||
create_table "pastes", :force => true do |t| | ||
t.text "content" | ||
t.string "title" | ||
t.integer "class_id" | ||
t.integer "language_id" | ||
t.datetime "created_at" | ||
t.datetime "updated_at" | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.