diff --git a/.sass-cache/53c0ce4446c54bca21eabbfde8aea9e680be8c1a/jquery.plupload.queue.scssc b/.sass-cache/53c0ce4446c54bca21eabbfde8aea9e680be8c1a/jquery.plupload.queue.scssc new file mode 100644 index 0000000..f8a7c61 Binary files /dev/null and b/.sass-cache/53c0ce4446c54bca21eabbfde8aea9e680be8c1a/jquery.plupload.queue.scssc differ diff --git a/.sass-cache/fb46dcf1b33fcd526ffc989de0c2b6e51630b35f/jquery.plupload.queue.scssc b/.sass-cache/fb46dcf1b33fcd526ffc989de0c2b6e51630b35f/jquery.plupload.queue.scssc new file mode 100644 index 0000000..df4cc05 Binary files /dev/null and b/.sass-cache/fb46dcf1b33fcd526ffc989de0c2b6e51630b35f/jquery.plupload.queue.scssc differ diff --git a/.sass-cache/fb46dcf1b33fcd526ffc989de0c2b6e51630b35f/jquery.ui.plupload.scssc b/.sass-cache/fb46dcf1b33fcd526ffc989de0c2b6e51630b35f/jquery.ui.plupload.scssc new file mode 100644 index 0000000..a9d253b Binary files /dev/null and b/.sass-cache/fb46dcf1b33fcd526ffc989de0c2b6e51630b35f/jquery.ui.plupload.scssc differ diff --git a/Gemfile b/Gemfile index f6443f7..d6c1456 100644 --- a/Gemfile +++ b/Gemfile @@ -2,29 +2,37 @@ source 'http://rubygems.org' gem 'rails', '3.2.6' -gem 'authlogic' - gem 'mime-types', :require => 'mime/types' gem 'carrierwave', '0.6.2' gem 'dynamic_form' gem 'princely' gem 'jquery-rails' gem 'jquery-ui-rails' +gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git' +gem 'configatron', :git => 'git://github.com/markbates/configatron.git' +gem 'plupload-rails', :git => 'git://github.com/bryanmig/plupload-rails.git' +gem 'sequel', :git => 'git://github.com/jeremyevans/sequel.git' gem 'russian', :git => 'git://github.com/yaroslav/russian.git' -# -- Heroku -#gem 'heroku' -#gem 'pg' +gem "devise_omniauth_engine", :git=>"git://github.com/greendog/devise_omniauth_engine.git" +gem 'omniauth-twitter' +gem 'omniauth-facebook' +gem 'omniauth-openid' +gem 'omniauth-google-apps' +gem 'omniauth-vkontakte', :git => 'git://github.com/mamantoha/omniauth-vkontakte.git' +gem 'cancan' -# -- Database -# SQLite: -group :development do - gem 'sqlite3-ruby' +group :assets do + gem 'sass-rails' + gem 'coffee-rails' + gem 'uglifier' +end + +group :development do + gem 'sqlite3' + gem 'ffaker' + gem 'machinist' end -# MySQL: -#gem 'mysql2' -# PostgreSQL: -#gem 'pg' # -- Cloud storage # AWS S3 support. Can be disabled if using local file system instead of cloud storage. diff --git a/Gemfile.lock b/Gemfile.lock index df83b35..3de58f5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,51 @@ +GIT + remote: git://github.com/bryanmig/plupload-rails.git + revision: 6d07d0f7e05d0b3fdc9b03b49d3a7c3aa1cd703b + specs: + plupload-rails (1.0.6) + rails (~> 3.1) + +GIT + remote: git://github.com/greendog/devise_omniauth_engine.git + revision: c46d449222133f709b5f0cafc31a57f1ae208f06 + specs: + devise_omniauth_engine (1.0.0) + devise + omniauth + yettings + +GIT + remote: git://github.com/jeremyevans/sequel.git + revision: 4b3396b47fdec748a4ed8fae8f6745d2fb5f1f71 + specs: + sequel (3.37.0) + +GIT + remote: git://github.com/mamantoha/omniauth-vkontakte.git + revision: 1d7fc5bdb3b90db2f51a9f3d5f4e6a14b97a2b41 + specs: + omniauth-vkontakte (1.0.7) + multi_json + omniauth (~> 1.1.0) + omniauth-oauth2 (~> 1.0) + +GIT + remote: git://github.com/markbates/configatron.git + revision: 7a81defa5e1fb032b5ed62754d7e6d7bfecf07a2 + specs: + configatron (2.9.1) + yamler (>= 0.1.0) + +GIT + remote: git://github.com/seyhunak/twitter-bootstrap-rails.git + revision: 087c17e4294ce10aeb80d31fe7388a2a524460dd + specs: + twitter-bootstrap-rails (2.1.1) + actionpack (>= 3.1) + less-rails (~> 2.2.3) + railties (>= 3.1) + therubyracer (= 0.10.1) + GIT remote: git://github.com/yaroslav/russian.git revision: e2dde13672bcee176f8b0be364a55ac256913231 @@ -36,16 +84,33 @@ GEM i18n (~> 0.6) multi_json (~> 1.0) arel (3.0.2) - authlogic (3.1.3) - activerecord (>= 3.0.0) - activesupport (>= 3.0.0) + bcrypt-ruby (3.0.1) builder (3.0.0) + cancan (1.6.8) carrierwave (0.6.2) activemodel (>= 3.2.0) activesupport (>= 3.2.0) + coffee-rails (3.2.2) + coffee-script (>= 2.2.0) + railties (~> 3.2.0) + coffee-script (2.2.0) + coffee-script-source + execjs + coffee-script-source (1.3.3) + commonjs (0.2.6) + devise (2.1.2) + bcrypt-ruby (~> 3.0) + orm_adapter (~> 0.1) + railties (~> 3.1) + warden (~> 1.2.1) dynamic_form (1.1.4) erubis (2.7.0) excon (0.14.3) + execjs (1.4.0) + multi_json (~> 1.0) + faraday (0.8.1) + multipart-post (~> 1.1) + ffaker (1.15.0) fog (1.4.0) builder excon (~> 0.14.0) @@ -57,7 +122,9 @@ GEM nokogiri (~> 1.5.0) ruby-hmac formatador (0.2.3) + hashie (1.2.0) hike (1.2.1) + httpauth (0.1) i18n (0.6.0) journey (1.0.4) jquery-rails (2.0.2) @@ -67,6 +134,15 @@ GEM jquery-rails railties (>= 3.1.0) json (1.7.3) + jwt (0.1.5) + multi_json (>= 1.0) + less (2.2.1) + commonjs (~> 0.2.6) + less-rails (2.2.3) + actionpack (>= 3.1) + less (~> 2.2.0) + libv8 (3.3.10.4) + machinist (2.0) mail (2.4.4) i18n (>= 0.4.0) mime-types (~> 1.16) @@ -76,15 +152,48 @@ GEM mini_magick (3.4) subexec (~> 0.2.1) multi_json (1.3.6) + multipart-post (1.1.5) net-scp (1.0.4) net-ssh (>= 1.99.1) net-ssh (2.5.2) nokogiri (1.5.5) + oauth (0.4.6) + oauth2 (0.8.0) + faraday (~> 0.8) + httpauth (~> 0.1) + jwt (~> 0.1.4) + multi_json (~> 1.0) + rack (~> 1.2) + omniauth (1.1.0) + hashie (~> 1.2) + rack + omniauth-facebook (1.4.1) + omniauth-oauth2 (~> 1.1.0) + omniauth-google-apps (0.0.2) + omniauth (~> 1.0) + omniauth-openid (~> 1.0) + ruby-openid-apps-discovery (~> 1.2.0) + omniauth-oauth (1.0.1) + oauth + omniauth (~> 1.0) + omniauth-oauth2 (1.1.0) + oauth2 (~> 0.8.0) + omniauth (~> 1.0) + omniauth-openid (1.0.1) + omniauth (~> 1.0) + rack-openid (~> 1.3.1) + omniauth-twitter (0.0.12) + multi_json (~> 1.3) + omniauth-oauth (~> 1.0) + orm_adapter (0.4.0) polyglot (0.3.3) princely (1.2.5) rack (1.4.1) rack-cache (1.2) rack (>= 0.4) + rack-openid (1.3.1) + rack (>= 1.1.0) + ruby-openid (>= 2.1.8) rack-ssl (1.3.2) rack rack-test (0.6.1) @@ -108,35 +217,65 @@ GEM rdoc (3.12) json (~> 1.4) ruby-hmac (0.4.0) + ruby-openid (2.2.0) + ruby-openid-apps-discovery (1.2.0) + ruby-openid (>= 2.1.7) + sass (3.1.20) + sass-rails (3.2.5) + railties (~> 3.2.0) + sass (>= 3.1.10) + tilt (~> 1.3) sprockets (2.1.3) hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) sqlite3 (1.3.6) - sqlite3-ruby (1.3.3) - sqlite3 (>= 1.3.3) subexec (0.2.2) + therubyracer (0.10.1) + libv8 (~> 3.3.10) thor (0.15.4) tilt (1.3.3) treetop (1.4.10) polyglot polyglot (>= 0.3.1) tzinfo (0.3.33) + uglifier (1.2.6) + execjs (>= 0.3.0) + multi_json (~> 1.3) + warden (1.2.1) + rack (>= 1.0) + yamler (0.1.0) + yettings (0.1.1) PLATFORMS ruby DEPENDENCIES - authlogic + cancan carrierwave (= 0.6.2) + coffee-rails + configatron! + devise_omniauth_engine! dynamic_form + ffaker fog jquery-rails jquery-ui-rails + machinist mime-types mini_exiftool mini_magick + omniauth-facebook + omniauth-google-apps + omniauth-openid + omniauth-twitter + omniauth-vkontakte! + plupload-rails! princely rails (= 3.2.6) russian! - sqlite3-ruby + sass-rails + sequel! + sqlite3 + twitter-bootstrap-rails! + uglifier diff --git a/Rakefile b/Rakefile index 34cf696..2465485 100644 --- a/Rakefile +++ b/Rakefile @@ -4,4 +4,4 @@ require File.expand_path('../config/application', __FILE__) require 'rake' -Balder::Application.load_tasks +Photomix::Application.load_tasks diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js new file mode 100644 index 0000000..87ab0a9 --- /dev/null +++ b/app/assets/javascripts/application.js @@ -0,0 +1,18 @@ +// This is a manifest file that'll be compiled into including all the files listed below. +// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically +// be included in the compiled file accessible from http://example.com/assets/application.js +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// the compiled file. +// +//= require jquery +//= require jquery_ujs +//= require twitter/bootstrap +//= require plupload +//= require jquery.plupload.queue +//= require plupload.flash +//= require plupload.silverlight +//= require plupload.html4 +//= require plupload.html5 +//= require plupload.gears +//= require plupload.browserplus +//= require_tree . diff --git a/app/assets/javascripts/bootstrap.js.coffee b/app/assets/javascripts/bootstrap.js.coffee new file mode 100644 index 0000000..c9404a8 --- /dev/null +++ b/app/assets/javascripts/bootstrap.js.coffee @@ -0,0 +1,4 @@ +jQuery -> + $("a[rel=popover]").popover() + $(".tooltip").tooltip() + $("a[rel=tooltip]").tooltip() \ No newline at end of file diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index bee6c61..424cc96 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -1,248 +1,6 @@ -/* @override - http://localhost:3000/stylesheets/application.css - http://photos.inspired.no/stylesheets/application.css?1316927557 -*/ - -/* @group Reset */ - -html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, code, del, dfn, em, img, q, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {margin:0;padding:0;border:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;vertical-align:baseline;} -body {line-height:1.5;} -table {border-collapse:separate;border-spacing:0;} -caption, th, td {text-align:left;font-weight:normal;} -table, td, th {vertical-align:middle;} -blockquote:before, blockquote:after, q:before, q:after {content:"";} -blockquote, q {quotes:"" "";} -a img {border:none;} - - - -/* @end */ - -/* @group Typography */ - -body {font-size:75%;color:#222;background:#fff;font-family:"Helvetica Neue", Arial, Helvetica, sans-serif;} -h1, h2, h3, h4, h5, h6 {font-weight:normal;} -h1 {font-size:3em;line-height:1;margin-bottom:0.5em;} -h2 {font-size:2em;margin-bottom:0.75em;} -h3 {font-size:1.5em;line-height:1;margin-bottom:1em;} -h4 {font-size:1.2em;line-height:1.25;margin-bottom:1.25em;} -h5 {font-size:1em;font-weight:bold;margin-bottom:1.5em;} -h6 {font-size:1em;font-weight:bold;} -h1 img, h2 img, h3 img, h4 img, h5 img, h6 img {margin:0;} -p {margin:0 0 1.5em;} -p img.left {float:left;margin:1.5em 1.5em 1.5em 0;padding:0;} -p img.right {float:right;margin:1.5em 0 1.5em 1.5em;} -a:focus, a:hover {color:#000;} -a {color:#009;text-decoration:underline;} -blockquote {margin:1.5em;color:#666;font-style:italic;} -strong {font-weight:bold;} -em, dfn {font-style:italic;} -dfn {font-weight:bold;} -sup, sub {line-height:0;} -abbr, acronym {border-bottom:1px dotted #666;} -address {margin:0 0 1.5em;font-style:italic;} -del {color:#666;} -pre {margin:1.5em 0;white-space:pre;} -pre, code, tt {font:1em 'andale mono', 'lucida console', monospace;line-height:1.5;} -li ul, li ol {margin:0 1.5em;} -ul, ol {margin:0 1.5em 1.5em 1.5em;} -ul {list-style-type:disc;} -ol {list-style-type:decimal;} -dl {margin:0 0 1.5em 0;} -dl dt {font-weight:bold;} -dd {margin-left:1.5em;} -table {margin-bottom:1.4em;width:100%;} -th {font-weight:bold;} -thead th {background:#c3d9ff;} -th, td, caption {padding:4px 10px 4px 5px;} -tr.even td {background:#e5ecf9;} -tfoot {font-style:italic;} -caption {background:#eee;} -.small {font-size:.8em;margin-bottom:1.875em;line-height:1.875em;} -.large {font-size:1.2em;line-height:2.5em;margin-bottom:1.25em;} -.hide {display:none;} -.quiet {color:#666;} -.loud {color:#000;} -.highlight {background:#ff0;} -.added {background:#060;color:#fff;} -.removed {background:#900;color:#fff;} -.first {margin-left:0;padding-left:0;} -.last {margin-right:0;padding-right:0;} -.top {margin-top:0;padding-top:0;} -.bottom {margin-bottom:0;padding-bottom:0;} -.clear { - clear: both; -} - - - -/* @end */ - -#container { - width: 950px; - margin: 0 auto; -} - -div#header h1 { - text-transform: uppercase; - font-weight: bold; - letter-spacing: 10px; - margin: 10px 0 0 0; - float: left; - clear: left; -} - -div#header h1 a, div#header h1 a:visited, div#header h1 a:active, div#header h1 a:hover { - text-decoration: none; - color: #222; -} - -div#header { - padding: 10px 0; -} -div#content { - clear: both; -} -div#footer { - clear: both; -} -form#search { - margin: 5px 0; - padding: 5px 10px; - float: right; -} -form#search input { - padding: 5px 5px 5px; - font-size: 13px; -} -form#search input.textfield { - width: 400px; - border: 1px solid black; -} -p.links { - margin: 5px 0; - text-transform: uppercase; -} -p.links a { - text-decoration: none; -} -p.links a:hover { - text-decoration: underline; -} -hr.seperator { - clear: both; - border: none; - background-color: #ddd; - height: 1px; -} -div.thumb { - background-color: #eee; - float: left; - padding: 10px; - margin-right: 10px; - margin-bottom: 10px; -} -div.thumb h3 { - text-transform: uppercase; - font-weight: bold; - font-size: 13px; -} -div.thumb h3 a { - color: black; - text-decoration: none; -} -div.thumb h3 a:hover { - border-bottom: 1px solid #999;} -div.thumb img { - width: 200px; - height: 200px; -} -div.thumb p { - text-align: center; - margin: 0; -} -.row { - clear: both; - padding-bottom: 40px; -} - -img { - - -} -.row div.image { - margin: 10px 0 0; - float: left; -} -.row div.image img { - margin: 0 0 0 10px; -} -div.title { - margin: 10px 0 0; - border-right: 1px solid #bbb; - display: block; - float: left; - width: 240px; -} -.row div.title img, .row div.image img { - width: 100px; - height: 100px; -} -div.title img { - float: right; - padding-right: 10px; - width: 100px; -} -div.title p { - font-weight: bold; - font-size: 18px; -} -div#header h1 p { - display: inline; - font-size: 12px; - letter-spacing: normal; - font-weight: normal; -} - -DIV#map_canvas { - width: 500px; - height: 300px; - float:right; - border:4px solid black; - display: none; -} - -DIV#breadcrumb { - float: left; -} - -DIV#action_links { - float: right; - clear: right; -} - -td { - vertical-align: bottom; -} -p#notice { - color: green; -} - -DIV#collection_albums { - width: 710px; - clear: both; -} -DIV#collection_albums span { - position: relative; - display: block; - float: left; - padding: 5px; -} -DIV#collection_albums IMG.delete { - display: block; - vertical-align: top; - position: absolute; - cursor: pointer; - right: 8px; - top: 8px; -} \ No newline at end of file +/* + *= require_self + *= require_tree . + *= require jquery.plupload.queue + *= require bootstrap_and_overrides + */ \ No newline at end of file diff --git a/app/assets/stylesheets/bootstrap_and_overrides.css.less b/app/assets/stylesheets/bootstrap_and_overrides.css.less new file mode 100644 index 0000000..14bf301 --- /dev/null +++ b/app/assets/stylesheets/bootstrap_and_overrides.css.less @@ -0,0 +1,32 @@ +@import "twitter/bootstrap/bootstrap"; +body { + padding-top: 60px; +} + +@import "twitter/bootstrap/responsive"; + +// Set the correct sprite paths +@iconSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings.png'); +@iconWhiteSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings-white.png'); + +// Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines) +// Note: If you use asset_path() here, your compiled boostrap_and_overrides.css will not +// have the proper paths. So for now we use the absolute path. +@fontAwesomeEotPath: '/assets/fontawesome-webfont.eot'; +@fontAwesomeWoffPath: '/assets/fontawesome-webfont.woff'; +@fontAwesomeTtfPath: '/assets/fontawesome-webfont.ttf'; +@fontAwesomeSvgPath: '/assets/fontawesome-webfont.svg'; + +// Font Awesome +@import "fontawesome"; + +// Your custom LESS stylesheets goes here +// +// Since bootstrap was imported above you have access to its mixins which +// you may use and inherit here +// +// If you'd like to override bootstrap's own variables, you can do so here as well +// See http://twitter.github.com/bootstrap/less.html for their names and documentation +// +// Example: +// @linkColor: #ff0000; diff --git a/vendor/assets/javascripts/plupload/js/jquery.plupload.queue/css/jquery.plupload.queue.css b/app/assets/stylesheets/jquery.plupload.queue.scss similarity index 79% rename from vendor/assets/javascripts/plupload/js/jquery.plupload.queue/css/jquery.plupload.queue.css rename to app/assets/stylesheets/jquery.plupload.queue.scss index 8581fdd..8c7093c 100644 --- a/vendor/assets/javascripts/plupload/js/jquery.plupload.queue/css/jquery.plupload.queue.css +++ b/app/assets/stylesheets/jquery.plupload.queue.scss @@ -11,7 +11,7 @@ border: 1px solid #bababa; padding: 2px 8px 3px 20px; margin-right: 4px; - background: #f3f3f3 url('../img/buttons.png') no-repeat 0 center; + background: #f3f3f3 url(asset_path("buttons.png")) no-repeat 0 center; outline: 0; /* Optional rounded corners for browsers that support it */ @@ -29,7 +29,7 @@ .plupload_disabled, a.plupload_disabled:hover { color: #737373; border-color: #c5c5c5; - background: #ededed url('../img/buttons-disabled.png') no-repeat 0 center; + background: #ededed url(asset_path('buttons-disabled.png')) no-repeat 0 center; cursor: default; } @@ -44,7 +44,7 @@ .plupload_container { padding: 8px; - background: url('../img/transp50.png'); + background: url(asset_path('transp50.png')); /*-moz-border-radius: 5px;*/ } @@ -54,9 +54,9 @@ width: 98%; } -.plupload_header {background: #2A2C2E url('../img/backgrounds.gif') repeat-x;} +.plupload_header {background: #2A2C2E url(asset_path('backgrounds.gif')) repeat-x;} .plupload_header_content { - background: url('../img/backgrounds.gif') no-repeat 0 -317px; + background: url(asset_path('backgrounds.gif')) no-repeat 0 -317px; min-height: 56px; padding-left: 60px; color: #FFF; @@ -83,7 +83,7 @@ .plupload_filelist li { padding: 10px 8px; - background: #F5F5F5 url('../img/backgrounds.gif') repeat-x 0 -156px; + background: #F5F5F5 url(asset_path('backgrounds.gif')) repeat-x 0 -156px; border-bottom: 1px solid #DDD; } @@ -122,20 +122,20 @@ height: 16px; } -li.plupload_uploading {background: #ECF3DC url('../img/backgrounds.gif') repeat-x 0 -238px;} +li.plupload_uploading {background: #ECF3DC url(asset_path('backgrounds.gif')) repeat-x 0 -238px;} li.plupload_done {color:#AAA} li.plupload_delete a { - background: url('../img/delete.gif'); + background: url(asset_path('delete.gif')); } li.plupload_failed a { - background: url('../img/error.gif'); + background: url(asset_path('error.gif')); cursor: default; } li.plupload_done a { - background: url('../img/done.gif'); + background: url(asset_path('done.gif')); cursor: default; } diff --git a/vendor/assets/javascripts/plupload/js/jquery.ui.plupload/css/jquery.ui.plupload.css b/app/assets/stylesheets/jquery.ui.plupload.scss similarity index 90% rename from vendor/assets/javascripts/plupload/js/jquery.ui.plupload/css/jquery.ui.plupload.css rename to app/assets/stylesheets/jquery.ui.plupload.scss index a819fff..2aa9dd3 100644 --- a/vendor/assets/javascripts/plupload/js/jquery.ui.plupload/css/jquery.ui.plupload.css +++ b/app/assets/stylesheets/jquery.ui.plupload.scss @@ -20,14 +20,14 @@ div.plupload div.plupload_header {border-width: 0 0 1px 0; position: relative;} } .plupload_header_content { - background-image: url('../img/plupload.png'); + background-image: url(asset_path('plupload.png')); background-repeat: no-repeat; background-position: 8px center; min-height: 56px; padding-left: 60px; position:relative; } -.plupload_header_content_bw {background-image: url('../img/plupload-bw.png');} +.plupload_header_content_bw {background-image: url(asset_path('plupload-bw.png'));} .plupload_header_title { font: normal 18px sans-serif; padding: 6px 0 3px; @@ -61,7 +61,6 @@ div.plupload div.plupload_header {border-width: 0 0 1px 0; position: relative;} max-height: 180px; min-height: 168px; _height: 168px; - overflow-y: auto; } .plupload_file_size, .plupload_file_status {text-align: right;} diff --git a/app/controllers/admin/application_controller.rb b/app/controllers/admin/application_controller.rb deleted file mode 100644 index 99a9d86..0000000 --- a/app/controllers/admin/application_controller.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Admin::ApplicationController < ApplicationController - - before_filter :require_role_admin - -end diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb deleted file mode 100644 index 9ca0051..0000000 --- a/app/controllers/admin/users_controller.rb +++ /dev/null @@ -1,47 +0,0 @@ -class Admin::UsersController < Admin::ApplicationController - - def index - @users = User.find(:all, :order => "Name, email") - end - - def show - @user = User.find(params[:id]) - end - - def new - @user = User.new - end - - def create - @user = User.new(params[:user]) - if @user.save - flash[:notice] = "Account registered!" - redirect_to @user - else - render :action => :new - end - end - - def edit - @user = User.find(params[:id]) - end - - def update - @user = User.find(params[:id]) - if @user.update_attributes(params[:user]) - flash[:notice] = "Account updated!" - redirect_to @user - else - render :action => :edit - end - end - - def destroy - @user = User.find(params[:id]) - if @user.destroy - redirect_to users_path - else - redirect_to @user - end - end -end diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb index 7cfda39..831c8c8 100644 --- a/app/controllers/albums_controller.rb +++ b/app/controllers/albums_controller.rb @@ -1,10 +1,10 @@ class AlbumsController < ApplicationController before_filter :check_public_access - before_filter :require_role_admin, :only => [:untouched, :new, :create, :edit, :update, :destroy] + skip_before_filter :authenticate_user!, :only => [:index, :show] def index if params[:tag_id] - @albums = Album.find(:all, :conditions => [ "id IN ( SELECT DISTINCT photos.album_id FROM photos WHERE photos.id IN ( SELECT photo_id FROM photo_tags WHERE photo_tags.tag_id = :q) )", { :q => Tag.find( params[:tag_id] ).id } ], :order => 'title') + @albums = Album.where(:conditions => [ "id IN ( SELECT DISTINCT photos.album_id FROM photos WHERE photos.id IN ( SELECT photo_id FROM photo_tags WHERE photo_tags.tag_id = :q) )", { :q => Tag.find( params[:tag_id] ).id } ]).order('title') elsif params[:q] #search = params[:q] #search = search.split("AND").map{|q|q.strip} @@ -20,7 +20,7 @@ class AlbumsController < ApplicationController end } else - @albums = Album.find(:all, :order => 'title') + @albums = Album.order('albums.title') end respond_to do |format| format.html diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 46867fc..fd82122 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,86 +2,33 @@ # Likewise, all the methods added will be available for all controllers. class ApplicationController < ActionController::Base + layout 'bootstrap' helper :all # include all helpers, all the time protect_from_forgery # See ActionController::RequestForgeryProtection for details - helper_method :current_user, :current_user_session - + before_filter :authenticate_user!, :set_current_user before_filter :setup - private - - def setup - redirect_to new_account_path if User.all.length == 0 - end - - def check_public_access - require_user if ENV['PRIVATE'] == 'true' - end + # This hack is needed to access the current user in models. See http://rails-bestpractices.com/posts/47-fetch-current-user-in-models + def set_current_user + User.current = current_user + end - def current_user_session - return @current_user_session if defined?(@current_user_session) - @current_user_session = UserSession.find - end + def setup + redirect_to new_account_path if User.all.size == 0 + end - def current_user - return @current_user if defined?(@current_user) - @current_user = current_user_session && current_user_session.user - end + def check_public_access + require_user if ENV['PRIVATE'] == 'true' + end - def require_role(roles = []) - unless current_user && current_user.in_role?(*roles) - store_location - flash[:notice] = "You must have permission to access this page" - redirect_to account_path - return false - end - return true - end + def store_location + session[:return_to] = request.fullpath + end - def require_role_admin - return false if !require_user - return require_role("admin") - end - - def require_permission(permissions = []) - return false if !require_user - unless current_user && current_user.has_permission?(*permissions) - store_location - flash[:notice] = "You must have permission to access this page" - redirect_to account_path - return false - end - return true - end - - def require_user - unless current_user - store_location - flash[:notice] = "You must be logged in to access this page" - redirect_to login_path - return false - end - return true - end - - def require_no_user - if current_user - store_location - flash[:notice] = "Already logged in. Please logout" - redirect_to account_path - return false - end - return true - end - - def store_location - session[:return_to] = request.fullpath - end - - def redirect_back_or_default(default) - redirect_to(session[:return_to] || default) - session[:return_to] = nil - end + def redirect_back_or_default(default) + redirect_to(session[:return_to] || default) + session[:return_to] = nil + end end diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb index bd67f8e..18d300e 100644 --- a/app/controllers/collections_controller.rb +++ b/app/controllers/collections_controller.rb @@ -1,9 +1,10 @@ class CollectionsController < ApplicationController before_filter :check_public_access - before_filter :require_role_admin, :only => [:new, :create, :edit, :update, :destroy] + skip_before_filter :authenticate_user!, :only => [:index, :show] + def index - @collections = Collection.find(:all, :order => 'title') + @collections = Collection.joins(:albums => :photos).group_for.order('collections.title') respond_to do |format| format.html format.json { render :json => @collections } @@ -13,7 +14,7 @@ class CollectionsController < ApplicationController def show @collection = Collection.find( params[:id] ) - @albums = @collection.albums.find(:all, :order => 'title') + @albums = @collection.albums.order('title') respond_to do |format| format.html format.json { render :json => @collection } diff --git a/app/controllers/locale_controller.rb b/app/controllers/locale_controller.rb new file mode 100644 index 0000000..60bfc78 --- /dev/null +++ b/app/controllers/locale_controller.rb @@ -0,0 +1,14 @@ +class LocaleController < ApplicationController + def set + if request.referer && request.referer.starts_with?('http://' + request.host) + session['return_to'] = request.referer + end + if params[:locale] && I18n.available_locales.include?(params[:locale].to_sym) + session[:locale] = I18n.locale = params[:locale].to_sym + flash.notice = t(:locale_changed) + else + flash[:error] = t(:locale_not_changed) + end + redirect_back_or_default(root_path) + end +end diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 909d157..ad698d7 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -1,17 +1,17 @@ class PhotosController < ApplicationController before_filter :check_public_access - before_filter :require_role_admin, :only => [:untouched, :upload, :new, :create, :edit, :update, :destroy, :scan] + skip_before_filter :authenticate_user!, :only => [:index, :show] def index if params[:tag_id] && params[:album_id] @tag = Tag.find_by_title!( params[:tag_id] ) - @photos = @tag.photos.find(:all, :conditions => ['photos.album_id = :album', {:album => Album.find(params[:album_id] ) } ], :order => "photos.id ASC") + @photos = @tag.photos.where(:conditions => ['photos.album_id = :album', {:album => Album.find(params[:album_id] ) } ]).order("photos.id ASC") elsif params[:tag_id] @tag = Tag.find_by_title!( params[:tag_id] ) - @photos = @tag.photos.find(:all, :order => "photos.id ASC") + @photos = @tag.photos.order("photos.id ASC") elsif params[:album_id] @album = Album.find( params[:album_id]) - @photos = @album.photos.find(:all, :order => "photos.id ASC") + @photos = @album.photos.order("photos.id ASC") elsif params[:q] #search = params[:q] #search = search.split("AND").map{|q|q.strip} @@ -25,7 +25,7 @@ class PhotosController < ApplicationController end } else - @photos = Photo.find(:all, :order => "photos.id ASC") + @photos = Photo.order("photos.id ASC") end respond_to do |format| format.html @@ -77,10 +77,10 @@ class PhotosController < ApplicationController def create @photo = Photo.new(params[:photo]) - @photo.file = params[:file] + @photo.attachment = params[:file] respond_to do |format| if @photo.save - format.html { render :text => "FILEID:" + @photo.file.album.url } + format.html { render :text => "FILEID:" + @photo.attachment.album.url } format.xml { render :nothing => true } else format.html { render :text => "ERRORS:" + @photo.errors.full_messages.join(" "), :status => 500 } @@ -91,7 +91,7 @@ class PhotosController < ApplicationController def edit @photo = Photo.find( params[:id]) - @tags = Tag.find(:all).map { |tag| tag.title }.join('\',\'') + @tags = Tag.all.map { |tag| tag.title }.join('\',\'') end def edit_multiple diff --git a/app/controllers/user_sessions_controller.rb b/app/controllers/user_sessions_controller.rb deleted file mode 100644 index acc3e57..0000000 --- a/app/controllers/user_sessions_controller.rb +++ /dev/null @@ -1,24 +0,0 @@ -class UserSessionsController < ApplicationController - before_filter :require_no_user, :only => [:new, :create] - before_filter :require_user, :only => :destroy - - def new - @user_session = UserSession.new - end - - def create - @user_session = UserSession.new(params[:user_session]) - if @user_session.save - flash[:notice] = "Login successful!" - redirect_back_or_default account_path - else - render :new - end - end - - def destroy - current_user_session.destroy - flash[:notice] = "Logout successful!" - redirect_to root_path - end -end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a7cb18d..8843607 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,7 +1,6 @@ class UsersController < ApplicationController before_filter :check_public_access - before_filter :require_no_user, :only => [:new, :create] - before_filter :require_user, :only => [:show, :edit, :update, :destroy] + skip_before_filter :authenticate_user!, :only => [:new, :create] skip_filter :setup def new diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 1062f12..44e7820 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -1,9 +1,3 @@ module UsersHelper - def has_permission?(permissions = []) - return current_user && current_user.has_permission?(permissions) - end - - def has_role?(roles = []) - return current_user && current_user.in_role?(roles) - end + end diff --git a/app/models/ability.rb b/app/models/ability.rb new file mode 100644 index 0000000..1064327 --- /dev/null +++ b/app/models/ability.rb @@ -0,0 +1,63 @@ +class Ability + include CanCan::Ability + + def initialize(user) + self.clear_aliased_actions + + alias_action :edit, :to => :update + alias_action :new, :to => :create + alias_action :new_action, :to => :create + alias_action :show, :to => :read + + if user.has_role? 'admin' + can :manage, :all + else + ############################# + can :read, User do |resource| + resource == user + end + can :update, User do |resource| + resource == user + end + can :create, User + ############################## + can :read, Profile do |resource| + resource == user + end + can :update, Profile do |resource| + resource == user + end + can :create, Profile + ############################### + can :read, Link do |resource| + resource == user + end + can :update, Link do |resource| + resource == user + end + can :create, Link + end + # Define abilities for the passed in user here. For example: + # + # user ||= User.new # guest user (not logged in) + # if user.admin? + # can :manage, :all + # else + # can :read, :all + # end + # + # The first argument to `can` is the action you are giving the user permission to do. + # If you pass :manage it will apply to every action. Other common actions here are + # :read, :create, :update and :destroy. + # + # The second argument is the resource the user can perform the action on. If you pass + # :all it will apply to every resource. Otherwise pass a Ruby class of the resource. + # + # The third argument is an optional hash of conditions to further filter the objects. + # For example, here the user can only update published articles. + # + # can :update, Article, :published => true + # + # See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities + end +end diff --git a/app/models/album.rb b/app/models/album.rb index d88c06c..3f0728f 100644 --- a/app/models/album.rb +++ b/app/models/album.rb @@ -1,4 +1,6 @@ class Album < ActiveRecord::Base + extend Ext::GroupFor + has_many :photos, :dependent => :destroy has_many :collection_albums has_many :collections, :through => :collection_albums @@ -12,7 +14,7 @@ class Album < ActiveRecord::Base attr_accessor :tags #attr_protected :path - + scope :untouched, where("albums.id IN ( SELECT DISTINCT photos.album_id FROM photos WHERE photos.description IS NULL AND photos.id NOT IN ( SELECT photo_id FROM photo_tags) )").order('title') scope :unused, where("albums.id NOT IN (SELECT album_id FROM collection_albums)") scope :used, where("albums.id IN (SELECT album_id FROM collection_albums)") diff --git a/app/models/collection.rb b/app/models/collection.rb index 926a7f7..666248f 100644 --- a/app/models/collection.rb +++ b/app/models/collection.rb @@ -1,10 +1,13 @@ class Collection < ActiveRecord::Base + extend Ext::GroupFor + has_many :collection_albums has_many :albums, :through => :collection_albums attr_accessor :album_list validates :title, :presence => true + def to_param "#{id}-#{title.parameterize}" end diff --git a/app/models/permission.rb b/app/models/permission.rb deleted file mode 100644 index c2951ff..0000000 --- a/app/models/permission.rb +++ /dev/null @@ -1,19 +0,0 @@ -class Permission < ActiveRecord::Base - # uncomment any of the following lines which is relevant to your application, - # or create your own with the name of the model which acts_as_permissible. - belongs_to :user - - belongs_to :role - - belongs_to :permissible, :polymorphic => true, :dependent => :destroy - - validates_presence_of :permissible_id, :permissible_type, :action - validates_format_of :action, :with => /^[a-z_]+$/ - validates_numericality_of :permissible_id - validates_uniqueness_of :action, :scope => [:permissible_id,:permissible_type] - - def to_hash - self.new_record? ? {} : {self.action => self.granted} - end - -end \ No newline at end of file diff --git a/app/models/photo.rb b/app/models/photo.rb index 652fb6d..552ab39 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -1,17 +1,16 @@ class Photo < ActiveRecord::Base - # TODO: path not used? it should be removed from the DB + extend Ext::GroupFor belongs_to :album has_many :photo_tags, :dependent => :destroy has_many :tags, :through => :photo_tags - mount_uploader :file, FileUploader + mount_uploader :attachment, FileUploader - validates :title, :presence => true - - before_validation :set_title + before_create :exif_read - #before_update :exif_write + before_update :exif_write + after_create :set_title attr_accessor :tag_list @@ -39,7 +38,7 @@ class Photo < ActiveRecord::Base end def tag_list - return self.tags.find(:all, :order => 'title').map{ |t| t.title }.sort.join(" ") + return self.tags.order('title').map{ |t| t.title }.sort.join(" ") end def tag_list=(tags) @@ -58,11 +57,13 @@ class Photo < ActiveRecord::Base private def set_title - self.title = self.file.file.basename.titleize unless self.title + a=self.attachment.file.basename + update_attribute(:title, a.titleize) + self.title = self.attachment.file.basename.titleize unless self.title end def exif_read - photo = MiniExiftool.new(self.file.file.file) + photo = MiniExiftool.new(self.attachment.file.file) self.longitude = photo.GPSLongitude if self.longitude.nil? self.latitude = photo.GPSLatitude if self.latitude.nil? self.title = photo.DocumentName if self.title.nil? @@ -72,7 +73,7 @@ class Photo < ActiveRecord::Base def exif_write # should only write if tags are changed as images can be large and thus ExifTool will take a while to write to the file - photo = MiniExiftool.new(self.file.file.file) + photo = MiniExiftool.new(self.attachment.file.file) photo.GPSLongitude = self.longitude photo.GPSLatitude = self.latitude photo.DocumentName = self.title diff --git a/app/models/role.rb b/app/models/role.rb index 8fbb325..a213fdf 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -1,12 +1,5 @@ class Role < ActiveRecord::Base - has_many :role_memberships, :as => :roleable, :dependent => :destroy - has_many :roles, :through => :role_memberships, :source => :role - - has_many :roleables, :class_name => "RoleMembership", :foreign_key => "role_id", :dependent => :destroy - has_many :subroles, :through => :roleables, :source => :roleable, :source_type => 'Role' - has_many :users, :through => :roleables, :source => :roleable, :source_type => 'User' - - validates :name, :presence => true, :uniqueness => true - - acts_as_permissible -end \ No newline at end of file + attr_accessible :name + + has_and_belongs_to_many :users +end diff --git a/app/models/role_membership.rb b/app/models/role_membership.rb deleted file mode 100644 index 9ebcbe2..0000000 --- a/app/models/role_membership.rb +++ /dev/null @@ -1,36 +0,0 @@ -class RoleMembership < ActiveRecord::Base - belongs_to :user - belongs_to :role - belongs_to :roleable, :polymorphic => true - - validates_presence_of :roleable_id, :roleable_type, :role_id - validates_uniqueness_of :role_id, :scope => [:roleable_id, :roleable_type] - validates_numericality_of :roleable_id, :role_id - validates_format_of :roleable_type, :with => /^[A-Z]{1}[a-z0-9]+([A-Z]{1}[a-z0-9]+)*$/ - validate :role_does_not_belong_to_itself_in_a_loop - - protected - def role_does_not_belong_to_itself_in_a_loop - if roleable_type == "Role" - if role_id == roleable_id - errors.add_to_base("A role cannot belong to itself.") - else - if belongs_to_itself_through_other?(roleable_id, role_id) - errors.add_to_base("A role cannot belong to a role which belongs to it.") - end - end - end - end - - def belongs_to_itself_through_other?(original_roleable_id, current_role_id) - if self.class.find(:first, :select => "id", :conditions => ["roleable_id=? AND roleable_type='Role' AND role_id=?",current_role_id,original_roleable_id]) - return true - else - memberships = self.class.find(:all, :select => "role_id", :conditions => ["roleable_id=? AND roleable_type='Role'",current_role_id]) - if memberships.any? {|membership| belongs_to_itself_through_other?(original_roleable_id,membership.role_id)} - return true - end - end - return false - end -end \ No newline at end of file diff --git a/app/models/user.rb b/app/models/user.rb index d1d3345..780cc4e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,4 +1,43 @@ class User < ActiveRecord::Base - acts_as_authentic - acts_as_permissible + devise :database_authenticatable, :registerable, :confirmable, :token_authenticatable, + :recoverable, :rememberable, :trackable, :validatable, :omniauthable, :lockable + + attr_accessible :id, :name, :second_name, :surname, :email, :password, :password_confirmation, :remember_me, :userpic + + mount_uploader :userpic, UserpicUploader + + has_and_belongs_to_many :roles + + def small_url + userpic.url(:small) + end + + alias_method :avatar, :small_url + + def thumb_url + userpic.url(:thumb) + end + + def original_url + userpic.url(:original) + end + + ########################################################## + # This hack is needed to access the current user in models. + #See http://rails-bestpractices.com/posts/47-fetch-current-user-in-models + def self.current + Thread.current[:user] + end + + def self.current=(user) + Thread.current[:user] = user + end + + def self.admin_created? + User.admin.count > 0 + end + + def has_role?(role_in_question) + roles.any? { |role| role.name == role_in_question.to_s } + end end diff --git a/app/models/user_session.rb b/app/models/user_session.rb deleted file mode 100644 index ec55ada..0000000 --- a/app/models/user_session.rb +++ /dev/null @@ -1,6 +0,0 @@ -class UserSession < Authlogic::Session::Base - # configuration here, see documentation for sub modules of Authlogic::Session - def to_key - new_record? ? nil : [ self.send(self.class.primary_key) ] - end -end diff --git a/app/uploaders/file_uploader.rb b/app/uploaders/file_uploader.rb index f429525..e38b330 100644 --- a/app/uploaders/file_uploader.rb +++ b/app/uploaders/file_uploader.rb @@ -2,6 +2,9 @@ class FileUploader < CarrierWave::Uploader::Base + @@generate_file_name = '' + @@original_filename = '' + # Include RMagick or ImageScience support # include CarrierWave::RMagick # include CarrierWave::ImageScience @@ -21,7 +24,15 @@ class FileUploader < CarrierWave::Uploader::Base # This is a sensible default for uploaders that are meant to be mounted: def store_dir #{}"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" - ENV['STORAGE_PATH'] + "/files/#{model.album.path}" + ENV['STORAGE_PATH'] + "/files/#{model.album.path}/#{model.id}" + end + + def filename + unless @@original_filename == original_filename + @@original_filename = original_filename + @@generate_file_name = "#{::SecureRandom.hex(8)}#{File.extname(original_filename).downcase}" if original_filename + end + @@generate_file_name end # Provide a default URL as a default if there hasn't been a file uploaded @@ -38,31 +49,34 @@ class FileUploader < CarrierWave::Uploader::Base # Create different versions of your uploaded files version :collection do - process :resize_to_fill => [200, 200] + process :resize_to_fill => [260, 180] def store_dir - ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}" + ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}/#{model.id}" end end + version :album do process :resize_to_fill => [100, 100] def store_dir - ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}" + ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}/#{model.id}" end end + version :preview do process :resize_to_fit => [210, 210] def store_dir - ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}" + ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}/#{model.id}" end end + version :single do process :resize_to_limit => [950, 950] def store_dir - ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}" + ENV['STORAGE_PATH'] + "/thumbs/#{model.album.path}/#{model.id}" end end @@ -71,10 +85,4 @@ class FileUploader < CarrierWave::Uploader::Base def extension_white_list %w(jpg jpeg gif png bmp tiff) end - - # Override the filename of the uploaded files - # def filename - # "something.jpg" if original_filename - # end - end diff --git a/app/uploaders/userpic_uploader.rb b/app/uploaders/userpic_uploader.rb new file mode 100644 index 0000000..888b822 --- /dev/null +++ b/app/uploaders/userpic_uploader.rb @@ -0,0 +1,21 @@ +class UserpicUploader < CarrierWave::Uploader::Base + include CarrierWave::MiniMagick + + def store_dir + "#{ENV['STORAGE_PATH']}/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}/original" + end + + def filename + "#{::SecureRandom.hex(8)}#{File.extname(original_filename).downcase}" if original_filename + end + + + version :small do + process :resize_to_fit => [100, 100] + + def store_dir + "#{ENV['STORAGE_PATH']}/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}/small" + end + end + +end \ No newline at end of file diff --git a/app/views/admin/users/_form.html.erb b/app/views/admin/users/_form.html.erb deleted file mode 100644 index b70ae04..0000000 --- a/app/views/admin/users/_form.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -<%= form.label :name, 'Display name' %>
-<%= form.text_field :name %>
-
-<%= form.label :email %>
-<%= form.text_field :email %>
-
-<%= form.label :password %>
-<%= form.password_field :password %>
-
-<%= form.label :password_confirmation %>
-<%= form.password_field :password_confirmation %>
-
diff --git a/app/views/admin/users/edit.html.erb b/app/views/admin/users/edit.html.erb deleted file mode 100644 index 4092d1c..0000000 --- a/app/views/admin/users/edit.html.erb +++ /dev/null @@ -1,15 +0,0 @@ -

