Permalink
Browse files

alternative top-nab added, prepared for memcached in production

  • Loading branch information...
1 parent 3289cce commit 906b9f3328501fa1ac1fa836200c7286327715f0 @zlorfi committed Mar 29, 2013
Showing with 92 additions and 40 deletions.
  1. +1 −0 Gemfile
  2. +2 −0 Gemfile.lock
  3. +1 −0 README.md
  4. +1 −1 app.rb
  5. +8 −3 config.ru
  6. +1 −1 views/index.haml
  7. +1 −0 views/layout.haml
  8. +3 −2 views/sidebar.haml
  9. +20 −33 views/top_nav.haml
  10. +54 −0 views/top_nav_alt.haml
View
1 Gemfile
@@ -10,6 +10,7 @@ gem 'dragonfly'
gem 'bson_ext'
gem 'mongoid'
gem 'rack-flash3'
+gem 'dalli'
group :development do
gem 'shotgun'
View
2 Gemfile.lock
@@ -17,6 +17,7 @@ GEM
chunky_png (~> 1.2)
fssm (>= 0.2.7)
sass (~> 3.1)
+ dalli (2.3.0)
dragonfly (0.9.14)
multi_json (~> 1.0)
rack
@@ -65,6 +66,7 @@ PLATFORMS
DEPENDENCIES
bson_ext
compass
+ dalli
dragonfly
haml
mongoid
View
1 README.md
@@ -17,6 +17,7 @@
- start `mongodb`
- create `tmp` and `upload` directories (`mkdir tmp upload`) and make them writable for your Apache
- install ImageMagic (`apt-get -y install imagemagick` or `yum -y install ImageMagick.x86_64`)
+- install `memcached` for production caching
- `bundle exec shotgun config.ru` for development (a bit of a warning, `rack_flash` doesn't seem to work with `shotgun`)
- `bundle exec puma config.ru` for production
View
2 app.rb
@@ -151,7 +151,7 @@ def count_all_pictures
filename = params[:file][:filename]
file = params[:file][:tempfile]
- prepared_image = app.fetch_file(file).process!(:resize, '800x800>')
+ prepared_image = app.fetch_file(file).process!(:resize, '1000x1000>')
image_uid = app.store(prepared_image, :meta => {:upload_time => Time.now, :name => filename})
picture = Picture.create(image_uid: image_uid,
image_name: filename,
View
11 config.ru
@@ -3,11 +3,16 @@ require 'sinatra'
require 'rack/cache'
require "./app"
-use Rack::Cache,
+if ENV["RACK_ENV"] == 'production'
+ use Rack::Cache,
+ :metastore => 'memcached://localhost:11211/meta',
+ :entitystore => 'memcached://localhost:11211/body',
+ :verbose => true
+else
+ use Rack::Cache,
:metastore => 'file:./tmp/meta',
:entitystore => 'file:./tmp/body',
-# #:metastore => 'memcached://localhost:11211/meta',
-# #:entitystore => 'memcached://localhost:11211/body',
:verbose => true
+end
run App
View
2 views/index.haml
@@ -21,7 +21,7 @@
$(document).ready(function() {
- var items = 15;
+ var items = 12;
var skip = items;
$.get('/gallery/' + items + '/0', function(data){
View
1 views/layout.haml
@@ -31,6 +31,7 @@
.row
.large-12.columns
= haml :top_nav
+ .large-12.columns
#flash_notice
= haml :notification
View
5 views/sidebar.haml
@@ -1,3 +1,4 @@
.large-4.columns.hide-for-small
- %h3 Welcome to our Gallery
- %p Enjoy your stay
+ .panel.radius
+ %h3 Welcome to our Gallery
+ %p Enjoy your stay
View
53 views/top_nav.haml
@@ -1,38 +1,25 @@
-%nav.top-bar
- %ul.title-area
- / Title Area
- %li.name
- %h1.subheader
- %a{:href => "/"}
- %i.icon-camera-retro.icon-large
- Sinatra Gallery
- / Remove the class "menu-icon" to get rid of menu icon. Take out "Menu" to just have icon alone
- %li.toggle-topbar.menu-icon
- %a{:href => "/"}
- %span Menu
- %section.top-bar-section
- / Left Nav Section
- %ul.left
+.large-4.columns
+ %h3.subheader
+ %i.icon-camera-retro.icon-large
+ %a{:href => "/"}
+ Sinatra Gallery
+
+.large-8.columns
+ %ul.inline-list.right
+ -if admin?
%li
- / Right Nav Section
- %ul.right
- %li.divider.hide-for-small
+ %a{:href => "/upload"}
+ %i.icon-upload.icon-large
+ Upload
+ %li
-if admin?
- %li
- %a{:href => "/upload"}
- %i.icon-upload.icon-large
- Upload
- %li.divider
- %li.divider.show-for-small
- %li
- -if admin?
- %a{:href => '/logout'}
- %i.icon-lock.icon-large
- Logout
- -else
- %a{:href => '#', "data-reveal-id" => "login"}
- %i.icon-unlock.icon-large
- Login
+ %a{:href => '/logout'}
+ %i.icon-lock.icon-large
+ Logout
+ -else
+ %a{:href => '#', "data-reveal-id" => "login"}
+ %i.icon-unlock.icon-large
+ Login
#login.reveal-modal.medium
%form(action="/login" method="post")
View
54 views/top_nav_alt.haml
@@ -0,0 +1,54 @@
+%nav.top-bar
+ %ul.title-area
+ / Title Area
+ %li.name
+ %h1.subheader
+ %a{:href => "/"}
+ %i.icon-camera-retro.icon-large
+ Sinatra Gallery
+ / Remove the class "menu-icon" to get rid of menu icon. Take out "Menu" to just have icon alone
+ %li.toggle-topbar.menu-icon
+ %a{:href => "/"}
+ %span Menu
+ %section.top-bar-section
+ / Left Nav Section
+ %ul.left
+ %li
+ / Right Nav Section
+ %ul.right
+ %li.divider.hide-for-small
+ -if admin?
+ %li
+ %a{:href => "/upload"}
+ %i.icon-upload.icon-large
+ Upload
+ %li.divider
+ %li.divider.show-for-small
+ %li
+ -if admin?
+ %a{:href => '/logout'}
+ %i.icon-lock.icon-large
+ Logout
+ -else
+ %a{:href => '#', "data-reveal-id" => "login"}
+ %i.icon-unlock.icon-large
+ Login
+
+#login.reveal-modal.medium
+ %form(action="/login" method="post")
+ %fieldset
+ %legend Login
+ %row
+ .large-12.columns
+ %label Username:
+ %input{:type => :text, :name => :username}
+ .large-12.columns
+ %label Password:
+ %input{:type => :password, :name => :password}
+ .large-12.columns
+ .row
+ .large-6.small-6.columns
+ %input.small.button.success.radius.left{:type => "submit", :value => "Login"}
+ .large-6.small-6.columns
+ %a.small.button.alert.radius.right{:href => "/"} Cancel
+ %a.close-reveal-modal ×

0 comments on commit 906b9f3

Please sign in to comment.