init
This commit is contained in:
37
.gitignore
vendored
Normal file
37
.gitignore
vendored
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
.idea
|
||||||
|
*.gem
|
||||||
|
*.rbc
|
||||||
|
/.config
|
||||||
|
/coverage/
|
||||||
|
/InstalledFiles
|
||||||
|
/pkg/
|
||||||
|
/spec/reports/
|
||||||
|
/spec/examples.txt
|
||||||
|
/test/tmp/
|
||||||
|
/test/version_tmp/
|
||||||
|
/tmp/
|
||||||
|
|
||||||
|
## Specific to RubyMotion:
|
||||||
|
.dat*
|
||||||
|
.repl_history
|
||||||
|
build/
|
||||||
|
|
||||||
|
## Documentation cache and generated files:
|
||||||
|
/.yardoc/
|
||||||
|
/_yardoc/
|
||||||
|
/doc/
|
||||||
|
/rdoc/
|
||||||
|
|
||||||
|
## Environment normalization:
|
||||||
|
/.bundle/
|
||||||
|
/vendor/bundle
|
||||||
|
/lib/bundler/man/
|
||||||
|
|
||||||
|
# for a library or gem, you might want to ignore these files since the code is
|
||||||
|
# intended to run in multiple environments; otherwise, check them in:
|
||||||
|
# Gemfile.lock
|
||||||
|
# .ruby-version
|
||||||
|
# .ruby-gemset
|
||||||
|
|
||||||
|
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
||||||
|
.rvmrc
|
||||||
12
Gemfile
Normal file
12
Gemfile
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
source "https://rubygems.org/"
|
||||||
|
|
||||||
|
# App Stack
|
||||||
|
gem "sinatra", "~> 1.4"
|
||||||
|
gem 'indico'
|
||||||
|
|
||||||
|
|
||||||
|
group :development do
|
||||||
|
gem "rake", "~> 10.0"
|
||||||
|
gem "minitest", "~> 5.2"
|
||||||
|
gem "rack-test", "~> 0.6"
|
||||||
|
end
|
||||||
35
Gemfile.lock
Normal file
35
Gemfile.lock
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
GEM
|
||||||
|
remote: https://rubygems.org/
|
||||||
|
specs:
|
||||||
|
chunky_png (1.3.5)
|
||||||
|
indico (0.7.0)
|
||||||
|
inifile (~> 3.0.0)
|
||||||
|
oily_png (~> 1.2.0)
|
||||||
|
inifile (3.0.0)
|
||||||
|
minitest (5.8.3)
|
||||||
|
oily_png (1.2.0)
|
||||||
|
chunky_png (~> 1.3.1)
|
||||||
|
rack (1.6.4)
|
||||||
|
rack-protection (1.5.3)
|
||||||
|
rack
|
||||||
|
rack-test (0.6.3)
|
||||||
|
rack (>= 1.0)
|
||||||
|
rake (10.4.2)
|
||||||
|
sinatra (1.4.6)
|
||||||
|
rack (~> 1.4)
|
||||||
|
rack-protection (~> 1.4)
|
||||||
|
tilt (>= 1.3, < 3)
|
||||||
|
tilt (1.4.1)
|
||||||
|
|
||||||
|
PLATFORMS
|
||||||
|
x64-mingw32
|
||||||
|
|
||||||
|
DEPENDENCIES
|
||||||
|
indico
|
||||||
|
minitest (~> 5.2)
|
||||||
|
rack-test (~> 0.6)
|
||||||
|
rake (~> 10.0)
|
||||||
|
sinatra (~> 1.4)
|
||||||
|
|
||||||
|
BUNDLED WITH
|
||||||
|
1.10.6
|
||||||
1
README.md
Normal file
1
README.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Simple Sinatra app to upload an image to indico and get any emotions in the file
|
||||||
9
Rakefile
Normal file
9
Rakefile
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
%w{ bundler find rake/testtask}.each { |lib| require lib }
|
||||||
|
|
||||||
|
task :default => :spec
|
||||||
|
|
||||||
|
Rake::TestTask.new(:spec) do |t|
|
||||||
|
t.test_files = FileList['spec/*_spec.rb']
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
3893
cacert.pem
Normal file
3893
cacert.pem
Normal file
File diff suppressed because it is too large
Load Diff
18
config.ru
Normal file
18
config.ru
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Load path and gems/bundler
|
||||||
|
$LOAD_PATH << File.expand_path(File.dirname(__FILE__))
|
||||||
|
|
||||||
|
require "bundler"
|
||||||
|
Bundler.require
|
||||||
|
|
||||||
|
# Local config
|
||||||
|
require "find"
|
||||||
|
|
||||||
|
%w{config/initializers lib}.each do |load_path|
|
||||||
|
Find.find(load_path) { |f|
|
||||||
|
require f unless f.match(/\/\..+$/) || File.directory?(f)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
# Load app
|
||||||
|
require "happy_or_sad"
|
||||||
|
run HappyOrSad
|
||||||
1
config/initializers/.keep
Normal file
1
config/initializers/.keep
Normal file
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
19
happy_or_sad.rb
Normal file
19
happy_or_sad.rb
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
require 'indico'
|
||||||
|
require 'base64'
|
||||||
|
require 'openssl'
|
||||||
|
|
||||||
|
|
||||||
|
class HappyOrSad < Sinatra::Base
|
||||||
|
|
||||||
|
set :public_folder => "public", :static => true
|
||||||
|
|
||||||
|
get "/" do
|
||||||
|
erb :welcome
|
||||||
|
end
|
||||||
|
|
||||||
|
post '/upload' do
|
||||||
|
puts encoded = Base64.encode64(params['myfile'][:tempfile].read)
|
||||||
|
Indico.api_key = ENV['indicoApiKey']
|
||||||
|
Indico.fer(encoded)
|
||||||
|
end
|
||||||
|
end
|
||||||
0
lib/.gitkeep
Normal file
0
lib/.gitkeep
Normal file
BIN
public/favicon.ico
Normal file
BIN
public/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 894 B |
0
public/images/.gitkeep
Normal file
0
public/images/.gitkeep
Normal file
BIN
public/images/hazel_icon.png
Normal file
BIN
public/images/hazel_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
BIN
public/images/hazel_small.png
Normal file
BIN
public/images/hazel_small.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.6 KiB |
0
public/javascripts/.gitkeep
Normal file
0
public/javascripts/.gitkeep
Normal file
116
public/stylesheets/main.css
Normal file
116
public/stylesheets/main.css
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
@media screen {
|
||||||
|
/* --- Reset Styles --- */
|
||||||
|
* {
|
||||||
|
list-style: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
html, body {
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- Welcome Page Styles --- */
|
||||||
|
body {
|
||||||
|
background: #eee;
|
||||||
|
color: #333;
|
||||||
|
font-family: Sans-Serif;
|
||||||
|
line-height: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wrapper {
|
||||||
|
background: #fff;
|
||||||
|
-moz-box-shadow: 0 0 10px rgba(0,0,0,.3);
|
||||||
|
-webkit-box-shadow: 0 0 10px rgba(0,0,0,.3);
|
||||||
|
box-shadow: 0 0 10px rgba(0,0,0,.3);
|
||||||
|
margin: 16px auto;
|
||||||
|
max-width: 960px;
|
||||||
|
padding: 2.25%; /* 18px / 800px */
|
||||||
|
width: 85%;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 36px;
|
||||||
|
line-height: 54px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
border-bottom: 2px solid #ccc;
|
||||||
|
font-size: 24px;
|
||||||
|
line-height: 36px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
font-size: 18px;
|
||||||
|
line-height: 36px;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin-bottom: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
float: left;
|
||||||
|
width: 60%; /* 480px / 800px */
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar {
|
||||||
|
background: #eee;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
float: right;
|
||||||
|
padding: 2.08333333333%; /* 5px / 240px */
|
||||||
|
width: 30%; /* 240px / 800px */
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar ul {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.branding {
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer.branding {
|
||||||
|
border-top: 2px solid #ccc;
|
||||||
|
margin-top: 20px;
|
||||||
|
padding-top: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 600px) {
|
||||||
|
.wrapper {
|
||||||
|
-moz-box-shadow: none;
|
||||||
|
-webkit-box-shadow: none;
|
||||||
|
box-shadow: none;
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content, .sidebar {
|
||||||
|
float: none;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar {
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
border-top: 2px solid #ccc;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 24px;
|
||||||
|
line-height: 36px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
font-size: 18px;
|
||||||
|
line-height: 24px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
14
spec/happy_or_sad_spec.rb
Normal file
14
spec/happy_or_sad_spec.rb
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
require_relative "spec_helper"
|
||||||
|
require_relative "../happy_or_sad.rb"
|
||||||
|
|
||||||
|
def app
|
||||||
|
HappyOrSad
|
||||||
|
end
|
||||||
|
|
||||||
|
describe HappyOrSad do
|
||||||
|
it "responds with a welcome message" do
|
||||||
|
get '/'
|
||||||
|
|
||||||
|
last_response.body.must_include 'Welcome to the Sinatra Template!'
|
||||||
|
end
|
||||||
|
end
|
||||||
23
spec/spec_helper.rb
Normal file
23
spec/spec_helper.rb
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
require 'bundler'
|
||||||
|
|
||||||
|
Bundler.setup
|
||||||
|
Bundler.require
|
||||||
|
|
||||||
|
ENV["RACK_ENV"] = "test"
|
||||||
|
|
||||||
|
require 'minitest/pride'
|
||||||
|
require 'minitest/autorun'
|
||||||
|
require 'minitest/spec'
|
||||||
|
require 'rack/test'
|
||||||
|
|
||||||
|
|
||||||
|
require "find"
|
||||||
|
%w{./config/initializers ./lib}.each do |load_path|
|
||||||
|
Find.find(load_path) { |f| require f if f.match(/\.rb$/) }
|
||||||
|
end
|
||||||
|
|
||||||
|
class MiniTest::Spec
|
||||||
|
include Rack::Test::Methods
|
||||||
|
end
|
||||||
37
views/layout.erb
Normal file
37
views/layout.erb
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
|
||||||
|
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
|
||||||
|
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
|
||||||
|
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
|
||||||
|
|
||||||
|
<title>HappyOrSad</title>
|
||||||
|
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="/stylesheets/main.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="wrapper">
|
||||||
|
<header class="branding">
|
||||||
|
<h1>HappyOrSad</h1>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="main">
|
||||||
|
<%= yield %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer class="branding">
|
||||||
|
<small>© <%= Time.now.year %></small>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
|
||||||
|
<!--[if lt IE 7]>
|
||||||
|
<script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.2/CFInstall.min.js"></script>
|
||||||
|
<script>window.attachEvent("onload",function(){CFInstall.check({mode:"overlay"})})</script>
|
||||||
|
<![endif]-->
|
||||||
|
</body>
|
||||||
|
|
||||||
10
views/welcome.erb
Normal file
10
views/welcome.erb
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<h2>Sinatra Template Default Page</h2>
|
||||||
|
|
||||||
|
<div class="content">
|
||||||
|
<h2>File Uploader</h2>
|
||||||
|
<form method="post" enctype="multipart/form-data" action="upload">
|
||||||
|
<input type="file" name="myfile" />
|
||||||
|
<br />
|
||||||
|
<input type="submit" value="Upload!" />
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user