Edit Account

- -<%= form_for @user do |f| %> - <%= f.error_messages %> - <%= render :partial => "form", :object => f %> - <%= f.submit "Update" %> -<% end %> - - - -<%= content_for :action_links do %> -<%= link_to("Delete user", { :action => "destroy", :id => @user }, - :confirm => "Are you sure you want to delete this user?", - :method => :delete) %> -<% end %> \ No newline at end of file diff --git a/app/views/admin/users/index.html.erb b/app/views/admin/users/index.html.erb deleted file mode 100644 index 401a5e2..0000000 --- a/app/views/admin/users/index.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -<% for user in @users %> -

<%= link_to user.name || user.email , user %>

-<% end %> - -<%= content_for :action_links do %> -<%= link_to "New user", new_user_path %> -<% end %> \ No newline at end of file diff --git a/app/views/admin/users/new.html.erb b/app/views/admin/users/new.html.erb deleted file mode 100644 index c73725d..0000000 --- a/app/views/admin/users/new.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -

Register

- -<%= form_for @user do |f| %> - <%= f.error_messages %> - <%= render :partial => "form", :object => f %> - <%= f.submit "Register" %> -<% end %> \ No newline at end of file diff --git a/app/views/admin/users/show.html.erb b/app/views/admin/users/show.html.erb deleted file mode 100644 index 77e999f..0000000 --- a/app/views/admin/users/show.html.erb +++ /dev/null @@ -1,45 +0,0 @@ -

