Permalink
Browse files

let's git it on

  • Loading branch information...
0 parents commit b8609e028ef0f75e217cee86f4c7b7006550c16f @leemartin leemartin committed Jun 13, 2012
@@ -0,0 +1,2 @@
+/.sass-cache
+.DS_Store
@@ -0,0 +1,7 @@
+source 'http://rubygems.org'
+
+gem 'haml'
+gem 'sinatra'
+gem 'mini_magick'
+gem 'rmagick'
+gem 'json'
@@ -0,0 +1,18 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ haml (3.0.25)
+ rack (1.2.1)
+ rmagick (2.12.0)
+ sinatra (1.2.6)
+ rack (~> 1.1)
+ tilt (>= 1.2.2, < 2.0)
+ tilt (1.2.2)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ haml
+ rmagick
+ sinatra
@@ -0,0 +1,2 @@
+Waveform.JS
+==========
36 app.rb
@@ -0,0 +1,36 @@
+require 'sinatra'
+require 'sinatra/reloader' if development?
+require 'haml'
+require 'cgi'
+require 'net/https'
+require "rmagick"
+require 'json'
+
+# require 'sass/plugin/rack'
+# use Sass::Plugin::Rack
+
+set :protection, :except => :json_csrf
+
+get '/' do
+ haml :index
+end
+
+get '/w*' do
+ content_type :json
+
+ waveform = []
+
+ image = Magick::Image.read(params[:url]).first
+ image.crop!(0, 0, image.columns, image.rows / 2)
+ image.rotate!(90)
+
+ columns = image.columns
+
+ image.each_pixel do |pixel, c, r|
+ if waveform.length <= r && (pixel.opacity == 0 || c == columns - 1)
+ waveform << c / columns.to_f
+ end
+ end
+
+ "#{ params[:callback] }(#{ waveform.to_json });"
+end
@@ -0,0 +1,2 @@
+require './app'
+run Sinatra::Application
@@ -0,0 +1,2 @@
+$ ->
+ console.log "ok"
@@ -0,0 +1,95 @@
+* {
+ margin: 0;
+ padding: 0; }
+
+body {
+ color: #999999;
+ font: 13px Interstate Light; }
+
+a {
+ color: #333333;
+ text-decoration: none; }
+ a:hover {
+ color: #ff6600; }
+
+p {
+ margin: 10px 0; }
+
+h1, h2 {
+ color: #333333;
+ font-family: Interstate;
+ font-weight: normal;
+ text-transform: uppercase; }
+
+h1 {
+ background: url(/images/icon.png) 0 4px no-repeat;
+ border-bottom: 3px solid #ff6600;
+ display: inline-block;
+ font-size: 36px;
+ margin-bottom: 10px;
+ padding-left: 38px;
+ position: relative; }
+ h1 span {
+ color: #cccccc;
+ font-size: 13px;
+ position: absolute;
+ right: -50px;
+ top: 7px; }
+
+h2 {
+ font-size: 24px;
+ padding: 25px 0 0 0; }
+
+code, pre {
+ background: whitesmoke; }
+
+code {
+ padding: 0 0.25em; }
+
+strong {
+ color: #ff6600;
+ font-weight: normal; }
+
+.gist {
+ color: #999999 !important;
+ margin: 10px 0; }
+ .gist .gist-file {
+ border: 0 !important; }
+ .gist .gist-file .gist-data {
+ background-color: whitesmoke !important;
+ border: 0 !important; }
+ .gist .gist-file .gist-data span {
+ color: #999999; }
+ .gist .gist-file .gist-data span.c, .gist .gist-file .gist-data span.c1 {
+ color: #ff6600; }
+ .gist .gist-file .gist-meta {
+ background-color: white !important; }
+ .gist .gist-file .gist-meta a {
+ color: black !important; }
+ .gist .gist-file .gist-meta a:nth-child(1) {
+ color: #ff6600 !important; }
+ .gist .gist-file .gist-meta a:nth-child(2) {
+ display: none; }
+
+p.intro {
+ color: #333333;
+ font-size: 24px;
+ line-height: 32px; }
+ p.intro a {
+ border-bottom: 1px solid #ff6600; }
+ p.intro a:hover {
+ color: #333333; }
+
+#header {
+ border-top: 5px solid #333333;
+ left: 0px;
+ position: fixed;
+ top: 0px;
+ width: 100%; }
+
+#container {
+ margin: 100px auto;
+ width: 750px; }
+
+p.copyright {
+ margin-top: 50px; }
No changes.
@@ -0,0 +1,6 @@
+!!!
+%html
+ %head
+ %title Waveform.JS
+ %script(src="/js/application.js")
+ %body

0 comments on commit b8609e0

Please sign in to comment.