Skip to content
This repository was archived by the owner on Jan 3, 2019. It is now read-only.

Commit 7ddbbe6

Browse files
committed
initital sinatra
1 parent 6f96b4b commit 7ddbbe6

File tree

10 files changed

+238
-2
lines changed

10 files changed

+238
-2
lines changed

Gemfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
source "https://rubygems.org"
2+
3+
gem 'sinatra'
4+
5+
group :production do
6+
gem 'thin'
7+
end

Gemfile.lock

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
daemons (1.1.9)
5+
eventmachine (1.0.3)
6+
rack (1.5.2)
7+
rack-protection (1.5.3)
8+
rack
9+
sinatra (1.4.5)
10+
rack (~> 1.4)
11+
rack-protection (~> 1.4)
12+
tilt (~> 1.3, >= 1.3.4)
13+
thin (1.6.2)
14+
daemons (>= 1.0.9)
15+
eventmachine (>= 1.0.0)
16+
rack (>= 1.0.0)
17+
tilt (1.4.1)
18+
19+
PLATFORMS
20+
ruby
21+
22+
DEPENDENCIES
23+
sinatra
24+
thin

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
# vjing
2-
First VJing repo
1+
# VJing
2+
3+
First VJing repo - getting some visuals in the browser, adding audio analysing functionlity and MIDI controlling.

app.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# for legacy should do this - good practise, not necessarily needed
2+
require 'rubygems'
3+
# use bundler - will use gemfile to get versions
4+
require 'bundler/setup'
5+
6+
# still need to do this
7+
require 'sinatra'
8+
9+
get '/' do
10+
erb :index
11+
end

config.ru

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require './app'
2+
run Sinatra::Application

favicon.ico

16.6 KB
Binary file not shown.

public/app.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
function createMap(mapEl, mapLat, mapLon, zoom) {
3+
zoom = typeof zoom !== 'undefined' ? zoom : 12;
4+
var myOptions = {
5+
zoom: zoom,
6+
center: new google.maps.LatLng(mapLat, mapLon)
7+
};
8+
var mapObject = new google.maps.Map(mapEl, myOptions);
9+
return mapObject;
10+
}
11+
12+
// google maps calculate route function, modified from http://www.sitepoint.com/find-a-route-using-the-geolocation-and-the-google-maps-api/
13+
function calculateRoute(from, to, googleMap) {
14+
var directionsService = new google.maps.DirectionsService();
15+
var directionsRequest = {
16+
origin: from,
17+
destination: to,
18+
travelMode: google.maps.DirectionsTravelMode.DRIVING,
19+
unitSystem: google.maps.UnitSystem.METRIC
20+
};
21+
directionsService.route(
22+
directionsRequest,
23+
function(response, status) {
24+
if (status == google.maps.DirectionsStatus.OK) {
25+
new google.maps.DirectionsRenderer({
26+
map: googleMap,
27+
directions: response
28+
});
29+
} else {
30+
console.warn('Unable to retrieve your route');
31+
}
32+
}
33+
);
34+
}

public/style.css

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*simple reset*/
2+
html, body, div, span, applet, object, iframe,
3+
header, hgroup, h1, h2, h3, h4, h5, h6,
4+
p, blockquote, pre, time,
5+
a, abbr, acronym, address, big, cite, code,
6+
del, dfn, em, font, ins, kbd, q, s, samp,
7+
small, strike, strong, sub, sup, tt, var,
8+
dl, dt, dd, ol, ul, li,
9+
figure, figcaption, video, audio, img,
10+
fieldset, form, label, legend, input, button, select,
11+
table, caption, tbody, tfoot, thead, tr, th, td,
12+
section, article, canvas, nav, footer, aside,
13+
figure {
14+
margin: 0;
15+
padding: 0;
16+
border: 0;
17+
outline: 0;
18+
vertical-align: baseline; }
19+
20+
body {
21+
font-size:100%;
22+
font-family: 'helvetica neue' helvetica arial sans-serif;
23+
}
24+
25+
.container {
26+
width: 70%; min-width: 800px;
27+
margin: 0px auto; padding: 2% 0px;
28+
font-size: 1.2em;
29+
}
30+
31+
p {margin:1em;}
32+
.form-field {margin:1em;}
33+
label, input {width:30%; font-size: 100%;}
34+
input {border:2px solid grey; padding:0.5em 1em;}
35+
input[type="submit"] {width:auto;}
36+
37+
38+
39+
#map {width:100%; height:500px; border:1px solid black;}
40+
41+
#golden-condor {
42+
opacity:0;
43+
width:593px; height:251px;
44+
background: transparent url('golden-condor.png') no-repeat left top;
45+
}
46+
#mcog {
47+
opacity: 0;
48+
position: absolute; top:80px; left:25%;
49+
width:50%; height:auto;
50+
border:2px solid white; box-shadow: 1px 1px 10px black;
51+
}
52+
53+
#mario-bros {
54+
opacity:0;
55+
width:499px; height:552px;
56+
background: transparent url('marioBros.png') no-repeat left top;
57+
}
58+
59+
/*#soundFile {display: none;}*/
60+
#mapStuff {opacity: 1;}
61+
#moon {
62+
opacity: 0; display: none;
63+
position: absolute; top:0px; left:0px;
64+
width: 100vw; height: 100vh;
65+
background-color: black;
66+
-webkit-perspective: 1000px;
67+
-moz-perspective: 1000px;
68+
perspective: 1000px;
69+
}
70+
#light-side {
71+
margin:200px auto;
72+
width: 740px; height: 454px;
73+
background:black url('moon.jpg') no-repeat center center;
74+
transform-origin: bottom left;
75+
-webkit-backface-visibility:visible;
76+
-moz-backface-visibility:visible;
77+
backface-visibility:visible;
78+
}
79+
80+
81+
82+

public/webanimations.js

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

views/index.erb

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="shortcut icon" href="favicon.ico" />
6+
<meta name="viewport" content="width=initial-scale=1.0, maximum-scale=1.0, user-scalable=no"></head>
7+
<title>VJing Demo</title>
8+
<link type="text/css" href="style.css" rel="stylesheet" media="screen">
9+
<script src="app.js"></script>
10+
</head>
11+
12+
<body>
13+
<div class="container">
14+
<section id="controls"></section>
15+
16+
<section id="screen">
17+
18+
</section>
19+
</div>
20+
</body>
21+
22+
<script type="text/javascript">
23+
24+
25+
var mapDiv = document.getElementById('map'),
26+
newMap,
27+
setCenter = {};
28+
// refactor into init()
29+
if (navigator.geolocation) {
30+
navigator.geolocation.getCurrentPosition(function (position) {
31+
setCenter.lat = position.coords.latitude;
32+
setCenter.lng = position.coords.longitude;
33+
// see app.js for createMap function (creates a google map)
34+
newMap = createMap(mapDiv, setCenter.lat, setCenter.lng);
35+
showRoute();
36+
});
37+
} else {
38+
console.warn('sorry, geolocation not supported');
39+
}
40+
41+
function showRoute() {
42+
var destinationForm = document.forms[0];
43+
destinationForm.onsubmit = function(e) {
44+
e.preventDefault();
45+
var dest = destinationForm.destination.value;
46+
// see app.js for the calculateRoute function (uses google maps directions service to give route)
47+
calculateRoute('Brighton', dest, newMap);
48+
}
49+
}
50+
51+
function init() {
52+
53+
}
54+
init();
55+
56+
</script>
57+
58+
</html>

0 commit comments

Comments
 (0)