- Name: - <%=h @user.name %> -

- -

- Email: - <%=h @user.email %> -

- - -

- Login count: - <%=h @user.login_count %> -

- -

- Last request at: - <%=h @user.last_request_at %> -

- -

- Last login at: - <%=h @user.last_login_at %> -

- -

- Current login at: - <%=h @user.current_login_at %> -

- -

- Last login ip: - <%=h @user.last_login_ip %> -

- -

- Current login ip: - <%=h @user.current_login_ip %> -

- - -<%= content_for :action_links do %> -<%= link_to 'Edit', edit_user_path(@user) %> -<% end %> \ No newline at end of file diff --git a/app/views/albums/show.html.erb b/app/views/albums/show.html.erb index 84a5cf7..8fb9819 100644 --- a/app/views/albums/show.html.erb +++ b/app/views/albums/show.html.erb @@ -6,7 +6,7 @@ <% for photo in @album.photos.find(:all, :order => "Id ASC") %> <% count += 1%> <% if count == 1 || ( (count-1) / 4.0 == ( (count-1) / 4.0).to_i ) %><% end %> - <%= link_to image_tag( photo.file.preview.url ), [@album.collections.first, @album, photo] %> + <%= link_to image_tag( photo.attachment.preview.url ), [@album.collections.first, @album, photo] %> <% if count / 4.0 == (count / 4.0).to_i %><% end %> <% end %> diff --git a/app/views/collections/_form.html.erb b/app/views/collections/_form.html.erb index 852fb53..39cd6c5 100644 --- a/app/views/collections/_form.html.erb +++ b/app/views/collections/_form.html.erb @@ -15,7 +15,7 @@ <% if album.photos.empty? %> <%= album.title %> <% else %> -<%= image_tag album.photos.first.file.album.url, :alt => album.title %> +<%= image_tag album.photos.first.attachment.album.url, :alt => album.title %> <% end %> <%= album_fields.hidden_field album.id %> diff --git a/app/views/collections/index.html.erb b/app/views/collections/index.html.erb index 25d1207..3c6ea58 100644 --- a/app/views/collections/index.html.erb +++ b/app/views/collections/index.html.erb @@ -1,14 +1,30 @@ -
-<% for collection in @collections %> -
-

