Ololo
This commit is contained in:
parent
d7ff408863
commit
0a455e2b3e
11
Gemfile
11
Gemfile
@ -15,8 +15,11 @@ gem 'encryptor'
|
|||||||
# Syntax Highlighting
|
# Syntax Highlighting
|
||||||
gem 'pygments.rb'
|
gem 'pygments.rb'
|
||||||
|
|
||||||
|
# JS
|
||||||
|
gem 'execjs'
|
||||||
|
gem 'therubyracer'
|
||||||
|
|
||||||
# Sugar
|
# Sugar
|
||||||
gem 'haml'
|
gem 'coffee-script'
|
||||||
gem 'sass'
|
gem 'slim'
|
||||||
|
gem 'stylus'
|
||||||
|
|
||||||
|
30
Gemfile.lock
30
Gemfile.lock
@ -1,10 +1,16 @@
|
|||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
|
coffee-script (2.2.0)
|
||||||
|
coffee-script-source
|
||||||
|
execjs
|
||||||
|
coffee-script-source (1.6.3)
|
||||||
encryptor (1.1.3)
|
encryptor (1.1.3)
|
||||||
haml (4.0.3)
|
execjs (1.4.0)
|
||||||
tilt
|
multi_json (~> 1.0)
|
||||||
kgio (2.8.0)
|
kgio (2.8.0)
|
||||||
|
libv8 (3.11.8.17)
|
||||||
|
multi_json (1.7.7)
|
||||||
pg (0.15.1)
|
pg (0.15.1)
|
||||||
posix-spawn (0.3.6)
|
posix-spawn (0.3.6)
|
||||||
pygments.rb (0.5.1)
|
pygments.rb (0.5.1)
|
||||||
@ -14,7 +20,7 @@ GEM
|
|||||||
rack-protection (1.5.0)
|
rack-protection (1.5.0)
|
||||||
rack
|
rack
|
||||||
raindrops (0.11.0)
|
raindrops (0.11.0)
|
||||||
sass (3.2.9)
|
ref (1.0.5)
|
||||||
sequel (4.0.0)
|
sequel (4.0.0)
|
||||||
shotgun (0.9)
|
shotgun (0.9)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
@ -22,6 +28,17 @@ GEM
|
|||||||
rack (~> 1.4)
|
rack (~> 1.4)
|
||||||
rack-protection (~> 1.4)
|
rack-protection (~> 1.4)
|
||||||
tilt (~> 1.3, >= 1.3.4)
|
tilt (~> 1.3, >= 1.3.4)
|
||||||
|
slim (2.0.0)
|
||||||
|
temple (~> 0.6.5)
|
||||||
|
tilt (~> 1.3, >= 1.3.3)
|
||||||
|
stylus (0.7.2)
|
||||||
|
execjs
|
||||||
|
stylus-source
|
||||||
|
stylus-source (0.31.0)
|
||||||
|
temple (0.6.5)
|
||||||
|
therubyracer (0.11.4)
|
||||||
|
libv8 (~> 3.11.8.12)
|
||||||
|
ref
|
||||||
tilt (1.4.1)
|
tilt (1.4.1)
|
||||||
unicorn (4.6.3)
|
unicorn (4.6.3)
|
||||||
kgio (~> 2.6)
|
kgio (~> 2.6)
|
||||||
@ -33,12 +50,15 @@ PLATFORMS
|
|||||||
ruby
|
ruby
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
|
coffee-script
|
||||||
encryptor
|
encryptor
|
||||||
haml
|
execjs
|
||||||
pg
|
pg
|
||||||
pygments.rb
|
pygments.rb
|
||||||
sass
|
|
||||||
sequel
|
sequel
|
||||||
shotgun
|
shotgun
|
||||||
sinatra
|
sinatra
|
||||||
|
slim
|
||||||
|
stylus
|
||||||
|
therubyracer
|
||||||
unicorn
|
unicorn
|
||||||
|
15
app/assets/javascripts/pastemaster.coffee
Normal file
15
app/assets/javascripts/pastemaster.coffee
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
$ ->
|
||||||
|
$form = $('#pasteform')
|
||||||
|
$contents = $('#contents')
|
||||||
|
$_button = $('#submitbtn')
|
||||||
|
$button = $('#submitlnk')
|
||||||
|
|
||||||
|
# Hide generic button, show styled button
|
||||||
|
$_button.hide()
|
||||||
|
$button.show()
|
||||||
|
$contents.focus()
|
||||||
|
|
||||||
|
# Binding submit event to new button
|
||||||
|
$button.on 'click', ->
|
||||||
|
$form.submit()
|
||||||
|
false
|
82
app/assets/stylesheets/pastemaster.styl
Normal file
82
app/assets/stylesheets/pastemaster.styl
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
* { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; }
|
||||||
|
|
||||||
|
body, input, select {
|
||||||
|
font-family: Helvetica, Arial, sans-serif;
|
||||||
|
font-size: 1.2em;
|
||||||
|
}
|
||||||
|
textarea, pre {
|
||||||
|
font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif;
|
||||||
|
font-size: 1.2em;
|
||||||
|
}
|
||||||
|
html, body, form {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
background-color: #fcfcfc;
|
||||||
|
padding: 3em;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
position: absolute;
|
||||||
|
top: 1em;
|
||||||
|
left: 3em;
|
||||||
|
font-weight: 200;
|
||||||
|
font-size: 1em;
|
||||||
|
line-height: 1em;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
text-transform: uppercase;
|
||||||
|
color: #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
textarea, input {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
textarea {
|
||||||
|
background-color: #ffffff;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
line-height: 120%;
|
||||||
|
resize: none;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: #ddd;
|
||||||
|
border-radius: 5px;
|
||||||
|
padding: .5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
#submitbtn, #submitlnk {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
#submitlnk {
|
||||||
|
background-color: #fefefe;
|
||||||
|
background-image: -webkit-linear-gradient(top, #ffffff, #f5f5f5);
|
||||||
|
background-image: linear-gradient(to bottom, #ffffff, #f5f5f5);
|
||||||
|
box-shadow: 0 1px 2px 2px #ffffff;
|
||||||
|
color: #666;
|
||||||
|
text-shadow: 0 0 2px #ffffff;
|
||||||
|
border-style: solid;
|
||||||
|
border-color: #ddd;
|
||||||
|
border-radius: 4px;
|
||||||
|
border-width: 1px;
|
||||||
|
border-bottom-width: 4px;
|
||||||
|
font-size: 1em;
|
||||||
|
width: 5em;
|
||||||
|
text-align: center;
|
||||||
|
padding: .4em 0;
|
||||||
|
margin: .5em 0;
|
||||||
|
text-decoration: none;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
#submitlnk:active {
|
||||||
|
box-shadow: 0 0 2px 2px #eee inset;
|
||||||
|
border-bottom-width: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
width: 100%;
|
||||||
|
}
|
@ -1,6 +1,3 @@
|
|||||||
$:.unshift File.dirname(__FILE__)
|
require File.expand_path('../pastemaster', __FILE__)
|
||||||
require 'pastemaster'
|
|
||||||
|
|
||||||
use Rack::ShowExceptions
|
|
||||||
|
|
||||||
run Pastemaster.new
|
run Pastemaster.new
|
||||||
|
21
lib/assets.rb
Normal file
21
lib/assets.rb
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
class CoffeeAssets < Sinatra::Base
|
||||||
|
set :views, File.expand_path('../../app/assets/javascripts', __FILE__)
|
||||||
|
|
||||||
|
get '/assets/:name.js' do
|
||||||
|
path = "#{settings.views}/#{params[:name]}.coffee"
|
||||||
|
return not_found unless File.exists?(path)
|
||||||
|
|
||||||
|
coffee params[:name].to_sym
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class StylusAssets < Sinatra::Base
|
||||||
|
set :views, File.expand_path('../../app/assets/stylesheets', __FILE__)
|
||||||
|
|
||||||
|
get '/assets/:name.css' do
|
||||||
|
path = "#{settings.views}/#{params[:name]}.styl"
|
||||||
|
return not_found unless File.exists?(path)
|
||||||
|
|
||||||
|
stylus params[:name].to_sym
|
||||||
|
end
|
||||||
|
end
|
15
lib/error_pages.rb
Normal file
15
lib/error_pages.rb
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
class ErrorPages < Sinatra::Base
|
||||||
|
set :views, File.expand_path('../../views', __FILE__)
|
||||||
|
|
||||||
|
not_found do
|
||||||
|
status 404
|
||||||
|
slim :error_404
|
||||||
|
end
|
||||||
|
|
||||||
|
module Forbidden
|
||||||
|
def forbidden
|
||||||
|
status 403
|
||||||
|
slim :error_403
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -1,3 +1,5 @@
|
|||||||
|
$:.unshift File.dirname(__FILE__)
|
||||||
|
|
||||||
require 'securerandom'
|
require 'securerandom'
|
||||||
require 'base64'
|
require 'base64'
|
||||||
|
|
||||||
@ -5,17 +7,30 @@ require 'bundler/setup'
|
|||||||
require 'sinatra'
|
require 'sinatra'
|
||||||
require 'sequel'
|
require 'sequel'
|
||||||
require 'encryptor'
|
require 'encryptor'
|
||||||
require 'haml'
|
require 'slim'
|
||||||
|
require 'coffee_script'
|
||||||
|
require 'stylus'
|
||||||
|
require 'stylus/tilt'
|
||||||
|
|
||||||
|
require 'lib/error_pages'
|
||||||
|
require 'lib/assets'
|
||||||
require 'app/config'
|
require 'app/config'
|
||||||
require 'app/database'
|
require 'app/database'
|
||||||
require 'app/paste'
|
require 'app/paste'
|
||||||
|
|
||||||
class Pastemaster < Sinatra::Application
|
class Pastemaster < Sinatra::Application
|
||||||
|
set :server, 'unicorn'
|
||||||
set :public_folder, 'public'
|
set :public_folder, 'public'
|
||||||
|
|
||||||
|
set :slim, pretty: true
|
||||||
|
|
||||||
|
use ErrorPages
|
||||||
|
helpers ErrorPages::Forbidden
|
||||||
|
use CoffeeAssets
|
||||||
|
use StylusAssets
|
||||||
|
|
||||||
get '/' do
|
get '/' do
|
||||||
haml :form, layout: :default
|
slim :form, layout: :default
|
||||||
end
|
end
|
||||||
|
|
||||||
post '/' do
|
post '/' do
|
||||||
@ -27,9 +42,13 @@ class Pastemaster < Sinatra::Application
|
|||||||
|
|
||||||
get '/:id/:key' do
|
get '/:id/:key' do
|
||||||
@paste = Paste.find(params[:id])
|
@paste = Paste.find(params[:id])
|
||||||
redirect '/' unless @paste
|
return not_found unless @paste
|
||||||
|
|
||||||
@paste.decrypt(params[:key])
|
begin
|
||||||
haml :show, layout: :default
|
@paste.decrypt(params[:key])
|
||||||
|
slim :show, layout: :default
|
||||||
|
rescue => Error
|
||||||
|
forbidden
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
* { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; }
|
|
||||||
|
|
||||||
body, input, select {
|
|
||||||
font-family: 'Helvetica', Arial, sans-serif;
|
|
||||||
font-size: 150%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container {
|
|
||||||
position: absolute;
|
|
||||||
top: 10%;
|
|
||||||
left: 10%;
|
|
||||||
width: 80%;
|
|
||||||
height: 80%;
|
|
||||||
}
|
|
||||||
|
|
||||||
textarea, input {
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
textarea {
|
|
||||||
width: 100%;
|
|
||||||
height: 20em;
|
|
||||||
line-height: 120%;
|
|
||||||
resize: none;
|
|
||||||
border-style: solid;
|
|
||||||
border-color: #ddd;
|
|
||||||
border-radius: 5px;
|
|
||||||
padding: .5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type="submit"] {
|
|
||||||
display: inline-block;
|
|
||||||
margin: .3em 0;
|
|
||||||
background-color: #fafafa;
|
|
||||||
border-color: #ddd;
|
|
||||||
border-radius: 4px;
|
|
||||||
border-width: 1px;
|
|
||||||
font-size: 1em;
|
|
||||||
padding: .2em .5em;
|
|
||||||
}
|
|
||||||
.row.centered {
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
p {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
!!!
|
|
||||||
%html
|
|
||||||
%head
|
|
||||||
%title Pastemaster
|
|
||||||
%link{ rel: 'stylesheet', href: '/normalize.css?v2.1.2' }
|
|
||||||
%link{ rel: 'stylesheet', href: '/pastemaster.css?r1' }
|
|
||||||
%body
|
|
||||||
.container= yield
|
|
13
views/default.slim
Normal file
13
views/default.slim
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
doctype html
|
||||||
|
html
|
||||||
|
head
|
||||||
|
title Pastemaster
|
||||||
|
link rel="stylesheet" href="/normalize.css?v2.1.2"
|
||||||
|
link rel="stylesheet" href="/assets/pastemaster.css?r1"
|
||||||
|
body
|
||||||
|
h1
|
||||||
|
strong Paste
|
||||||
|
| master
|
||||||
|
.container== yield
|
||||||
|
script type="text/javascript" src="http://code.jquery.com/jquery-2.0.3.min.js"
|
||||||
|
script type="text/javascript" src="/assets/pastemaster.js?r1"
|
20
views/error_403.slim
Normal file
20
views/error_403.slim
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
doctype html
|
||||||
|
html
|
||||||
|
head
|
||||||
|
title 403 Forbidden
|
||||||
|
meta charset="utf-8"
|
||||||
|
style type="text/css"
|
||||||
|
| html { display: table; }
|
||||||
|
| body { display: table-cell; }
|
||||||
|
| html, body {
|
||||||
|
| width: 100%; height: 100%;
|
||||||
|
| margin: 0; padding: 0;
|
||||||
|
| text-align: center; vertical-align: middle;
|
||||||
|
| font-face: Helvetica, Arial, sans-serif;
|
||||||
|
| font-size: 2em;
|
||||||
|
| font-weight: 100;
|
||||||
|
| background-color: #fafafa;
|
||||||
|
| color: #444444;
|
||||||
|
| }
|
||||||
|
body
|
||||||
|
| 403 Forbidden
|
20
views/error_404.slim
Normal file
20
views/error_404.slim
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
doctype html
|
||||||
|
html
|
||||||
|
head
|
||||||
|
title 404 Not Found
|
||||||
|
meta charset="utf-8"
|
||||||
|
style type="text/css"
|
||||||
|
| html { display: table; }
|
||||||
|
| body { display: table-cell; }
|
||||||
|
| html, body {
|
||||||
|
| width: 100%; height: 100%;
|
||||||
|
| margin: 0; padding: 0;
|
||||||
|
| text-align: center; vertical-align: middle;
|
||||||
|
| font-face: Helvetica, Arial, sans-serif;
|
||||||
|
| font-size: 2em;
|
||||||
|
| font-weight: 100;
|
||||||
|
| background-color: #fafafa;
|
||||||
|
| color: #444444;
|
||||||
|
| }
|
||||||
|
body
|
||||||
|
| 404 Not Found
|
@ -1,8 +0,0 @@
|
|||||||
%form{ action: '/', method: 'post', 'accept-charset' => 'UTF-8' }
|
|
||||||
.row{ style: 'display: none' }
|
|
||||||
%select{ name: 'type' }
|
|
||||||
%option{ value: 'text_plain' } Plain Text
|
|
||||||
.row
|
|
||||||
%textarea{ name: 'contents' }
|
|
||||||
.row.centered
|
|
||||||
%input{ type: 'submit' }
|
|
4
views/form.slim
Normal file
4
views/form.slim
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
form#pasteform action="/" method="post" accept-charset="UTF-8"
|
||||||
|
textarea#contents name="contents"
|
||||||
|
input#submitbtn type="submit" value="Save"
|
||||||
|
a#submitlnk href="" role="submit" Save
|
@ -1,5 +0,0 @@
|
|||||||
%p
|
|
||||||
- if @paste
|
|
||||||
= @paste.contents
|
|
||||||
- else
|
|
||||||
.nohave Sorry no have mister
|
|
1
views/show.slim
Normal file
1
views/show.slim
Normal file
@ -0,0 +1 @@
|
|||||||
|
pre= @paste.contents
|
Loading…
x
Reference in New Issue
Block a user