Skip to content

Commit

Permalink
bloating myself... mobile interface
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolaiwarner committed Mar 10, 2011
1 parent 99a7fbd commit 4714d1a
Show file tree
Hide file tree
Showing 21 changed files with 151 additions and 44 deletions.
14 changes: 14 additions & 0 deletions app/controllers/application_controller.rb
@@ -1,8 +1,22 @@
class ApplicationController < ActionController::Base
protect_from_forgery

layout :detect_browser

rescue_from CanCan::AccessDenied do |exception|
redirect_to root_url, :alert => exception.message
end


private

def detect_browser
agent = request.headers["HTTP_USER_AGENT"].downcase
["android", "ipod", "opera mini", "blackberry", "kindle", "mobile"].each do |m|
return "application.mobile" if agent.match(m)
end
return "application"
end


end
3 changes: 2 additions & 1 deletion app/views/frequencies/index.html.haml
@@ -1,4 +1,5 @@
%h1 interaction frequencies
%h1
= h content_for(:title, "interaction frequencies")

.nav
= link_to 'new frequency', new_frequency_path
Expand Down
17 changes: 10 additions & 7 deletions app/views/friends/index.html.haml
@@ -1,11 +1,14 @@
%h1 your friends
%h1
= h content_for(:title, "your friends")

.nav
= link_to "new friend", new_friend_path
|
= link_to "best friends", best_friends_path
|
= link_to "learn your friends", learn_friends_path
.nav(data-role="navbar")
%ul
%li
= link_to "new friend", new_friend_path, {"data-role" => "button"}
%li
= link_to "best friends", best_friends_path, {"data-role" => "button"}
%li
= link_to "learn your friends", learn_friends_path, {"data-role" => "button"}

= render 'friends/name_list', :friends => @friends

Expand Down
16 changes: 10 additions & 6 deletions app/views/friends/learn.html.haml
@@ -1,17 +1,21 @@
%h1
= h content_for(:title, "learn")


.learn_page

.nav
%a{ :href=>"#", :onclick=>"sociallatio.learning.reveal_info();" }
.nav(data-role="controlgroup" data-type="horizontal")
%a{ :href=>"#", :onclick=>"sociallatio.learning.reveal_info();", "data-role" => "button"}
who is this?
|
= link_to "next", learn_friends_path
%a{ :href=>"#", :onclick=>"location.reload();", "data-role" => "button", "data-iconpos" => "right"}
next

.info
.portrait
.friend_portrait
= image_tag(@friend.portrait_url) if @friend.portrait?

.hidden
%h1
%h2
= @friend.name
.nav
= link_to 'view friend', friend_path(@friend)
7 changes: 4 additions & 3 deletions app/views/friends/new.html.haml
@@ -1,3 +1,4 @@
%h1 add a new friend
= render 'form'
= link_to 'Back', friends_path
%h1
= h content_for(:title, "add a new friend")

= render 'form'
9 changes: 5 additions & 4 deletions app/views/friends/show.html.haml
@@ -1,8 +1,9 @@
%h1
= h content_for(:title, @friend.name )

.friend_page
%h1
= @friend.name
.info
.portrait
.friend_portrait
= image_tag(@friend.portrait_url) if @friend.portrait?
.status
#{pluralize @friend.score, 'point'}
Expand All @@ -21,4 +22,4 @@
= paginate @interactions

.nav
= link_to "edit #{@friend.name}", edit_friend_path(@friend)
= link_to "edit #{@friend.name}", edit_friend_path(@friend), {"data-role" => "button"}
10 changes: 5 additions & 5 deletions app/views/interactions/_list.html.haml
@@ -1,10 +1,10 @@
- interactions.each do |interaction|
.interaction
.date
.interaction(class='ui-grid-c')
.date(class='ui-block-a')
= raw link_to("#{time_ago_in_words(interaction.datetime)} ago", edit_interaction_path(interaction)) if interaction.datetime
.name
.name(class='ui-block-b')
= interaction.interaction_type.name
.friend
.friend(class='ui-block-c')
= link_to interaction.friend.name, friend_path(interaction.friend)
.description
.description(class='ui-block-d')
= interaction.description
5 changes: 2 additions & 3 deletions app/views/interactions/edit.html.haml
@@ -1,7 +1,6 @@
%h1 edit interaction
= render 'form'
%h1
= h content_for(:title, "edit interaction")



.admin
= link_to 'delete', @interation, :confirm => 'Are you sure?', :method => :delete
5 changes: 3 additions & 2 deletions app/views/interactions/index.html.haml
@@ -1,7 +1,8 @@
%h1 your interactions
%h1
= h content_for(:title, "your interactions")

.nav
= link_to 'new interaction', new_interaction_path
= link_to 'new interaction', new_interaction_path, {"data-role" => "button"}

.history
= render 'list', :interactions => @interactions
Expand Down
4 changes: 3 additions & 1 deletion app/views/interactions/new.html.haml
@@ -1,2 +1,4 @@
%h1 add an interaction
%h1
= h content_for(:title, "add an interaction")

= render 'form'
4 changes: 1 addition & 3 deletions app/views/layouts/application.html.haml
Expand Up @@ -3,11 +3,10 @@
%head
%title Sociallatio