<%= link_to collection.title, collection %>

- <%= link_to (image_tag collection.albums.find(:first).photos.first.file.collection.url ), collection_path(collection) unless collection.albums.empty? || collection.albums.find(:first).photos.empty? %> -
+<% @collections.in_groups_of(4).compact.each do |group| %> + <% unless group.compact.empty? %> + + <% end %> <% end %> -
+ <%= content_for :action_links do %> -<% if has_role?("admin") %> -<%= link_to "New collection", new_collection_path %> + <% if current_user and current_user.has_role?("admin") %> + <%= link_to "New collection", new_collection_path %> + <% end %> <% end %> -<% end %> \ No newline at end of file + diff --git a/app/views/collections/show.html.erb b/app/views/collections/show.html.erb index 90e2feb..6ec99b4 100644 --- a/app/views/collections/show.html.erb +++ b/app/views/collections/show.html.erb @@ -14,7 +14,7 @@ <% end %> <%= content_for :action_links do %> -<% if has_role?("admin") %> +<% if current_user and current_user.has_role?("admin") %> <%= link_to "PDF", collection_path(@collection, :format => 'pdf') %> |  <%= link_to "Edit collection", edit_collection_path(@collection) %> | <%= link_to "New album", new_collection_album_path(@collection) %> diff --git a/app/views/devise/_links.erb b/app/views/devise/_links.erb new file mode 100644 index 0000000..76b85d0 --- /dev/null +++ b/app/views/devise/_links.erb @@ -0,0 +1,24 @@ +<%- if controller_name != 'sessions' %> + <%= link_to t('devise.sign_in'), login_path %>
+<% end -%> + +<%- if devise_mapping.registerable? && controller_name != 'registrations' %> + <%= link_to t('devise.sign_up'), signup_path %>
+<% end -%> + +<%- if devise_mapping.recoverable? && controller_name != 'passwords' %> + <%= link_to t('devise.forgot_your_password'), new_password_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> + <%= link_to t('devise.send_confirmation_instructions'), new_confirmation_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %> + <%= link_to t('devise.send_unlock_instructions'), new_unlock_path(resource_name) %>
+<% end -%> +<%- if devise_mapping.omniauthable? %> + <%- resource_class.omniauth_providers.each do |provider| %> + <%= link_to t('devise.sign_in_with', :provider => provider.to_s.titleize), omniauth_authorize_path(resource_name, provider) %>
+ <% end -%> +<% end -%> \ No newline at end of file diff --git a/app/views/devise/confirmations/new.html.erb b/app/views/devise/confirmations/new.html.erb new file mode 100644 index 0000000..18d81b1 --- /dev/null +++ b/app/views/devise/confirmations/new.html.erb @@ -0,0 +1,12 @@ +

