Skip to content
Browse files

no time to explain!

  • Loading branch information...
1 parent 62e4873 commit 506fbc424d4a395d293666980fd4d2db3dc6c755 @Cosmo committed Oct 20, 2012
View
BIN .DS_Store
Binary file not shown.
View
1 Gemfile
@@ -23,6 +23,7 @@ end
gem 'jquery-rails'
gem 'puma'
+gem 'pusher'
# To use ActiveModel has_secure_password
gem 'bcrypt-ruby', '~> 3.0.0'
View
5 Gemfile.lock
@@ -65,6 +65,9 @@ GEM
polyglot (0.3.3)
puma (1.6.3)
rack (~> 1.2)
+ pusher (0.10.0)
+ multi_json (~> 1.0)
+ signature (~> 0.1.4)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
@@ -95,6 +98,7 @@ GEM
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
+ signature (0.1.4)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
@@ -119,6 +123,7 @@ DEPENDENCIES
compass-rails
jquery-rails
puma
+ pusher
rails (= 3.2.8)
sass-rails (~> 3.2.3)
sqlite3
View
BIN app/assets/images/ui/current-video.jpg
Deleted file not rendered
View
BIN app/assets/images/ui/default.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN app/assets/images/ui/missed-video.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN app/assets/images/ui/preview-video.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN app/assets/images/ui/teaser-video.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN app/assets/images/ui/video.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
6 app/assets/javascripts/application.js
@@ -12,4 +12,8 @@
//
//= require jquery
//= require jquery_ujs
-//= require_tree .
+//= require_tree .
+
+jQuery.fn.reset = function () {
+ $(this).each (function() { this.reset(); });
+}
View
11 app/assets/javascripts/ui.js
@@ -0,0 +1,11 @@
+$(document).ready(function(){
+ $("#video-trigger").click(function() {
+ if ($("#video").css("top") === "-365px"){
+ $("#video").animate({"top" : "0"}, 300, 'swing');
+ $("#video-trigger").text("Video ausblenden");
+ } else {
+ $("#video").animate({"top" : "-365px"}, 300, 'swing');
+ $("#video-trigger").text("Video jetzt anschauen");
+ }
+ });
+});
View
100 app/assets/stylesheets/screen.css.sass
@@ -7,55 +7,81 @@
@import compass/reset
@import compass/css3
+$orange: #ff4300
+
+html
+ width: 100%
+ height: 100%
+
body.ui
background: #444
width: 100%
height: 100%
font: 14px/1.2em "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif
+ color: #000
img
- dipslay: block
+ display: block
a
text-decoration: none
+ color: #000
#container
width: 1024px
- min-height: 768px
+ height: 100%
position: relative
left: 50%
margin-left: -512px
- #prev
- width: 220px
- position: absolute
- top: 0
- left: 0
- bottom: 0
-
#current
width: 584px
position: absolute
- top: 0
+ height: 100%
left: 220px
- bottom: 0
@include box-shadow(rgba(0,0,0,.8) 0 4px 20px)
z-index: 20
+ overflow: hidden
+
+ #video
+ width: 584px
+ height: 365px
+ position: absolute
+ top: -365px
+ left: 0
+ z-index: 30
+
+ .button
+ background: #222
+ color: #fff
+ float: left
+ padding: 0 12px
+ line-height: 36px
+ margin-left: 16px
#current-video
- @include background-image(linear-gradient(#F5C200, #B07F00))
- min-height: 240px
+ @include background-image(linear-gradient(#f6f6f6, #c8c8c8))
+ @include box-shadow(rgba(0,0,0,.8) 0 2px 15px)
+ width: 100%
+ float: left
- img
- border: 4px solid #222
- margin: 16px
+ #teaser-button
+ width: 300px
float: left
+ img
+ border: 4px solid #222
+ margin: 52px 16px 16px 16px
+ float: left
+
#description
width: 268px
- margin-top: 16px
float: left
- @include single-text-shadow(0, 1px, 0, false, rgba(255,255,255,.3))
+ margin-top: 50px
+ @include single-text-shadow(0, 1px, 0, false, rgba(255,255,255,.6))
+
+ #nowon
+ color: $orange
h1
font-size: 28px
@@ -74,9 +100,43 @@ body.ui
strong
font-weight: bold
- #next
+ .sidebar
width: 220px
position: absolute
top: 0
+ height: 100%
+ background: #333
+
+ .sidebar-video
+ width: 180px
+ @include background-image(linear-gradient(#f6f6f6, #c8c8c8))
+ padding: 0 20px 10px 20px
+ float: left
+
+ .sidebar-title
+ float: left
+ margin-top: 10px
+ margin-bottom: 4px
+ font-weight: bold
+ color: $orange
+
+ img
+ border: 2px solid #222
+
+ h3
+ margin-top: 4px
+ font-weight: bold
+
+ .sidebar-video:hover
+ background: #222
+ color: #ccc
+
+ img
+ border-color: #ccc
+
+ #prev
+ left: 0
+
+ #next
right: 0
- bottom: 0
+
View
5 app/controllers/chat_controller.rb
@@ -0,0 +1,5 @@
+class ChatController < ApplicationController
+ def index
+
+ end
+end
View
9 app/controllers/home_controller.rb
@@ -1,5 +1,5 @@
class HomeController < ApplicationController
- layout 'ui', :only => 'ui'
+ #layout 'ui', :only => 'ui'
def index
schedule_now_and_next_url = "http://www.arte.tv/tvhack/tvguide/epg/live/D/L3/2.json"
@@ -8,12 +8,13 @@ def index
@schedule_now = schedule_now_and_next["abstractBroadcastList"][0]
@schedule_next = schedule_now_and_next["abstractBroadcastList"][1]
- schedule_url = "http://www.arte.tv/tvhack/tvguide/epg/schedule/D/L2/2012-10-20/2012-10-20.json"
+ date_today = Time.now.strftime("%Y-%m-%d")
+ schedule_url = "http://www.arte.tv/tvhack/tvguide/epg/schedule/D/L3/#{date_today}/#{date_today}.json"
schedule_day = parse_json(schedule_url)
schedule_day["abstractBroadcastList"].each_with_index {|program, index|
- if program["PID"] = @schedule_now["PID"]
- @schedule_previous = schedule_day["abstractBroadcastList"][index]
+ if program["BID"] == @schedule_now["BID"]
+ @schedule_previous = schedule_day["abstractBroadcastList"][index-1]
end
}
end
View
1 app/controllers/logs_controller.rb
@@ -29,6 +29,7 @@ def create
end
if @log.save
logger.info "awesome, #{current_user.email} tagged a video at #{@log.at}"
+ Pusher['presence-chat'].trigger('comment', { :body => @log.body, :user_id => @log.user_id, :short_time => @log.at.strftime("%H:%M"), :name => @log.user.name })
end
redirect_to logs_path
else
View
18 app/controllers/pusher_controller.rb
@@ -0,0 +1,18 @@
+class PusherController < ApplicationController
+ protect_from_forgery :except => :auth
+
+ def auth
+ if current_user
+ response = Pusher[params[:channel_name]].authenticate(params[:socket_id], {
+ :user_id => current_user.id,
+ :user_info => { # => optional - for example
+ :name => current_user.name,
+ :email => current_user.email
+ }
+ })
+ render :json => response
+ else
+ render :text => "Forbidden", :status => '403'
+ end
+ end
+end
View
2 app/models/user.rb
@@ -1,5 +1,5 @@
class User < ActiveRecord::Base
- attr_accessible :email, :password, :password_confirmation
+ attr_accessible :email, :password, :password_confirmation, :name
has_secure_password
validates_presence_of :password, :on => :create
end
View
72 app/views/chat/index.html.erb
@@ -0,0 +1,72 @@
+<script type="text/javascript">
+ Pusher.log = function(message) {
+ if (window.console && window.console.log) window.console.log(message);
+ };
+
+ $(function() {
+ // Set focus on message field
+ $("#log_body").focus();
+
+ var socket = new Pusher('9b398a15a5cdeb082e7d');
+ var channel = socket.subscribe('presence-chat');
+
+ channel.bind('pusher:subscription_succeeded', function(members) {
+ console.log("subscribed!")
+ update_member_count(members.count);
+ members.each(function(member) {
+ add_member(member.id, member.info);
+ });
+ });
+
+ channel.bind('pusher:member_added', function(member) {
+ console.log("added!")
+ });
+
+ channel.bind('pusher:member_removed', function(member) {
+ console.log("removed!")
+ remove_member(member.id);
+ });
+
+ channel.bind('comment', function(data) {
+ console.log(data.user_name);
+ $("<p>["+data.short_time+"] "+data.name+": "+data.body+"</p>").appendTo("#chat");
+ $("#new_log").reset();
+ $("#log_body").focus();
+ });
+
+ })
+
+ function update_member_count(count) {
+ $("#count").text(count + " users");
+ }
+
+ function add_member(member_id, member_info) {
+ $("<li id='member_id_"+member_id+"'>"+member_info.name+"</li>").appendTo("#members");
+ }
+
+ function remove_member(member_id) {
+ console.log("removing: " + member_id)
+ console.log("removing!!." + $("member_id_" + member_id))
+ $("#member_id_" + member_id).remove();
+ }
+</script>
+
+<div style="background-color: white">
+
+ <div id="chat">
+ </div>
+
+ <%= form_for Log.new, :remote => true do |f| %>
+ <p>
+ <%= f.text_field :body %>
+ <%= f.submit "Send" %>
+ </p>
+ <% end %>
+
+ <hr />
+
+ <div id="count">Loading members count …</div>
+
+ <ul id="members">
+ </ul>
+</div>
View
53 app/views/home/index.html.erb
@@ -1,8 +1,45 @@
-Previous:
-<%= @schedule_previous %>
-<br />
-Now:
-<%= @schedule_now["TIT"] =%>
-<br />
-Next:
-<%= @schedule_next["TIT"] =%>
+<div id="container">
+ <div id="prev" class="sidebar">
+ <a href="#" class="sidebar-video">
+ <div class="sidebar-title">Sendung verpasst?</div>
+ <%= image_tag @schedule_previous["VDO"] ? @schedule_previous["VDO"]["VTU"]["IUR"] : "", :size => "176x117" %>
+ <h3><%= @schedule_previous["TIT"] %></h3>
+ <% if @schedule_previous["AP7"] %>
+ <%= link_to "Arte+7", @schedule_previous["VDO"]["VTR"] %>
+ <% end %>
+ </a>
+ </div>
+
+ <div id="current">
+ <div id="video">
+ <%= image_tag("ui/video.png") %>
+ <a href="#" id="video-trigger" class="button">
+ Video jetzt anschauen
+ </a>
+ </div>
+ <div id="current-video">
+ <div id="teaser-button">
+ <%= image_tag @schedule_now["VDO"] ? @schedule_now["VDO"]["VTU"]["IUR"] : "", :size => "260x160" %>
+ </div>
+ <div id="description">
+ <div id="nowon">Jetzt läuft:</div>
+ <h1><%= @schedule_now["DSS"] ? @schedule_now["DSS"] : @schedule_now["DTE"] %></h1>
+ <h2>
+ 20:15 - 22:15 Uhr
+ </h2>
+ <p>
+ Die Produkte der Firma Apple, seien es Computer oder Telefone, vermitteln den Käufern beziehungsweise Nutzern eine bestimmte Lebensart und die Zugehörigkeit zu einer besonderen - oft auch als elitär bezeichneten - Gruppe der Gesellschaft, die äußerst anziehend wirkt.
+ </p>
+ </div>
+ </div>
+ </div>
+
+ <div id="next" class="sidebar">
+ <a href="#" class="sidebar-video">
+ <div class="sidebar-title">Nächste Sendung:</div>
+ <%= image_tag(@schedule_next["VDO"] ? @schedule_next["VDO"]["VTU"]["IUR"] : "", :size => "176x117") %>
+ <h3><%= @schedule_next["TIT"] %></h3>
+ <%= @schedule_next["BAT"] ? "#{@schedule_next["BAT"]} Uhr" : "" %>
+ </a>
+ </div>
+</div>
View
43 app/views/home/ui.html.erb
@@ -0,0 +1,43 @@
+ <div id="container">
+ <div id="prev" class="sidebar">
+ <a href="#" class="sidebar-video">
+ <div class="sidebar-title">Sendung verpasst?</div>
+ <%= image_tag("ui/missed-video.jpg") %>
+ <h3>Modelsuche in Sibirien</h3>
+ 19:15 - 20:15 Uhr
+ </a>
+ </div>
+
+ <div id="current">
+ <div id="video">
+ <%= image_tag("ui/video.png") %>
+ <a href="#" id="video-trigger" class="button">
+ Video jetzt anschauen
+ </a>
+ </div>
+ <div id="current-video">
+ <div id="teaser-button">
+ <%= image_tag("ui/teaser-video.jpg") %>
+ </div>
+ <div id="description">
+ <div id="nowon">Jetzt läuft:</div>
+ <h1>Das Coolness-Diktat</h1>
+ <h2>
+ 20:15 - 22:15 Uhr
+ </h2>
+ <p>
+ Die Produkte der Firma Apple, seien es Computer oder Telefone, vermitteln den Käufern beziehungsweise Nutzern eine bestimmte Lebensart und die Zugehörigkeit zu einer besonderen - oft auch als elitär bezeichneten - Gruppe der Gesellschaft, die äußerst anziehend wirkt.
+ </p>
+ </div>
+ </div>
+ </div>
+
+ <div id="next" class="sidebar">
+ <a href="#" class="sidebar-video">
+ <div class="sidebar-title">Nächste Sendung:</div>
+ <%= image_tag("ui/preview-video.jpg") %>
+ <h3>Die Arte Reportage</h3>
+ 22:15 - 22:35 Uhr
+ </a>
+ </div>
+ </div>
View
26 app/views/layouts/application.html.erb
@@ -4,8 +4,14 @@
<title>Hackday</title>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
+ <script src="http://js.pusher.com/1.12/pusher.min.js" type="text/javascript"></script>
+ <%= stylesheet_link_tag "application", :media => "all" %>
+ <%= javascript_include_tag "application" %>
+ <%= csrf_meta_tags %>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, target-densitydpi=device-dpi, user-scalable=no" />
+ <meta name="apple-mobile-web-app-capable" content="yes">
</head>
-<body>
+<body class="ui">
<% flash.each do |name, message| %>
<% message_type = (name == :notice ? "success" : name) %>
@@ -14,10 +20,6 @@
</div>
<% end %>
- <%= yield %>
-
- <hr />
-
<p>
<% if current_user.present? %>
User:
@@ -27,17 +29,7 @@
<% end %>
</p>
- <ul>
- <li>
- <%= link_to "root", root_path %>
- </li>
- <li>
- <%= link_to "home", home_path %>
- </li>
- <li>
- <%= link_to "view all logs", logs_path %>
- </li>
- </ul>
-
+ <%= yield %>
+
</body>
</html>
View
35 app/views/layouts/ui.html.erb
@@ -5,41 +5,10 @@
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, target-densitydpi=device-dpi, user-scalable=no" />
+ <meta name="apple-mobile-web-app-capable" content="yes">
</head>
<body class="ui">
- <div id="container">
- <div id="prev">
- Sendung verpasst?
- <%= image_tag("ui/missed-video.jpg") %>
- 2.11.12
- </div>
- <div id="current">
- <div id="current-video">
- <%= image_tag("ui/teaser-video.jpg") %>
- <div id="description">
- <div id="nowon">Jetzt läuft</div>
- <h1>Breaking Bad</h1>
- <h2>
- <strong>Folge 7</strong> Lilly of the Valley
- </h2>
- <p>
- Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
- tempor incididunt ut labore et dolore magna aliqua.
- </p>
- <p>
- Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
- consequat.
- </p>
- </div>
- </div>
- </div>
- <div id="next">
- Vorschau Nächste Woche
- <%= image_tag("ui/preview-video.jpg") %>
- 2.11.12
- </div>
- </div>
-
<%= yield %>
View
2 app/views/logs/index.html.erb
@@ -13,6 +13,6 @@
<% if logged_in? %>
<p>
- <%= link_to 'new log', new_log_path %>
+ <%= link_to 'new log (form)', new_log_path %>
</p>
<% end %>
View
4 app/views/users/new.html.erb
@@ -14,6 +14,10 @@
<% end %>
<div class="field">
+ <%= f.label :name %>
+ <%= f.text_field :name %>
+ </div>
+ <div class="field">
<%= f.label :email %>
<%= f.text_field :email %>
</div>
View
13 app/views/welcome/index.html.erb
@@ -27,6 +27,19 @@
<hr />
+<ul>
+ <li>
+ <%= link_to "root", root_path %>
+ </li>
+ <li>
+ <%= link_to "home", home_path %>
+ </li>
+ <li>
+ <%= link_to "view all logs", logs_path %>
+ </li>
+</ul>
+
+
<p>
have fun.
</p>
View
7 config/initializers/pusher.rb
@@ -1,2 +1,7 @@
+PUSHER_APP_ID = '30019'
PUSHER_KEY = '9b398a15a5cdeb082e7d'
-PUSHER_SECRET = '6f97399638c0bda6db0c'
+PUSHER_SECRET = '6f97399638c0bda6db0c'
+
+Pusher.app_id = PUSHER_APP_ID
+Pusher.key = PUSHER_KEY
+Pusher.secret = PUSHER_SECRET
View
2 config/routes.rb
@@ -12,6 +12,8 @@
match 'signup' => 'users#new'
match 'home' => 'home#index'
match 'ui' => 'home#ui'
+ match 'chat' => 'chat#index'
+ match 'pusher/auth' => 'pusher#auth'
# Sample of named route:
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
View
5 db/migrate/20121020134923_add_name_to_users.rb
@@ -0,0 +1,5 @@
+class AddNameToUsers < ActiveRecord::Migration
+ def change
+ add_column :users, :name, :string
+ end
+end
View
3 db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20121020115720) do
+ActiveRecord::Schema.define(:version => 20121020134923) do
create_table "logs", :force => true do |t|
t.integer "user_id"
@@ -29,6 +29,7 @@
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "uid"
+ t.string "name"
end
end

0 comments on commit 506fbc4

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