= stylesheet_link_tag :all
= stylesheet_link_tag 'application'
%link{ :rel => "shortcut icon", :href => '/images/favicon.png' }
%link{ :rel => "apple-touch-icon", :href => '/images/favicon.png' }
%link{ :media => "screen", :rel => "stylesheet", :type => "text/css", :href => "http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.0/themes/smoothness/jquery-ui.css" }
%link{ :rel => "stylesheet", :href => "http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" }

%script{ :type => "text/javascript", :src => "https://www.google.com/jsapi?key=ABQIAAAALFcVECtS_cckPZPP6gEvtBQNqA7PXSQWBnZcv0WRsLc5vt2EwhRNL4XDqi3F3gVWu6gud-eJy35NIA" }
:javascript
Expand All @@ -20,7 +19,6 @@
families: [ 'Neuton', 'Josefin Slab' ]
}});
});
%script{ :src => "http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js" }

= javascript_include_tag "rails", "jquery-ui-timepicker-addon", "application"
= csrf_meta_tag
Expand Down
51 changes: 51 additions & 0 deletions app/views/layouts/application.mobile.html.haml
@@ -0,0 +1,51 @@
!!! 5
%html
%head
%title Sociallatio

= stylesheet_link_tag 'mobile'

%link{ :rel => "shortcut icon", :href => '/images/favicon.png' }
%link{ :rel => "apple-touch-icon", :href => '/images/favicon.png' }

%link{ :rel => "stylesheet", :href => "http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" }

%script{ :type => "text/javascript", :src => "https://www.google.com/jsapi?key=ABQIAAAALFcVECtS_cckPZPP6gEvtBQNqA7PXSQWBnZcv0WRsLc5vt2EwhRNL4XDqi3F3gVWu6gud-eJy35NIA" }
:javascript
google.load("jquery", "1.5.0");
google.load("jqueryui", "1.8.9");
google.load("webfont", "1.0.18");
google.setOnLoadCallback(function() {
WebFont.load({
google: {
families: [ 'Neuton', 'Josefin Slab' ]
}});
});
%script{ :src => "http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js" }

= csrf_meta_tag
%body
.wrapper(data-role="page")
.header(data-role="header" data-position="fixed")
%h1
= yield :title

- if current_user
= link_to "interact", new_interaction_path, {:class => "ui-btn-right"}
.content(data-role="content")
= render 'layouts/notices'
= yield
.footer(data-role="footer" data-position="fixed")
- if current_user
%div(data-role="navbar")
%ul
%li
= link_to("dashboard", root_path, {"data-icon" => "home"})
%li
= link_to("friends", friends_path, {"data-icon" => "star"})
%li
= link_to("interact", interactions_path, {"data-icon" => "check"})
%li
= link_to("settings", page_path('settings'), {"data-icon" => "gear"})
- else(data-icon="plus")
= link_to("sign in", new_user_session_path)
2 changes: 2 additions & 0 deletions app/views/pages/about.html.haml
@@ -0,0 +1,2 @@
%h1
= h content_for(:title, "about")
2 changes: 1 addition & 1 deletion app/views/pages/home.html.haml
Expand Up @@ -3,7 +3,7 @@


%h1
today
= h content_for(:title, "today")

.friends
- if current_user.friends.length < 1
Expand Down
8 changes: 5 additions & 3 deletions app/views/pages/settings.html.haml
@@ -1,5 +1,7 @@
%h1
= h content_for(:title, "settings")

.nav
= link_to 'interaction frequencies', frequencies_path
|
= link_to 'types of interactions', interaction_types_path
= link_to 'interaction frequencies', frequencies_path, {"data-role" => "button"}
%br/
= link_to 'types of interactions', interaction_types_path, {"data-role" => "button"}
2 changes: 1 addition & 1 deletion config/initializers/mime_types.rb
Expand Up @@ -2,4 +2,4 @@

# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
# Mime::Type.register_alias "text/html", :iphone
2 changes: 1 addition & 1 deletion public/javascripts/application.js
Expand Up @@ -18,7 +18,7 @@ $(document).ready(function(){
if ($('.datepicker').length > 0) {
$('.datepicker').timepicker();
}

// Autocomplete
$(".friendname_autocomplete")
.bind( "keydown", function( event ) {
Expand Down
4 changes: 2 additions & 2 deletions public/stylesheets/application.css
Expand Up @@ -193,10 +193,10 @@ a.friend_needs_interaction {
.history .interaction .description {
width: 350px; }

.portrait {
.friend_portrait {
padding: 5px;
text-align: center; }
.portrait img {
.friend_portrait img {
outline: 1px solid #aaaaaa; }

.best_friends {
Expand Down
12 changes: 12 additions & 0 deletions public/stylesheets/mobile.css
@@ -0,0 +1,12 @@
.content h1 {
display: none; }

.hidden {
display: none; }

.pagination, .learn_page {
text-align: center; }

.interaction {
padding-top: 10px;
padding-bottom: 10px; }
2 changes: 1 addition & 1 deletion public/stylesheets/sass/application.sass
Expand Up @@ -230,7 +230,7 @@ a.friend_needs_interaction



.portrait
.friend_portrait
padding: 5px
text-align: center

Expand Down
16 changes: 16 additions & 0 deletions public/stylesheets/sass/mobile.sass
@@ -0,0 +1,16 @@
.content h1
display: none

.hidden
display: none


.pagination, .learn_page
text-align: center


.interaction
padding-top: 10px
padding-bottom: 10px


0 comments on commit 4714d1a

Please sign in to comment.