Skip to content
This repository
Browse code

let's git it on

  • Loading branch information...
commit b8609e028ef0f75e217cee86f4c7b7006550c16f 0 parents
Lee Martin authored June 13, 2012
2  .gitignore
... ...
@@ -0,0 +1,2 @@
  1
+/.sass-cache
  2
+.DS_Store
7  Gemfile
... ...
@@ -0,0 +1,7 @@
  1
+source 'http://rubygems.org'
  2
+
  3
+gem 'haml'
  4
+gem 'sinatra'
  5
+gem 'mini_magick'
  6
+gem 'rmagick'
  7
+gem 'json'
18  Gemfile.lock
... ...
@@ -0,0 +1,18 @@
  1
+GEM
  2
+  remote: http://rubygems.org/
  3
+  specs:
  4
+    haml (3.0.25)
  5
+    rack (1.2.1)
  6
+    rmagick (2.12.0)
  7
+    sinatra (1.2.6)
  8
+      rack (~> 1.1)
  9
+      tilt (>= 1.2.2, < 2.0)
  10
+    tilt (1.2.2)
  11
+
  12
+PLATFORMS
  13
+  ruby
  14
+
  15
+DEPENDENCIES
  16
+  haml
  17
+  rmagick
  18
+  sinatra
2  README.markdown
Source Rendered
... ...
@@ -0,0 +1,2 @@
  1
+Waveform.JS
  2
+==========
36  app.rb
... ...
@@ -0,0 +1,36 @@
  1
+require 'sinatra'
  2
+require 'sinatra/reloader' if development?
  3
+require 'haml'
  4
+require 'cgi'
  5
+require 'net/https'
  6
+require "rmagick"
  7
+require 'json'
  8
+
  9
+# require 'sass/plugin/rack'
  10
+# use Sass::Plugin::Rack
  11
+
  12
+set :protection, :except => :json_csrf
  13
+
  14
+get '/' do
  15
+  haml :index
  16
+end
  17
+
  18
+get '/w*' do
  19
+  content_type :json
  20
+
  21
+  waveform = []
  22
+
  23
+  image = Magick::Image.read(params[:url]).first
  24
+  image.crop!(0, 0, image.columns, image.rows / 2)
  25
+  image.rotate!(90)
  26
+
  27
+  columns = image.columns
  28
+
  29
+  image.each_pixel do |pixel, c, r|
  30
+    if waveform.length <= r && (pixel.opacity == 0 || c == columns - 1)
  31
+      waveform << c / columns.to_f
  32
+    end
  33
+  end
  34
+
  35
+  "#{ params[:callback] }(#{ waveform.to_json });"
  36
+end
2  config.ru
... ...
@@ -0,0 +1,2 @@
  1
+require './app'
  2
+run Sinatra::Application
2  public/js/application.coffee
... ...
@@ -0,0 +1,2 @@
  1
+$ ->
  2
+  console.log "ok"
95  public/stylesheets/application.css
... ...
@@ -0,0 +1,95 @@
  1
+* {
  2
+  margin: 0;
  3
+  padding: 0; }
  4
+
  5
+body {
  6
+  color: #999999;
  7
+  font: 13px Interstate Light; }
  8
+
  9
+a {
  10
+  color: #333333;
  11
+  text-decoration: none; }
  12
+  a:hover {
  13
+    color: #ff6600; }
  14
+
  15
+p {
  16
+  margin: 10px 0; }
  17
+
  18
+h1, h2 {
  19
+  color: #333333;
  20
+  font-family: Interstate;
  21
+  font-weight: normal;
  22
+  text-transform: uppercase; }
  23
+
  24
+h1 {
  25
+  background: url(/images/icon.png) 0 4px no-repeat;
  26
+  border-bottom: 3px solid #ff6600;
  27
+  display: inline-block;
  28
+  font-size: 36px;
  29
+  margin-bottom: 10px;
  30
+  padding-left: 38px;
  31
+  position: relative; }
  32
+  h1 span {
  33
+    color: #cccccc;
  34
+    font-size: 13px;
  35
+    position: absolute;
  36
+    right: -50px;
  37
+    top: 7px; }
  38
+
  39
+h2 {
  40
+  font-size: 24px;
  41
+  padding: 25px 0 0 0; }
  42
+
  43
+code, pre {
  44
+  background: whitesmoke; }
  45
+
  46
+code {
  47
+  padding: 0 0.25em; }
  48
+
  49
+strong {
  50
+  color: #ff6600;
  51
+  font-weight: normal; }
  52
+
  53
+.gist {
  54
+  color: #999999 !important;
  55
+  margin: 10px 0; }
  56
+  .gist .gist-file {
  57
+    border: 0 !important; }
  58
+    .gist .gist-file .gist-data {
  59
+      background-color: whitesmoke !important;
  60
+      border: 0 !important; }
  61
+      .gist .gist-file .gist-data span {
  62
+        color: #999999; }
  63
+      .gist .gist-file .gist-data span.c, .gist .gist-file .gist-data span.c1 {
  64
+        color: #ff6600; }
  65
+    .gist .gist-file .gist-meta {
  66
+      background-color: white !important; }
  67
+      .gist .gist-file .gist-meta a {
  68
+        color: black !important; }
  69
+      .gist .gist-file .gist-meta a:nth-child(1) {
  70
+        color: #ff6600 !important; }
  71
+      .gist .gist-file .gist-meta a:nth-child(2) {
  72
+        display: none; }
  73
+
  74
+p.intro {
  75
+  color: #333333;
  76
+  font-size: 24px;
  77
+  line-height: 32px; }
  78
+  p.intro a {
  79
+    border-bottom: 1px solid #ff6600; }
  80
+    p.intro a:hover {
  81
+      color: #333333; }
  82
+
  83
+#header {
  84
+  border-top: 5px solid #333333;
  85
+  left: 0px;
  86
+  position: fixed;
  87
+  top: 0px;
  88
+  width: 100%; }
  89
+
  90
+#container {
  91
+  margin: 100px auto;
  92
+  width: 750px; }
  93
+
  94
+p.copyright {
  95
+  margin-top: 50px; }
0  public/stylesheets/sass/application.sass
No changes.
6  views/index.haml
... ...
@@ -0,0 +1,6 @@
  1
+!!!
  2
+%html
  3
+  %head
  4
+    %title Waveform.JS
  5
+    %script(src="/js/application.js")
  6
+  %body

0 notes on commit b8609e0

Please sign in to comment.
Something went wrong with that request. Please try again.