Resend confirmation instructions

+ +<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %> + <%= devise_error_messages! %> + +
<%= f.label :email %>
+ <%= f.email_field :email %>
+ +
<%= f.submit "Resend confirmation instructions" %>
+<% end %> + +<%= render "links" %> \ No newline at end of file diff --git a/app/views/devise/mailer/confirmation_instructions.html.erb b/app/views/devise/mailer/confirmation_instructions.html.erb new file mode 100644 index 0000000..a5c4585 --- /dev/null +++ b/app/views/devise/mailer/confirmation_instructions.html.erb @@ -0,0 +1,5 @@ +

Welcome <%= @resource.email %>!

+ +

You can confirm your account email through the link below:

+ +

<%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %>

diff --git a/app/views/devise/mailer/reset_password_instructions.html.erb b/app/views/devise/mailer/reset_password_instructions.html.erb new file mode 100644 index 0000000..ae9e888 --- /dev/null +++ b/app/views/devise/mailer/reset_password_instructions.html.erb @@ -0,0 +1,8 @@ +

Hello <%= @resource.email %>!

+ +

Someone has requested a link to change your password, and you can do this through the link below.

+ +

<%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %>

+ +

If you didn't request this, please ignore this email.

+

Your password won't change until you access the link above and create a new one.

diff --git a/app/views/devise/mailer/unlock_instructions.html.erb b/app/views/devise/mailer/unlock_instructions.html.erb new file mode 100644 index 0000000..2263c21 --- /dev/null +++ b/app/views/devise/mailer/unlock_instructions.html.erb @@ -0,0 +1,7 @@ +

Hello <%= @resource.email %>!

+ +

Your account has been locked due to an excessive amount of unsuccessful sign in attempts.

+ +

Click the link below to unlock your account:

+ +

<%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %>

diff --git a/app/views/devise/passwords/edit.html.erb b/app/views/devise/passwords/edit.html.erb new file mode 100644 index 0000000..5f7bcf8 --- /dev/null +++ b/app/views/devise/passwords/edit.html.erb @@ -0,0 +1,16 @@ +

Change your password

+ +<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %> + <%= devise_error_messages! %> + <%= f.hidden_field :reset_password_token %> + +
<%= f.label :password, "New password" %>
+ <%= f.password_field :password %>
+ +
<%= f.label :password_confirmation, "Confirm new password" %>
+ <%= f.password_field :password_confirmation %>
+ +
<%= f.submit "Change my password" %>
+<% end %> + +<%= render "links" %> \ No newline at end of file diff --git a/app/views/devise/passwords/new.html.erb b/app/views/devise/passwords/new.html.erb new file mode 100644 index 0000000..b0b5690 --- /dev/null +++ b/app/views/devise/passwords/new.html.erb @@ -0,0 +1,12 @@ +

Forgot your password?

+ +<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %> + <%= devise_error_messages! %> + +
<%= f.label :email %>
+ <%= f.email_field :email %>
+ +
<%= f.submit "Send me reset password instructions" %>
+<% end %> + +<%= render "links" %> \ No newline at end of file diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb new file mode 100644 index 0000000..bb66fbf --- /dev/null +++ b/app/views/devise/registrations/edit.html.erb @@ -0,0 +1,25 @@ +

Edit <%= resource_name.to_s.humanize %>

+ +<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %> + <%= devise_error_messages! %> + +
<%= f.label :email %>
+ <%= f.email_field :email %>
+ +
<%= f.label :password %> (leave blank if you don't want to change it)
+ <%= f.password_field :password, :autocomplete => "off" %>
+ +
<%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation %>
+ +
<%= f.label :current_password %> (we need your current password to confirm your changes)
+ <%= f.password_field :current_password %>
+ +
<%= f.submit "Update" %>
+<% end %> + +

Cancel my account

+ +

Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.

+ +<%= link_to "Back", :back %> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb new file mode 100644 index 0000000..f5136f1 --- /dev/null +++ b/app/views/devise/registrations/new.html.erb @@ -0,0 +1,18 @@ +

Sign up

+ +<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> + <%= devise_error_messages! %> + +
<%= f.label :email %>
+ <%= f.email_field :email %>
+ +
<%= f.label :password %>
+ <%= f.password_field :password %>
+ +
<%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation %>
+ +
<%= f.submit "Sign up" %>
+<% end %> + +<%= render "links" %> diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb new file mode 100644 index 0000000..a4a21fb --- /dev/null +++ b/app/views/devise/sessions/new.html.erb @@ -0,0 +1,17 @@ +

<%= t("devise.sign_in") %>

+ +<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %> +
<%= f.label :email %>
+ <%= f.email_field :email %>
+ +
<%= f.label :password %>
+ <%= f.password_field :password %>
+ + <% if devise_mapping.rememberable? -%> +
<%= f.check_box :remember_me %> <%= f.label :remember_me %>
+ <% end -%> + +
<%= f.submit "Sign in" %>
+<% end %> + +<%= render "links" %> \ No newline at end of file diff --git a/app/views/devise/unlocks/new.html.erb b/app/views/devise/unlocks/new.html.erb new file mode 100644 index 0000000..0dc79ac --- /dev/null +++ b/app/views/devise/unlocks/new.html.erb @@ -0,0 +1,12 @@ +

Resend unlock instructions

+ +<%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %> + <%= devise_error_messages! %> + +
<%= f.label :email %>
+ <%= f.email_field :email %>
+ +
<%= f.submit "Resend unlock instructions" %>
+<% end %> + +<%= render "links" %> \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 470b279..bb305a7 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,13 +1,7 @@ - - <%= ENV['TITLE'] || "Photos" %> - - - <%= yield :head %> - <%= stylesheet_link_tag 'application' %> - <%= csrf_meta_tag %> + <%= render :partial => 'shared/head' %>
@@ -43,7 +37,6 @@
-<%= javascript_include_tag 'jquery-1.4.2.js', 'rails', 'balder' %> -<%= yield :javascript %> + diff --git a/app/views/layouts/bootstrap.html.erb b/app/views/layouts/bootstrap.html.erb new file mode 100644 index 0000000..72a800d --- /dev/null +++ b/app/views/layouts/bootstrap.html.erb @@ -0,0 +1,29 @@ + + + + <%= render :partial => 'shared/head' %> + + +<%= render :partial => 'shared/nav_bar' %> +
+ +
+

Hello, world!

+

This is a template for a simple marketing or informational website. It includes a large callout called the hero + unit and three supporting pieces of content. Use it as a starting point to create something more unique.

+

Learn more »

+
+ +
+
+ <%= yield %> +
+
+
+ +
+ + + diff --git a/app/views/photos/_form.html.erb b/app/views/photos/_form.html.erb index 39702ca..1718f01 100644 --- a/app/views/photos/_form.html.erb +++ b/app/views/photos/_form.html.erb @@ -1,14 +1,14 @@ <%= content_for :javascript do %> -<%= javascript_include_tag "tag/tag" -%> + <%= javascript_include_tag "tag/tag" -%> <% end %> <%= hidden_field_tag :all_tags, @tags %> <%= form.label :title %>
<%= form.text_field :title %>
-
+
<%= form.label :tag_list %>
-<%= form.text_field :tag_list, { :autocomplete => "off", :class => 'tag_list'} %>
-
+<%= form.text_field :tag_list, {:autocomplete => "off", :class => 'tag_list'} %>
+
<%= form.label :description %>
<%= form.text_area :description %>

-

On disk: ~/<%= @photo.file.path %>

\ No newline at end of file +

On disk: ~/<%= @photo.attachment.path %>

\ No newline at end of file diff --git a/app/views/photos/_photo.pdf.erb b/app/views/photos/_photo.pdf.erb index 00259fe..6b065fd 100644 --- a/app/views/photos/_photo.pdf.erb +++ b/app/views/photos/_photo.pdf.erb @@ -1 +1 @@ -<%= image_tag photo.file.single.url %>
\ No newline at end of file +<%= image_tag photo.attachment.single.url %>
\ No newline at end of file diff --git a/app/views/photos/_thumb.html.erb b/app/views/photos/_thumb.html.erb index fc8870b..d8eff19 100644 --- a/app/views/photos/_thumb.html.erb +++ b/app/views/photos/_thumb.html.erb @@ -1 +1 @@ -<%= link_to (image_tag eval('photo.file.' + (defined?(photosize) ? photosize : "album") + '.url') ), [photo.album.collections.first, photo.album, photo] %> \ No newline at end of file +<%= link_to (image_tag eval('photo.attachment.' + (defined?(photosize) ? photosize : "album") + '.url')), [photo.album.collections.first, photo.album, photo] %> \ No newline at end of file diff --git a/app/views/photos/edit.html.erb b/app/views/photos/edit.html.erb index 6341f62..8befd2f 100644 --- a/app/views/photos/edit.html.erb +++ b/app/views/photos/edit.html.erb @@ -1,17 +1,17 @@

Edit Photo

-<%= image_tag @photo.file.preview.url %> - +<%= image_tag @photo.attachment.preview.url %> + <%= form_for @photo do |f| %> -<%= hidden_field_tag :collection_id, params[:collection_id] %> -<%= hidden_field_tag :album_id, params[:album_id] %> - <%= f.error_messages %> - <%= render :partial => "form", :object => f %> - <%= f.submit "Update" %> + <%= hidden_field_tag :collection_id, params[:collection_id] %> + <%= hidden_field_tag :album_id, params[:album_id] %> + <%= f.error_messages %> + <%= render :partial => "form", :object => f %> + <%= f.submit "Update" %> <% end %> <%= content_for :action_links do %> -<%= link_to("Delete photo", { :action => "destroy", :id => @photo, :collection_id => params[:collection_id] }, - :confirm => "Are you sure you want to delete this photo?", - :method => :delete) %> + <%= link_to("Delete photo", {:action => "destroy", :id => @photo, :collection_id => params[:collection_id]}, + :confirm => "Are you sure you want to delete this photo?", + :method => :delete) %> <% end %> \ No newline at end of file diff --git a/app/views/photos/edit_multiple.html.erb b/app/views/photos/edit_multiple.html.erb index addebb5..d05fb0d 100644 --- a/app/views/photos/edit_multiple.html.erb +++ b/app/views/photos/edit_multiple.html.erb @@ -1,15 +1,15 @@ -<%= form_for :photos, :url => update_multiple_photos_path, :html => { :method => :put } do |f| %> -<% for photo in @photos %> -

-<%= f.fields_for photo, :index => photo.id do |p|%> - <%= p.check_box :_delete %> - <%= render :partial => "photos/thumb", :locals => {:photo => photo } %> - <%= p.text_field :title %> - <%= p.text_field :tags, :value => photo.tag_list %> -<% end%> -

-<% end%> -

<%= f.submit "Submit" %>

+<%= form_for :photos, :url => update_multiple_photos_path, :html => {:method => :put} do |f| %> + <% for photo in @photos %> +

+ <%= f.fields_for photo, :index => photo.id do |p| %> + <%= p.check_box :_delete %> + <%= render :partial => "photos/thumb", :locals => {:photo => photo} %> + <%= p.text_field :title %> + <%= p.text_field :tags, :value => photo.tag_list %> + <% end %> +

+ <% end %> +

<%= f.submit "Submit" %>

<% end %> -
<%= link_to "Back to #{@album.title}", @album %> \ No newline at end of file +
<%= link_to "Back to #{@album.title}", @album %> \ No newline at end of file diff --git a/app/views/photos/index.html.erb b/app/views/photos/index.html.erb index a748a1d..4721360 100644 --- a/app/views/photos/index.html.erb +++ b/app/views/photos/index.html.erb @@ -1,6 +1,6 @@ - + <%= content_for :action_links do %> -<%= link_to "Show albums containing photos tagged with #{params[:q]}", albums_path(:q => params[:q]) if params[:q] %> -<%= link_to "Show all photos tagged with #{params[:tag_id]}", tag_photos_path(params[:tag_id]) if params[:tag_id] && params[:album_id] %> + <%= link_to "Show albums containing photos tagged with #{params[:q]}", albums_path(:q => params[:q]) if params[:q] %> + <%= link_to "Show all photos tagged with #{params[:tag_id]}", tag_photos_path(params[:tag_id]) if params[:tag_id] && params[:album_id] %> <% end %> \ No newline at end of file diff --git a/app/views/photos/show.html.erb b/app/views/photos/show.html.erb index 8399e47..4d458a7 100644 --- a/app/views/photos/show.html.erb +++ b/app/views/photos/show.html.erb @@ -1,34 +1,34 @@ -

<%= @photo.title%>

+

<%= @photo.title %>

- -

<%= link_to_if @next, image_tag(@photo.file.single.url ), [ @photo.album.collections.first, @photo.album, @next] %>

+ +

<%= link_to_if @next, image_tag(@photo.attachment.single.url), [@photo.album.collections.first, @photo.album, @next] %>

<%= @photo.description %>

-

Tagged with: -<% for tag in @photo.tags.map{|tag|tag.title}.sort %> -<%= link_to tag, tag_photos_path(tag) %> -<% end %> +

Tagged with: + <% for tag in @photo.tags.map { |tag| tag.title }.sort %> + <%= link_to tag, tag_photos_path(tag) %> + <% end %> -<%= content_for :action_links do %> -<% if has_role?("admin") %> -<% if params[:collection_id] %> -<%= link_to "Edit photo", edit_collection_album_photo_path(params[:collection_id], params[:album_id], @photo) %> -<% else %> -<%= link_to "Edit photo", edit_photo_path(@photo) %> -<% end %> -<% end %> + <%= content_for :action_links do %> + <% if current_user and current_user.has_role?("admin") %> + <% if params[:collection_id] %> + <%= link_to "Edit photo", edit_collection_album_photo_path(params[:collection_id], params[:album_id], @photo) %> + <% else %> + <%= link_to "Edit photo", edit_photo_path(@photo) %> + <% end %> + <% end %> <% end %> \ No newline at end of file diff --git a/app/views/photos/untouched.html.erb b/app/views/photos/untouched.html.erb index 3b1424c..ebb5c22 100644 --- a/app/views/photos/untouched.html.erb +++ b/app/views/photos/untouched.html.erb @@ -1,12 +1,12 @@ -<%= form_for :photos, :url => update_multiple_photos_path, :html => { :method => :put } do |f| %> -<% for photo in @photos %> -

-<%= f.fields_for photo do |p|%> - <%= render :partial => "photos/thumb", :locals => {:photo => photo } %> - <%= p.text_field :title, :index => photo.id %> - <%= p.text_field :tags, :index => photo.id, :value => photo.tag_list %> -<% end%> -

-<% end%> -

<%= f.submit "Submit" %>

+<%= form_for :photos, :url => update_multiple_photos_path, :html => {:method => :put} do |f| %> + <% for photo in @photos %> +

+ <%= f.fields_for photo do |p| %> + <%= render :partial => "photos/thumb", :locals => {:photo => photo} %> + <%= p.text_field :title, :index => photo.id %> + <%= p.text_field :tags, :index => photo.id, :value => photo.tag_list %> + <% end %> +

+ <% end %> +

<%= f.submit "Submit" %>

<% end %> \ No newline at end of file diff --git a/app/views/photos/upload.html.erb b/app/views/photos/upload.html.erb index 407d84b..a473b90 100644 --- a/app/views/photos/upload.html.erb +++ b/app/views/photos/upload.html.erb @@ -1,13 +1,7 @@ <%= content_for :javascript do %> - - <%= javascript_include_tag "plupload/js/plupload.full.js" -%> - <%= javascript_include_tag "plupload/js/jquery.plupload.queue/jquery.plupload.queue.js" -%> -