big update
This commit is contained in:
parent
ac9a8886de
commit
e59d11e1c9
Binary file not shown.
Binary file not shown.
Binary file not shown.
34
Gemfile
34
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.
|
||||
|
|
153
Gemfile.lock
153
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
|
||||
|
|
2
Rakefile
2
Rakefile
|
@ -4,4 +4,4 @@
|
|||
require File.expand_path('../config/application', __FILE__)
|
||||
require 'rake'
|
||||
|
||||
Balder::Application.load_tasks
|
||||
Photomix::Application.load_tasks
|
||||
|
|
18
app/assets/javascripts/application.js
Normal file
18
app/assets/javascripts/application.js
Normal file
|
@ -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 .
|
4
app/assets/javascripts/bootstrap.js.coffee
Normal file
4
app/assets/javascripts/bootstrap.js.coffee
Normal file
|
@ -0,0 +1,4 @@
|
|||
jQuery ->
|
||||
$("a[rel=popover]").popover()
|
||||
$(".tooltip").tooltip()
|
||||
$("a[rel=tooltip]").tooltip()
|
|
@ -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;
|
||||
}
|
||||
/*
|
||||
*= require_self
|
||||
*= require_tree .
|
||||
*= require jquery.plupload.queue
|
||||
*= require bootstrap_and_overrides
|
||||
*/
|
32
app/assets/stylesheets/bootstrap_and_overrides.css.less
vendored
Normal file
32
app/assets/stylesheets/bootstrap_and_overrides.css.less
vendored
Normal file
|
@ -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;
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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;}
|
|
@ -1,5 +0,0 @@
|
|||
class Admin::ApplicationController < ApplicationController
|
||||
|
||||
before_filter :require_role_admin
|
||||
|
||||
end
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -2,80 +2,27 @@
|
|||
# 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
|
||||
# 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 setup
|
||||
redirect_to new_account_path if User.all.length == 0
|
||||
redirect_to new_account_path if User.all.size == 0
|
||||
end
|
||||
|
||||
def check_public_access
|
||||
require_user if ENV['PRIVATE'] == 'true'
|
||||
end
|
||||
|
||||
def current_user_session
|
||||
return @current_user_session if defined?(@current_user_session)
|
||||
@current_user_session = UserSession.find
|
||||
end
|
||||
|
||||
def current_user
|
||||
return @current_user if defined?(@current_user)
|
||||
@current_user = current_user_session && current_user_session.user
|
||||
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 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
|
||||
|
|
|
@ -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 }
|
||||
|
|
14
app/controllers/locale_controller.rb
Normal file
14
app/controllers/locale_controller.rb
Normal file
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
63
app/models/ability.rb
Normal file
63
app/models/ability.rb
Normal file
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
class Role < ActiveRecord::Base
|
||||
has_many :role_memberships, :as => :roleable, :dependent => :destroy
|
||||
has_many :roles, :through => :role_memberships, :source => :role
|
||||
attr_accessible :name
|
||||
|
||||
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
|
||||
has_and_belongs_to_many :users
|
||||
end
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
21
app/uploaders/userpic_uploader.rb
Normal file
21
app/uploaders/userpic_uploader.rb
Normal file
|
@ -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
|
|
@ -1,12 +0,0 @@
|
|||
<%= form.label :name, 'Display name' %><br />
|
||||
<%= form.text_field :name %><br />
|
||||
<br />
|
||||
<%= form.label :email %><br />
|
||||
<%= form.text_field :email %><br />
|
||||
<br/>
|
||||
<%= form.label :password %><br />
|
||||
<%= form.password_field :password %><br />
|
||||
<br/>
|
||||
<%= form.label :password_confirmation %><br />
|
||||
<%= form.password_field :password_confirmation %><br />
|
||||
<br/>
|
|
@ -1,15 +0,0 @@
|
|||
<h1>Edit Account</h1>
|
||||
|
||||
<%= 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 %>
|
|
@ -1,7 +0,0 @@
|
|||
<% for user in @users %>
|
||||
<h2><%= link_to user.name || user.email , user %></h2>
|
||||
<% end %>
|
||||
|
||||
<%= content_for :action_links do %>
|
||||
<%= link_to "New user", new_user_path %>
|
||||
<% end %>
|
|
@ -1,7 +0,0 @@
|
|||
<h1>Register</h1>
|
||||
|
||||
<%= form_for @user do |f| %>
|
||||
<%= f.error_messages %>
|
||||
<%= render :partial => "form", :object => f %>
|
||||
<%= f.submit "Register" %>
|
||||
<% end %>
|
|
@ -1,45 +0,0 @@
|
|||
<p>
|
||||
<b>Name:</b>
|
||||
<%=h @user.name %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Email:</b>
|
||||
<%=h @user.email %>
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
<b>Login count:</b>
|
||||
<%=h @user.login_count %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Last request at:</b>
|
||||
<%=h @user.last_request_at %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Last login at:</b>
|
||||
<%=h @user.last_login_at %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Current login at:</b>
|
||||
<%=h @user.current_login_at %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Last login ip:</b>
|
||||
<%=h @user.last_login_ip %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Current login ip:</b>
|
||||
<%=h @user.current_login_ip %>
|
||||
</p>
|
||||
|
||||
|
||||
<%= content_for :action_links do %>
|
||||
<%= link_to 'Edit', edit_user_path(@user) %>
|
||||
<% end %>
|
|
@ -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 ) %><tr><% end %>
|
||||
<td><%= link_to image_tag( photo.file.preview.url ), [@album.collections.first, @album, photo] %></td>
|
||||
<td><%= link_to image_tag( photo.attachment.preview.url ), [@album.collections.first, @album, photo] %></td>
|
||||
<% if count / 4.0 == (count / 4.0).to_i %></tr><% end %>
|
||||
<% end %>
|
||||
</table>
|
||||
|
|
|
@ -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 %>
|
||||
</span>
|
||||
|
|
|
@ -1,14 +1,30 @@
|
|||
<div id="multipleimages">
|
||||
<% for collection in @collections %>
|
||||
<div class="thumb">
|
||||
<h3><%= link_to collection.title, collection %></h3>
|
||||
<%= 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? %>
|
||||
<ul class="thumbnails">
|
||||
<% group.compact.each do |collection| %>
|
||||
<% unless collection.albums.empty? %>
|
||||
<% unless collection.albums.first.photos.empty? %>
|
||||
<li class="span3">
|
||||
<div class="thumbnail">
|
||||
<%= image_tag collection.albums.first.photos.first.attachment.collection.url %>
|
||||
<div class="caption">
|
||||
<h5><%= collection.title %></h5>
|
||||
<p><%= collection.description %></p>
|
||||
<p><%= link_to 'View', (collection_path(collection) unless collection.albums.empty? || collection.albums.first.photos.empty?), {:class => 'btn btn-primary'} %></p>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
|
||||
<%= content_for :action_links do %>
|
||||
<% if has_role?("admin") %>
|
||||
<%= link_to "New collection", new_collection_path %>
|
||||
<% end %>
|
||||
<% if current_user and current_user.has_role?("admin") %>
|
||||
<%= link_to "New collection", new_collection_path %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -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) %>
|
||||
|
|
24
app/views/devise/_links.erb
Normal file
24
app/views/devise/_links.erb
Normal file
|
@ -0,0 +1,24 @@
|
|||
<%- if controller_name != 'sessions' %>
|
||||
<%= link_to t('devise.sign_in'), login_path %><br />
|
||||
<% end -%>
|
||||
|
||||
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
|
||||
<%= link_to t('devise.sign_up'), signup_path %><br />
|
||||
<% end -%>
|
||||
|
||||
<%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
|
||||
<%= link_to t('devise.forgot_your_password'), new_password_path(resource_name) %><br />
|
||||
<% end -%>
|
||||
|
||||
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
|
||||
<%= link_to t('devise.send_confirmation_instructions'), new_confirmation_path(resource_name) %><br />
|
||||
<% 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) %><br />
|
||||
<% 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) %><br />
|
||||
<% end -%>
|
||||
<% end -%>
|
12
app/views/devise/confirmations/new.html.erb
Normal file
12
app/views/devise/confirmations/new.html.erb
Normal file
|
@ -0,0 +1,12 @@
|
|||
<h2>Resend confirmation instructions</h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
<div><%= f.label :email %><br />
|
||||
<%= f.email_field :email %></div>
|
||||
|
||||
<div><%= f.submit "Resend confirmation instructions" %></div>
|
||||
<% end %>
|
||||
|
||||
<%= render "links" %>
|
|
@ -0,0 +1,5 @@
|
|||
<p>Welcome <%= @resource.email %>!</p>
|
||||
|
||||
<p>You can confirm your account email through the link below:</p>
|
||||
|
||||
<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
|
|
@ -0,0 +1,8 @@
|
|||
<p>Hello <%= @resource.email %>!</p>
|
||||
|
||||
<p>Someone has requested a link to change your password, and you can do this through the link below.</p>
|
||||
|
||||
<p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
|
||||
|
||||
<p>If you didn't request this, please ignore this email.</p>
|
||||
<p>Your password won't change until you access the link above and create a new one.</p>
|
7
app/views/devise/mailer/unlock_instructions.html.erb
Normal file
7
app/views/devise/mailer/unlock_instructions.html.erb
Normal file
|
@ -0,0 +1,7 @@
|
|||
<p>Hello <%= @resource.email %>!</p>
|
||||
|
||||
<p>Your account has been locked due to an excessive amount of unsuccessful sign in attempts.</p>
|
||||
|
||||
<p>Click the link below to unlock your account:</p>
|
||||
|
||||
<p><%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %></p>
|
16
app/views/devise/passwords/edit.html.erb
Normal file
16
app/views/devise/passwords/edit.html.erb
Normal file
|
@ -0,0 +1,16 @@
|
|||
<h2>Change your password</h2>
|
||||
|
||||
<%= 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 %>
|
||||
|
||||
<div><%= f.label :password, "New password" %><br />
|
||||
<%= f.password_field :password %></div>
|
||||
|
||||
<div><%= f.label :password_confirmation, "Confirm new password" %><br />
|
||||
<%= f.password_field :password_confirmation %></div>
|
||||
|
||||
<div><%= f.submit "Change my password" %></div>
|
||||
<% end %>
|
||||
|
||||
<%= render "links" %>
|
12
app/views/devise/passwords/new.html.erb
Normal file
12
app/views/devise/passwords/new.html.erb
Normal file
|
@ -0,0 +1,12 @@
|
|||
<h2>Forgot your password?</h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
<div><%= f.label :email %><br />
|
||||
<%= f.email_field :email %></div>
|
||||
|
||||
<div><%= f.submit "Send me reset password instructions" %></div>
|
||||
<% end %>
|
||||
|
||||
<%= render "links" %>
|
25
app/views/devise/registrations/edit.html.erb
Normal file
25
app/views/devise/registrations/edit.html.erb
Normal file
|
@ -0,0 +1,25 @@
|
|||
<h2>Edit <%= resource_name.to_s.humanize %></h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
<div><%= f.label :email %><br />
|
||||
<%= f.email_field :email %></div>
|
||||
|
||||
<div><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
|
||||
<%= f.password_field :password, :autocomplete => "off" %></div>
|
||||
|
||||
<div><%= f.label :password_confirmation %><br />
|
||||
<%= f.password_field :password_confirmation %></div>
|
||||
|
||||
<div><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
|
||||
<%= f.password_field :current_password %></div>
|
||||
|
||||
<div><%= f.submit "Update" %></div>
|
||||
<% end %>
|
||||
|
||||
<h3>Cancel my account</h3>
|
||||
|
||||
<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.</p>
|
||||
|
||||
<%= link_to "Back", :back %>
|
18
app/views/devise/registrations/new.html.erb
Normal file
18
app/views/devise/registrations/new.html.erb
Normal file
|
@ -0,0 +1,18 @@
|
|||
<h2>Sign up</h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
<div><%= f.label :email %><br />
|
||||
<%= f.email_field :email %></div>
|
||||
|
||||
<div><%= f.label :password %><br />
|
||||
<%= f.password_field :password %></div>
|
||||
|
||||
<div><%= f.label :password_confirmation %><br />
|
||||
<%= f.password_field :password_confirmation %></div>
|
||||
|
||||
<div><%= f.submit "Sign up" %></div>
|
||||
<% end %>
|
||||
|
||||
<%= render "links" %>
|
17
app/views/devise/sessions/new.html.erb
Normal file
17
app/views/devise/sessions/new.html.erb
Normal file
|
@ -0,0 +1,17 @@
|
|||
<h2><%= t("devise.sign_in") %></h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
|
||||
<div><%= f.label :email %><br />
|
||||
<%= f.email_field :email %></div>
|
||||
|
||||
<div><%= f.label :password %><br />
|
||||
<%= f.password_field :password %></div>
|
||||
|
||||
<% if devise_mapping.rememberable? -%>
|
||||
<div><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
|
||||
<% end -%>
|
||||
|
||||
<div><%= f.submit "Sign in" %></div>
|
||||
<% end %>
|
||||
|
||||
<%= render "links" %>
|
12
app/views/devise/unlocks/new.html.erb
Normal file
12
app/views/devise/unlocks/new.html.erb
Normal file
|
@ -0,0 +1,12 @@
|
|||
<h2>Resend unlock instructions</h2>
|
||||
|
||||
<%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %>
|
||||
<%= devise_error_messages! %>
|
||||
|
||||
<div><%= f.label :email %><br />
|
||||
<%= f.email_field :email %></div>
|
||||
|
||||
<div><%= f.submit "Resend unlock instructions" %></div>
|
||||
<% end %>
|
||||
|
||||
<%= render "links" %>
|
|
@ -1,13 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title><%= ENV['TITLE'] || "Photos" %></title>
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<meta name="viewport" content="initial-scale=1.0">
|
||||
<%= yield :head %>
|
||||
<%= stylesheet_link_tag 'application' %>
|
||||
<%= csrf_meta_tag %>
|
||||
<%= render :partial => 'shared/head' %>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
|
@ -43,7 +37,6 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<%= javascript_include_tag 'jquery-1.4.2.js', 'rails', 'balder' %>
|
||||
<%= yield :javascript %>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
29
app/views/layouts/bootstrap.html.erb
Normal file
29
app/views/layouts/bootstrap.html.erb
Normal file
|
@ -0,0 +1,29 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<%= render :partial => 'shared/head' %>
|
||||
</head>
|
||||
<body>
|
||||
<%= render :partial => 'shared/nav_bar' %>
|
||||
<div class="container">
|
||||
<!-- Main hero unit for a primary marketing message or call to action -->
|
||||
<div class="hero-unit">
|
||||
<h1>Hello, world!</h1>
|
||||
<p>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.</p>
|
||||
<p><a class="btn btn-primary btn-large">Learn more »</a></p>
|
||||
</div>
|
||||
<!-- Example row of columns -->
|
||||
<div class="row">
|
||||
<div class="span12">
|
||||
<%= yield %>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<footer>
|
||||
<p>© Company 2012</p>
|
||||
</footer>
|
||||
</div>
|
||||
<!-- /container -->
|
||||
</body>
|
||||
</html>
|
|
@ -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 %><br />
|
||||
<%= form.text_field :title %><br />
|
||||
<br />
|
||||
<br/>
|
||||
<%= form.label :tag_list %><br />
|
||||
<%= form.text_field :tag_list, { :autocomplete => "off", :class => 'tag_list'} %><br />
|
||||
<br />
|
||||
<%= form.text_field :tag_list, {:autocomplete => "off", :class => 'tag_list'} %><br />
|
||||
<br/>
|
||||
<%= form.label :description %><br />
|
||||
<%= form.text_area :description %><br />
|
||||
<br/>
|
||||
<p>On disk: ~/<%= @photo.file.path %></p>
|
||||
<p>On disk: ~/<%= @photo.attachment.path %></p>
|
|
@ -1 +1 @@
|
|||
<%= image_tag photo.file.single.url %><br/>
|
||||
<%= image_tag photo.attachment.single.url %><br/>
|
|
@ -1 +1 @@
|
|||
<%= link_to (image_tag eval('photo.file.' + (defined?(photosize) ? photosize : "album") + '.url') ), [photo.album.collections.first, photo.album, photo] %>
|
||||
<%= link_to (image_tag eval('photo.attachment.' + (defined?(photosize) ? photosize : "album") + '.url')), [photo.album.collections.first, photo.album, photo] %>
|
|
@ -1,17 +1,17 @@
|
|||
<h1>Edit Photo</h1>
|
||||
|
||||
<%= 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] %>
|
||||
<%= 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] },
|
||||
<%= 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 %>
|
|
@ -1,15 +1,15 @@
|
|||
<%= form_for :photos, :url => update_multiple_photos_path, :html => { :method => :put } do |f| %>
|
||||
<% for photo in @photos %>
|
||||
<p>
|
||||
<%= f.fields_for photo, :index => photo.id do |p|%>
|
||||
<%= form_for :photos, :url => update_multiple_photos_path, :html => {:method => :put} do |f| %>
|
||||
<% for photo in @photos %>
|
||||
<p>
|
||||
<%= f.fields_for photo, :index => photo.id do |p| %>
|
||||
<%= p.check_box :_delete %>
|
||||
<%= render :partial => "photos/thumb", :locals => {:photo => photo } %>
|
||||
<%= render :partial => "photos/thumb", :locals => {:photo => photo} %>
|
||||
<%= p.text_field :title %>
|
||||
<%= p.text_field :tags, :value => photo.tag_list %>
|
||||
<% end%>
|
||||
</p>
|
||||
<% end%>
|
||||
<% end %>
|
||||
</p>
|
||||
<% end %>
|
||||
<p><%= f.submit "Submit" %></p>
|
||||
<% end %>
|
||||
|
||||
<br /><%= link_to "Back to #{@album.title}", @album %>
|
||||
<br/><%= link_to "Back to #{@album.title}", @album %>
|
|
@ -1,6 +1,6 @@
|
|||
<ul><%= render :partial => 'photos/thumb',:collection => @photos, :as => :photo %></ul>
|
||||
<ul><%= render :partial => 'photos/thumb', :collection => @photos, :as => :photo %></ul>
|
||||
|
||||
<%= 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 %>
|
|
@ -1,34 +1,34 @@
|
|||
<h2><%= @photo.title%></h2>
|
||||
<h2><%= @photo.title %></h2>
|
||||
|
||||
<div id="fullimage">
|
||||
<div id="navigation">
|
||||
<p class="links">
|
||||
<% unless @previous.nil? %>
|
||||
<%= link_to "Previous", [ @photo.album.collections.first, @photo.album, @previous] %>
|
||||
<%= link_to "Previous", [@photo.album.collections.first, @photo.album, @previous] %>
|
||||
<% unless @next.nil? %>
|
||||
|
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% unless @next.nil? %>
|
||||
<%= link_to "Next", [ @photo.album.collections.first, @photo.album, @next] %>
|
||||
<%= link_to "Next", [@photo.album.collections.first, @photo.album, @next] %>
|
||||
<% end %>
|
||||
</p>
|
||||
</div>
|
||||
<p><%= link_to_if @next, image_tag(@photo.file.single.url ), [ @photo.album.collections.first, @photo.album, @next] %></p>
|
||||
<p><%= link_to_if @next, image_tag(@photo.attachment.single.url), [@photo.album.collections.first, @photo.album, @next] %></p>
|
||||
</div>
|
||||
|
||||
<p><%= @photo.description %></p>
|
||||
<p>Tagged with:
|
||||
<% for tag in @photo.tags.map{|tag|tag.title}.sort %>
|
||||
<%= link_to tag, tag_photos_path(tag) %>
|
||||
<% end %>
|
||||
<% 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 %>
|
|
@ -1,12 +1,12 @@
|
|||
<%= form_for :photos, :url => update_multiple_photos_path, :html => { :method => :put } do |f| %>
|
||||
<% for photo in @photos %>
|
||||
<p>
|
||||
<%= f.fields_for photo do |p|%>
|
||||
<%= render :partial => "photos/thumb", :locals => {:photo => photo } %>
|
||||
<%= form_for :photos, :url => update_multiple_photos_path, :html => {:method => :put} do |f| %>
|
||||
<% for photo in @photos %>
|
||||
<p>
|
||||
<%= 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%>
|
||||
</p>
|
||||
<% end%>
|
||||
<% end %>
|
||||
</p>
|
||||
<% end %>
|
||||
<p><%= f.submit "Submit" %></p>
|
||||
<% end %>
|
|
@ -1,13 +1,7 @@
|
|||
<%= content_for :javascript do %>
|
||||
<style type="text/css">@import url(/javascripts/plupload/js/jquery.plupload.queue/css/jquery.plupload.queue.css);</style>
|
||||
<%= javascript_include_tag "plupload/js/plupload.full.js" -%>
|
||||
<%= javascript_include_tag "plupload/js/jquery.plupload.queue/jquery.plupload.queue.js" -%>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
|
||||
$("#uploader").pluploadQueue({
|
||||
// General settings
|
||||
runtimes:'flash,html5,browserplus,silverlight,gears',
|
||||
url:'<%= photos_path %>',
|
||||
max_file_size:'10mb',
|
||||
|
@ -27,10 +21,10 @@
|
|||
],
|
||||
|
||||
// Flash settings
|
||||
flash_swf_url:'/javascripts/plupload/js/plupload.flash.swf',
|
||||
flash_swf_url:'/assets/plupload.flash.swf',
|
||||
|
||||
// Silverlight settings
|
||||
silverlight_xap_url:'/javascripts/plupload/js/plupload.silverlight.xap',
|
||||
silverlight_xap_url:'/assets/plupload.silverlight.xap',
|
||||
|
||||
// Post init events, bound after the internal events
|
||||
init:{
|
||||
|
@ -76,6 +70,7 @@
|
|||
<p>You browser doesn't have Flash, Silverlight, Gears, BrowserPlus or HTML5 support.</p>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
<div id="thumbs"></div>
|
||||
</form>
|
||||
|
||||
|
|
36
app/views/shared/_head.html.erb
Normal file
36
app/views/shared/_head.html.erb
Normal file
|
@ -0,0 +1,36 @@
|
|||
<meta charset="utf-8">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title><%= ENV['TITLE'] || "Photos" %></title>
|
||||
<%= csrf_meta_tags %>
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
|
||||
<![endif]-->
|
||||
|
||||
<%= stylesheet_link_tag "application", :media => "all" %>
|
||||
<%= javascript_include_tag "application" %>
|
||||
<!-- For third-generation iPad with high-resolution Retina display: -->
|
||||
<!-- Size should be 144 x 144 pixels -->
|
||||
<%= favicon_link_tag 'images/apple-touch-icon-144x144-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '144x144' %>
|
||||
|
||||
<!-- For iPhone with high-resolution Retina display: -->
|
||||
<!-- Size should be 114 x 114 pixels -->
|
||||
<%= favicon_link_tag 'images/apple-touch-icon-114x114-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '114x114' %>
|
||||
|
||||
<!-- For first- and second-generation iPad: -->
|
||||
<!-- Size should be 72 x 72 pixels -->
|
||||
<%= favicon_link_tag 'images/apple-touch-icon-72x72-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '72x72' %>
|
||||
|
||||
<!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: -->
|
||||
<!-- Size should be 57 x 57 pixels -->
|
||||
<%= favicon_link_tag 'images/apple-touch-icon-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png' %>
|
||||
|
||||
<!-- For all other devices -->
|
||||
<!-- Size should be 32 x 32 pixels -->
|
||||
<%= favicon_link_tag 'images/favicon.ico', :rel => 'shortcut icon' %>
|
||||
|
||||
<%= yield :head %>
|
||||
<%= yield :javascript %>
|
25
app/views/shared/_nav_bar.html.erb
Normal file
25
app/views/shared/_nav_bar.html.erb
Normal file
|
@ -0,0 +1,25 @@
|
|||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</a>
|
||||
<a class="brand" href="#">Photomix</a>
|
||||
|
||||
<div class="nav-collapse">
|
||||
<ul class="nav">
|
||||
<li class="active"><a href="#">Home</a></li>
|
||||
<li><a href="#about">About</a></li>
|
||||
<li><a href="#contact">Contact</a></li>
|
||||
</ul>
|
||||
<form action="" class="navbar-search pull-left">
|
||||
<input type="text" placeholder="Search" class="search-query span2">
|
||||
</form>
|
||||
<%= render :partial => 'shared/user_links' %>
|
||||
</div>
|
||||
<!--/.nav-collapse -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
14
app/views/shared/_user_links.html.erb
Normal file
14
app/views/shared/_user_links.html.erb
Normal file
|
@ -0,0 +1,14 @@
|
|||
<% if current_user %>
|
||||
<ul class="nav pull-right">
|
||||
<li><%= link_to current_user.email, account_path %></li>
|
||||
<li class="divider-vertical"></li>
|
||||
<li class="dropdown">
|
||||
<a data-toggle="dropdown" class="dropdown-toggle" href="#">Actions <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><%= link_to 'Logout', logout_path %></li>
|
||||
<li class="divider"></li>
|
||||
<li><%= link_to "New collection", new_collection_path %></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<% end %>
|
|
@ -1,42 +1,40 @@
|
|||
<p>
|
||||
<b>Name:</b>
|
||||
<%=h @user.name %>
|
||||
<%= @user.first_name %>
|
||||
</p>
|
||||
<p>
|
||||
<b>Second Name:</b>
|
||||
<%= @user.second_name %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Email:</b>
|
||||
<%=h @user.email %>
|
||||
<%= @user.email %>
|
||||
</p>
|
||||
|
||||
|
||||
<p>
|
||||
<b>Login count:</b>
|
||||
<%=h @user.login_count %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Last request at:</b>
|
||||
<%=h @user.last_request_at %>
|
||||
<%= @user.sign_in_count %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Last login at:</b>
|
||||
<%=h @user.last_login_at %>
|
||||
<%= @user.last_sign_in_at %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Current login at:</b>
|
||||
<%=h @user.current_login_at %>
|
||||
<%= @user.current_sign_in_at %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Last login ip:</b>
|
||||
<%=h @user.last_login_ip %>
|
||||
<%= @user.last_sign_in_ip %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Current login ip:</b>
|
||||
<%=h @user.current_login_ip %>
|
||||
<%= @user.current_sign_in_ip %>
|
||||
</p>
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# This file is used by Rack-based servers to start the application.
|
||||
|
||||
require ::File.expand_path('../config/environment', __FILE__)
|
||||
run Balder::Application
|
||||
run Photomix::Application
|
||||
|
|
|
@ -6,7 +6,7 @@ require 'rails/all'
|
|||
# you've limited to :test, :development, or :production.
|
||||
Bundler.require(:default, Rails.env) if defined?(Bundler)
|
||||
|
||||
module Balder
|
||||
module Photomix
|
||||
class Application < Rails::Application
|
||||
|
||||
# Custom directories with classes and modules you want to be autoloadable.
|
||||
|
@ -16,6 +16,9 @@ module Balder
|
|||
config.encoding = "utf-8"
|
||||
config.i18n.default_locale = :ru
|
||||
config.time_zone = 'Moscow'
|
||||
config.active_support.escape_html_entities_in_json = true
|
||||
config.assets.enabled = true
|
||||
config.assets.version = '1.0'
|
||||
|
||||
# Configure sensitive parameters which will be filtered from the log file.
|
||||
config.filter_parameters += [:password, :password_confirmation]
|
||||
|
|
55
config/application_config.rb
Normal file
55
config/application_config.rb
Normal file
|
@ -0,0 +1,55 @@
|
|||
configuration = {
|
||||
:app_host => "example.com",
|
||||
:site_name => "PhotoMix",
|
||||
:site_description => "The Best Site!",
|
||||
:support_email => "support@example.com",
|
||||
:meta_description => 'A description of your site for use in META tags.',
|
||||
:meta_keywords => 'keywords for use in META tags',
|
||||
|
||||
:userpic => {
|
||||
:paperclip_options => {
|
||||
:default_url => "http://lorempixel.com/87/86/people/",
|
||||
:styles => {
|
||||
:thumb => "100x100>",
|
||||
:small => "80x80>"
|
||||
},
|
||||
:url => "/system/:class/:attachment/:id/:style/:filename",
|
||||
:path => "public/system/:class/:attachment/:id/:style/:filename"
|
||||
},
|
||||
:validation_options => {
|
||||
:max_size => 1,
|
||||
:content_type => ['image/jpg', 'image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png']
|
||||
}
|
||||
},
|
||||
|
||||
:terms => 'Penatibus pulvinar nisi vel sed placerat tincidunt est scelerisque velit est dictumst.
|
||||
Aenean diam, scelerisque in cum eros? Dignissim phasellus phasellus pellentesque rhoncus risus tempor
|
||||
a ut nunc, sed porta hac porttitor auctor purus risus platea, tempor tortor, mus tincidunt vel magna.
|
||||
Tristique mid purus sit mattis elit, vut nunc turpis elementum scelerisque augue aenean magnis, eros magna placerat.
|
||||
Et urna nascetur, elementum porttitor egestas a amet tincidunt rhoncus porta sit lundium, enim, ut augue tortor
|
||||
ultricies magnis tristique sed egestas urna cum rhoncus penatibus porttitor tortor. Velit scelerisque odio! Adipiscing,
|
||||
dolor habitasse tincidunt dolor lundium, augue integer odio, ut, mauris integer, natoque placerat velit, velit, duis in,
|
||||
enim turpis, cursus magna lundium risus odio dignissim arcu porta urna? Enim.
|
||||
|
||||
Tincidunt proin, ultrices ridiculus! Proin. Placerat et? Ut aenean, parturient porttitor?
|
||||
Duis egestas magnis montes, turpis, cursus, pulvinar diam, parturient placerat sociis turpis.
|
||||
Enim mid? Ultricies mauris sagittis facilisis adipiscing lectus pellentesque porttitor. Vel tincidunt, non ridiculus,
|
||||
in aenean aliquet dictumst pellentesque duis et massa diam tincidunt. Elementum? Odio, pid. Habitasse, urna,
|
||||
nascetur cursus magna facilisis mauris facilisis montes. Adipiscing egestas urna magna dignissim ac, pellentesque
|
||||
lectus. Porta adipiscing amet. Porta placerat montes mus, proin, sit cum vut et, elementum mid ut, dignissim
|
||||
natoque rhoncus urna dolor ridiculus? Egestas, enim pellentesque magna augue placerat eros? Urna dignissim lorem,
|
||||
mattis elementum. Integer porttitor pulvinar. Aenean ridiculus urna scelerisque et et quis purus duis aliquam eu eu
|
||||
nec dictumst, sagittis! Aliquam.
|
||||
|
||||
Ac eu eros! Sed tincidunt, mattis etiam? Odio odio dignissim integer? Ut dictumst porttitor. Lectus turpis turpis
|
||||
in porta. Aenean ut diam mauris augue mattis ultricies est? Habitasse. Turpis? Parturient dictumst ut facilisis sit?
|
||||
Dapibus, dolor odio augue elementum porttitor eu nunc cras hac non dapibus facilisis? Pellentesque nec vut purus
|
||||
dignissim turpis, vut elementum? Ridiculus amet urna vel! Sed, in montes, dignissim rhoncus habitasse, parturient turpis?
|
||||
Natoque turpis sociis tortor, dignissim platea placerat, eu lundium duis amet cursus, tincidunt velit, rhoncus elementum,
|
||||
proin ut mus purus! Mid eros enim eros sed mid penatibus. A, sed sit. A ultrices ac eu! Tortor turpis aliquet odio,
|
||||
pellentesque vut sit dictumst nunc adipiscing. Augue amet aliquam rhoncus enim arcu velit sit.'
|
||||
|
||||
|
||||
}
|
||||
|
||||
configatron.configure_from_hash(configuration)
|
|
@ -6,19 +6,19 @@ development:
|
|||
development_mysql_osx:
|
||||
adapter: mysql2
|
||||
encoding: utf8
|
||||
username: balder
|
||||
username: photomix
|
||||
password: changeme
|
||||
database: balder_development
|
||||
database: photomix_development
|
||||
socket: /tmp/mysql.sock
|
||||
production:
|
||||
adapter: mysql2
|
||||
encoding: utf8
|
||||
username: balder
|
||||
username: photomix
|
||||
password: changeme
|
||||
database: balder_production
|
||||
database: photomix_production
|
||||
socket: /var/run/mysqld/mysqld.sock
|
||||
test: &TEST
|
||||
adapter: postgresql
|
||||
database: gallery_test
|
||||
username: balder
|
||||
username: photomix
|
||||
password: changeme
|
|
@ -2,8 +2,8 @@
|
|||
require File.expand_path('../application', __FILE__)
|
||||
|
||||
# Load app vars from local file
|
||||
balder_env = File.join(Rails.root, 'config', 'balder.rb')
|
||||
load(balder_env) if File.exists?(balder_env)
|
||||
photomix_env = File.join(Rails.root, 'config', 'photomix.rb')
|
||||
load(photomix_env) if File.exists?(photomix_env)
|
||||
|
||||
# Initialize the rails application
|
||||
Balder::Application.initialize!
|
||||
Photomix::Application.initialize!
|
|
@ -1,9 +1,9 @@
|
|||
Balder::Application.configure do
|
||||
# Settings specified here will take precedence over those in config/environment.rb
|
||||
Photomix::Application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb
|
||||
|
||||
# In the development environment your application's code is reloaded on
|
||||
# every request. This slows down response time but is perfect for development
|
||||
# since you don't have to restart the webserver when you make code changes.
|
||||
# since you don't have to restart the web server when you make code changes.
|
||||
config.cache_classes = false
|
||||
|
||||
# Log error messages when you accidentally call methods on nil.
|
||||
|
@ -22,6 +22,19 @@ Balder::Application.configure do
|
|||
# Only use best-standards-support built into browsers
|
||||
config.action_dispatch.best_standards_support = :builtin
|
||||
|
||||
# Raise exception on mass assignment protection for Active Record models
|
||||
config.active_record.mass_assignment_sanitizer = :strict
|
||||
|
||||
# Log the query plan for queries taking more than this (works
|
||||
# with SQLite, MySQL, and PostgreSQL)
|
||||
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
||||
|
||||
# Do not compress assets
|
||||
config.assets.compress = false
|
||||
|
||||
# Expands the lines which load the assets
|
||||
config.assets.debug = true
|
||||
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
|
||||
ENV["RAILS_ASSET_ID"] = ""
|
||||
end
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
Balder::Application.configure do
|
||||
# Settings specified here will take precedence over those in config/environment.rb
|
||||
Photomix::Application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb
|
||||
|
||||
# The production environment is meant for finished, "live" apps.
|
||||
# Code is not reloaded between requests
|
||||
config.cache_classes = true
|
||||
|
||||
|
@ -9,31 +8,46 @@ Balder::Application.configure do
|
|||
config.consider_all_requests_local = false
|
||||
config.action_controller.perform_caching = true
|
||||
|
||||
# Disable Rails's static asset server (Apache or nginx will already do this)
|
||||
config.serve_static_assets = false
|
||||
|
||||
# Compress JavaScripts and CSS
|
||||
config.assets.compress = true
|
||||
|
||||
# Don't fallback to assets pipeline if a precompiled asset is missed
|
||||
config.assets.compile = false
|
||||
|
||||
# Generate digests for assets URLs
|
||||
config.assets.digest = true
|
||||
|
||||
# Defaults to Rails.root.join("public/assets")
|
||||
# config.assets.manifest = YOUR_PATH
|
||||
|
||||
# Specifies the header that your server uses for sending files
|
||||
config.action_dispatch.x_sendfile_header = "X-Sendfile"
|
||||
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
||||
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
||||
|
||||
# For nginx:
|
||||
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
|
||||
|
||||
# If you have no front-end server that supports something like X-Sendfile,
|
||||
# just comment this out and Rails will serve the files
|
||||
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
||||
# config.force_ssl = true
|
||||
|
||||
# See everything in the log (default is :info)
|
||||
# config.log_level = :debug
|
||||
|
||||
# Prepend all log lines with the following tags
|
||||
# config.log_tags = [ :subdomain, :uuid ]
|
||||
|
||||
# Use a different logger for distributed setups
|
||||
# config.logger = SyslogLogger.new
|
||||
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
||||
|
||||
# Use a different cache store in production
|
||||
# config.cache_store = :mem_cache_store
|
||||
|
||||
# Disable Rails's static asset server
|
||||
# In production, Apache or nginx will already do this
|
||||
config.serve_static_assets = false
|
||||
|
||||
# Enable serving of images, stylesheets, and javascripts from an asset server
|
||||
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
||||
# config.action_controller.asset_host = "http://assets.example.com"
|
||||
|
||||
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
||||
config.assets.precompile += %w( front.js front_preloader.js )
|
||||
|
||||
# Disable delivery errors, bad email addresses will be ignored
|
||||
# config.action_mailer.raise_delivery_errors = false
|
||||
|
||||
|
@ -46,4 +60,8 @@ Balder::Application.configure do
|
|||
|
||||
# Send deprecation notices to registered listeners
|
||||
config.active_support.deprecation = :notify
|
||||
|
||||
# Log the query plan for queries taking more than this (works
|
||||
# with SQLite, MySQL, and PostgreSQL)
|
||||
# config.active_record.auto_explain_threshold_in_seconds = 0.5
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Balder::Application.configure do
|
||||
Photomix::Application.configure do
|
||||
# Settings specified here will take precedence over those in config/environment.rb
|
||||
|
||||
# The test environment is used exclusively to run your application's
|
||||
|
|
1
config/initializers/carrier_wave.rb
Normal file
1
config/initializers/carrier_wave.rb
Normal file
|
@ -0,0 +1 @@
|
|||
CarrierWave::SanitizedFile.sanitize_regexp = /[^[:word:]\.\-\+]/
|
2
config/initializers/configatron.rb
Normal file
2
config/initializers/configatron.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
require 'configatron'
|
||||
require Rails.root.join('config','application_config.rb')
|
232
config/initializers/devise.rb
Normal file
232
config/initializers/devise.rb
Normal file
|
@ -0,0 +1,232 @@
|
|||
# Use this hook to configure devise mailer, warden hooks and so forth.
|
||||
# Many of these configuration options can be set straight in your model.
|
||||
Devise.setup do |config|
|
||||
# ==> Mailer Configuration
|
||||
# Configure the e-mail address which will be shown in Devise::Mailer,
|
||||
# note that it will be overwritten if you use your own mailer class with default "from" parameter.
|
||||
config.mailer_sender = "robot@example.com"
|
||||
|
||||
# Configure the class responsible to send e-mails.
|
||||
# config.mailer = "Devise::Mailer"
|
||||
|
||||
# ==> ORM configuration
|
||||
# Load and configure the ORM. Supports :active_record (default) and
|
||||
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
||||
# available as additional gems.
|
||||
require 'devise/orm/active_record'
|
||||
|
||||
# ==> Configuration for any authentication mechanism
|
||||
# Configure which keys are used when authenticating a user. The default is
|
||||
# just :email. You can configure it to use [:username, :subdomain], so for
|
||||
# authenticating a user, both parameters are required. Remember that those
|
||||
# parameters are used only when authenticating and not when retrieving from
|
||||
# session. If you need permissions, you should implement that in a before filter.
|
||||
# You can also supply a hash where the value is a boolean determining whether
|
||||
# or not authentication should be aborted when the value is not present.
|
||||
# config.authentication_keys = [ :email ]
|
||||
|
||||
# Configure parameters from the request object used for authentication. Each entry
|
||||
# given should be a request method and it will automatically be passed to the
|
||||
# find_for_authentication method and considered in your model lookup. For instance,
|
||||
# if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
|
||||
# The same considerations mentioned for authentication_keys also apply to request_keys.
|
||||
# config.request_keys = []
|
||||
|
||||
# Configure which authentication keys should be case-insensitive.
|
||||
# These keys will be downcased upon creating or modifying a user and when used
|
||||
# to authenticate or find a user. Default is :email.
|
||||
config.case_insensitive_keys = [ :email ]
|
||||
|
||||
# Configure which authentication keys should have whitespace stripped.
|
||||
# These keys will have whitespace before and after removed upon creating or
|
||||
# modifying a user and when used to authenticate or find a user. Default is :email.
|
||||
config.strip_whitespace_keys = [ :email ]
|
||||
|
||||
# Tell if authentication through request.params is enabled. True by default.
|
||||
# It can be set to an array that will enable params authentication only for the
|
||||
# given strategies, for example, `config.params_authenticatable = [:database]` will
|
||||
# enable it only for database (email + password) authentication.
|
||||
# config.params_authenticatable = true
|
||||
|
||||
# Tell if authentication through HTTP Basic Auth is enabled. False by default.
|
||||
# It can be set to an array that will enable http authentication only for the
|
||||
# given strategies, for example, `config.http_authenticatable = [:token]` will
|
||||
# enable it only for token authentication.
|
||||
# config.http_authenticatable = false
|
||||
|
||||
# If http headers should be returned for AJAX requests. True by default.
|
||||
# config.http_authenticatable_on_xhr = true
|
||||
|
||||
# The realm used in Http Basic Authentication. "Application" by default.
|
||||
# config.http_authentication_realm = "Application"
|
||||
|
||||
# It will change confirmation, password recovery and other workflows
|
||||
# to behave the same regardless if the e-mail provided was right or wrong.
|
||||
# Does not affect registerable.
|
||||
# config.paranoid = true
|
||||
|
||||
# By default Devise will store the user in session. You can skip storage for
|
||||
# :http_auth and :token_auth by adding those symbols to the array below.
|
||||
# Notice that if you are skipping storage for all authentication paths, you
|
||||
# may want to disable generating routes to Devise's sessions controller by
|
||||
# passing :skip => :sessions to `devise_for` in your config/routes.rb
|
||||
config.skip_session_storage = [:http_auth]
|
||||
|
||||
# ==> Configuration for :database_authenticatable
|
||||
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
|
||||
# using other encryptors, it sets how many times you want the password re-encrypted.
|
||||
#
|
||||
# Limiting the stretches to just one in testing will increase the performance of
|
||||
# your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
|
||||
# a value less than 10 in other environments.
|
||||
config.stretches = Rails.env.test? ? 1 : 10
|
||||
|
||||
# Setup a pepper to generate the encrypted password.
|
||||
# config.pepper = "8464ad45498829424d5220a93af12ced3d7d656e5be3dac9fc15a47a8837c421ee476980a5d030b9c0cd589143e6108a21c5abc912b688a848baa8e1409aaa7d"
|
||||
|
||||
# ==> Configuration for :confirmable
|
||||
# A period that the user is allowed to access the website even without
|
||||
# confirming his account. For instance, if set to 2.days, the user will be
|
||||
# able to access the website for two days without confirming his account,
|
||||
# access will be blocked just in the third day. Default is 0.days, meaning
|
||||
# the user cannot access the website without confirming his account.
|
||||
# config.allow_unconfirmed_access_for = 2.days
|
||||
|
||||
# If true, requires any email changes to be confirmed (exactly the same way as
|
||||
# initial account confirmation) to be applied. Requires additional unconfirmed_email
|
||||
# db field (see migrations). Until confirmed new email is stored in
|
||||
# unconfirmed email column, and copied to email column on successful confirmation.
|
||||
config.reconfirmable = true
|
||||
|
||||
# Defines which key will be used when confirming an account
|
||||
# config.confirmation_keys = [ :email ]
|
||||
|
||||
# ==> Configuration for :rememberable
|
||||
# The time the user will be remembered without asking for credentials again.
|
||||
# config.remember_for = 2.weeks
|
||||
|
||||
# If true, extends the user's remember period when remembered via cookie.
|
||||
# config.extend_remember_period = false
|
||||
|
||||
# Options to be passed to the created cookie. For instance, you can set
|
||||
# :secure => true in order to force SSL only cookies.
|
||||
# config.rememberable_options = {}
|
||||
|
||||
# ==> Configuration for :validatable
|
||||
# Range for password length. Default is 6..128.
|
||||
# config.password_length = 6..128
|
||||
|
||||
# Email regex used to validate email formats. It simply asserts that
|
||||
# an one (and only one) @ exists in the given string. This is mainly
|
||||
# to give user feedback and not to assert the e-mail validity.
|
||||
# config.email_regexp = /\A[^@]+@[^@]+\z/
|
||||
|
||||
# ==> Configuration for :timeoutable
|
||||
# The time you want to timeout the user session without activity. After this
|
||||
# time the user will be asked for credentials again. Default is 30 minutes.
|
||||
# config.timeout_in = 30.minutes
|
||||
|
||||
# If true, expires auth token on session timeout.
|
||||
# config.expire_auth_token_on_timeout = false
|
||||
|
||||
# ==> Configuration for :lockable
|
||||
# Defines which strategy will be used to lock an account.
|
||||
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
|
||||
# :none = No lock strategy. You should handle locking by yourself.
|
||||
# config.lock_strategy = :failed_attempts
|
||||
|
||||
# Defines which key will be used when locking and unlocking an account
|
||||
# config.unlock_keys = [ :email ]
|
||||
|
||||
# Defines which strategy will be used to unlock an account.
|
||||
# :email = Sends an unlock link to the user email
|
||||
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
|
||||
# :both = Enables both strategies
|
||||
# :none = No unlock strategy. You should handle unlocking by yourself.
|
||||
# config.unlock_strategy = :both
|
||||
|
||||
# Number of authentication tries before locking an account if lock_strategy
|
||||
# is failed attempts.
|
||||
# config.maximum_attempts = 20
|
||||
|
||||
# Time interval to unlock the account if :time is enabled as unlock_strategy.
|
||||
# config.unlock_in = 1.hour
|
||||
|
||||
# ==> Configuration for :recoverable
|
||||
#
|
||||
# Defines which key will be used when recovering the password for an account
|
||||
# config.reset_password_keys = [ :email ]
|
||||
|
||||
# Time interval you can reset your password with a reset password key.
|
||||
# Don't put a too small interval or your users won't have the time to
|
||||
# change their passwords.
|
||||
config.reset_password_within = 6.hours
|
||||
|
||||
# ==> Configuration for :encryptable
|
||||
# Allow you to use another encryption algorithm besides bcrypt (default). You can use
|
||||
# :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
|
||||
# :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
|
||||
# and :restful_authentication_sha1 (then you should set stretches to 10, and copy
|
||||
# REST_AUTH_SITE_KEY to pepper)
|
||||
# config.encryptor = :sha512
|
||||
|
||||
# ==> Configuration for :token_authenticatable
|
||||
# Defines name of the authentication token params key
|
||||
# config.token_authentication_key = :auth_token
|
||||
|
||||
# ==> Scopes configuration
|
||||
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
||||
# "users/sessions/new". It's turned off by default because it's slower if you
|
||||
# are using only default views.
|
||||
# config.scoped_views = false
|
||||
|
||||
# Configure the default scope given to Warden. By default it's the first
|
||||
# devise role declared in your routes (usually :user).
|
||||
# config.default_scope = :user
|
||||
|
||||
# Set this configuration to false if you want /users/sign_out to sign out
|
||||
# only the current scope. By default, Devise signs out all scopes.
|
||||
# config.sign_out_all_scopes = true
|
||||
|
||||
# ==> Navigation configuration
|
||||
# Lists the formats that should be treated as navigational. Formats like
|
||||
# :html, should redirect to the sign in page when the user does not have
|
||||
# access, but formats like :xml or :json, should return 401.
|
||||
#
|
||||
# If you have any extra navigational formats, like :iphone or :mobile, you
|
||||
# should add them to the navigational formats lists.
|
||||
#
|
||||
# The "*/*" below is required to match Internet Explorer requests.
|
||||
# config.navigational_formats = ["*/*", :html]
|
||||
|
||||
# The default HTTP method used to sign out a resource. Default is :delete.
|
||||
config.sign_out_via = :delete
|
||||
|
||||
# ==> OmniAuth
|
||||
# Add a new OmniAuth provider. Check the wiki for more information on setting
|
||||
# up on your models and hooks.
|
||||
# config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
|
||||
|
||||
# ==> Warden configuration
|
||||
# If you want to use other strategies, that are not supported by Devise, or
|
||||
# change the failure app, you can configure them inside the config.warden block.
|
||||
#
|
||||
# config.warden do |manager|
|
||||
# manager.intercept_401 = false
|
||||
# manager.default_strategies(:scope => :user).unshift :some_external_strategy
|
||||
# end
|
||||
|
||||
# ==> Mountable engine configurations
|
||||
# When using Devise inside an engine, let's call it `MyEngine`, and this engine
|
||||
# is mountable, there are some extra configurations to be taken into account.
|
||||
# The following options are available, assuming the engine is mounted as:
|
||||
#
|
||||
# mount MyEngine, at: "/my_engine"
|
||||
#
|
||||
# The router that invoked `devise_for`, in the example above, would be:
|
||||
# config.router_name = :my_engine
|
||||
#
|
||||
# When using omniauth, Devise cannot automatically set Omniauth path,
|
||||
# so you need to do it manually. For the users scope, it would be:
|
||||
# config.omniauth_path_prefix = "/my_engine/users/auth"
|
||||
end
|
1
config/initializers/hack.rb
Normal file
1
config/initializers/hack.rb
Normal file
|
@ -0,0 +1 @@
|
|||
LIKE = ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' ? 'ILIKE' : 'LIKE'
|
|
@ -8,3 +8,8 @@
|
|||
# inflect.irregular 'person', 'people'
|
||||
# inflect.uncountable %w( fish sheep )
|
||||
# end
|
||||
#
|
||||
# These inflection rules are supported but not enabled by default:
|
||||
# ActiveSupport::Inflector.inflections do |inflect|
|
||||
# inflect.acronym 'RESTful'
|
||||
# end
|
||||
|
|
|
@ -2,4 +2,5 @@
|
|||
|
||||
# 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
|
||||
Mime::Type.register "image/svg+xml", :svg
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
# If you change this key, all old signed cookies will become invalid!
|
||||
# Make sure the secret is at least 30 characters and all random,
|
||||
# no regular words or you'll be exposed to dictionary attacks.
|
||||
Balder::Application.config.secret_token = '23aabccbfd8e48ab8b96104ba699a1603e6bad13a125317be3ed9963c18cd24b9afa725d218688202f3752fd693cc8358f522c0f18c42a5a0b8ce3c84a8b89a2'
|
||||
Photomix::Application.config.secret_token = '23aabccbfd8e48ab8b96104ba699a1603e6bad13a125317be3ed9963c18cd24b9afa725d218688202f3752fd693cc8358f522c0f18c42a5a0b8ce3c84a8b89a2'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
Balder::Application.config.session_store :cookie_store, :key => '_balder_session'
|
||||
Photomix::Application.config.session_store :cookie_store, :key => '_photomix_session'
|
||||
|
||||
Rails.application.config.middleware.insert_before(
|
||||
Rails.application.config.session_store,
|
||||
|
@ -11,4 +11,4 @@ Rails.application.config.middleware.insert_before(
|
|||
# Use the database for sessions instead of the cookie-based default,
|
||||
# which shouldn't be used to store highly confidential information
|
||||
# (create the session table with "rake db:sessions:create")
|
||||
# Balder::Application.config.session_store :active_record_store
|
||||
# Photomix::Application.config.session_store :active_record_store
|
||||
|
|
58
config/locales/devise.en.yml
Normal file
58
config/locales/devise.en.yml
Normal file
|
@ -0,0 +1,58 @@
|
|||
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
|
||||
|
||||
en:
|
||||
errors:
|
||||
messages:
|
||||
expired: "has expired, please request a new one"
|
||||
not_found: "not found"
|
||||
already_confirmed: "was already confirmed, please try signing in"
|
||||
not_locked: "was not locked"
|
||||
not_saved:
|
||||
one: "1 error prohibited this %{resource} from being saved:"
|
||||
other: "%{count} errors prohibited this %{resource} from being saved:"
|
||||
|
||||
devise:
|
||||
failure:
|
||||
already_authenticated: 'You are already signed in.'
|
||||
unauthenticated: 'You need to sign in or sign up before continuing.'
|
||||
unconfirmed: 'You have to confirm your account before continuing.'
|
||||
locked: 'Your account is locked.'
|
||||
invalid: 'Invalid email or password.'
|
||||
invalid_token: 'Invalid authentication token.'
|
||||
timeout: 'Your session expired, please sign in again to continue.'
|
||||
inactive: 'Your account was not activated yet.'
|
||||
sessions:
|
||||
signed_in: 'Signed in successfully.'
|
||||
signed_out: 'Signed out successfully.'
|
||||
passwords:
|
||||
send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
|
||||
updated: 'Your password was changed successfully. You are now signed in.'
|
||||
updated_not_active: 'Your password was changed successfully.'
|
||||
send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
|
||||
no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
|
||||
confirmations:
|
||||
send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
|
||||
send_paranoid_instructions: 'If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes.'
|
||||
confirmed: 'Your account was successfully confirmed. You are now signed in.'
|
||||
registrations:
|
||||
signed_up: 'Welcome! You have signed up successfully.'
|
||||
signed_up_but_unconfirmed: 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.'
|
||||
signed_up_but_inactive: 'You have signed up successfully. However, we could not sign you in because your account is not yet activated.'
|
||||
signed_up_but_locked: 'You have signed up successfully. However, we could not sign you in because your account is locked.'
|
||||
updated: 'You updated your account successfully.'
|
||||
update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address."
|
||||
destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
|
||||
unlocks:
|
||||
send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
|
||||
unlocked: 'Your account has been unlocked successfully. Please sign in to continue.'
|
||||
send_paranoid_instructions: 'If your account exists, you will receive an email with instructions about how to unlock it in a few minutes.'
|
||||
omniauth_callbacks:
|
||||
success: 'Successfully authenticated from %{kind} account.'
|
||||
failure: 'Could not authenticate you from %{kind} because "%{reason}".'
|
||||
mailer:
|
||||
confirmation_instructions:
|
||||
subject: 'Confirmation instructions'
|
||||
reset_password_instructions:
|
||||
subject: 'Reset password instructions'
|
||||
unlock_instructions:
|
||||
subject: 'Unlock Instructions'
|
|
@ -1,8 +1,17 @@
|
|||
Balder::Application.routes.draw do
|
||||
Photomix::Application.routes.draw do
|
||||
mount DeviseOmniauthEngine::Engine => "/", :as => "devise_omniauth"
|
||||
|
||||
devise_scope :user do
|
||||
get '/login' => 'devise/sessions#new', :as => :login
|
||||
get '/signup' => 'devise/registrations#new', :as => :signup
|
||||
get '/logout' => 'devise/sessions#destroy', :as => :logout
|
||||
resource :account, :controller => :users, :as => :user_root
|
||||
end
|
||||
|
||||
devise_for :users, :controllers => {:omniauth_callbacks => "users/omniauth_callbacks"},
|
||||
:path_names => {:sign_out => 'logout'}
|
||||
|
||||
resource :account, :controller => :users
|
||||
match "login", :to => "user_sessions#new", :as => :login
|
||||
match "authenticate", :to => "user_sessions#create", :as => :authenticate
|
||||
match "logout", :to => "user_sessions#destroy", :as => :logout
|
||||
|
||||
resources :photos do
|
||||
collection do
|
||||
|
@ -51,7 +60,7 @@ Balder::Application.routes.draw do
|
|||
resources :albums
|
||||
end
|
||||
|
||||
resources :users, :controller => "admin/users"
|
||||
match '/locale' => "locale#set"
|
||||
|
||||
root :to => "collections#index"
|
||||
|
||||
|
|
15
config/yettings/devise_omniauth_engine.yml
Normal file
15
config/yettings/devise_omniauth_engine.yml
Normal file
|
@ -0,0 +1,15 @@
|
|||
development:
|
||||
twitter_key: Uaqi5HXJlxVPKrQD0Rytw
|
||||
twitter_secret: RCxKqgsjqNxmjd2YDLEjOn6emhMOjwy3yWPvLO06i0
|
||||
facebook_key: 237456219689843
|
||||
facebook_secret: ffec0c5a132bb83473084c31a6bd27ed
|
||||
vkontakte_key: 2951707
|
||||
vkontakte_secret: CWOzbZrfFagKmtdMb1ZC
|
||||
|
||||
production:
|
||||
twitter_key: LY7PGBLsvSF0Z4rK30a9cA
|
||||
twitter_secret: PvyYVDQRysLGy8Vvvj6RcFewdLmpdmnvUzKm6IqrBY
|
||||
facebook_key: 310467435688958
|
||||
facebook_secret: a95127a3842bc45a82199e3eceb9b837
|
||||
vkontakte_key: 2936461
|
||||
vkontakte_secret: xx2ZqujGSztHH09NYKbU
|
|
@ -1,7 +1,7 @@
|
|||
class CreatePhotos < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :photos do |t|
|
||||
t.string :title, :length => 250, :null => false
|
||||
t.string :title, :length => 250
|
||||
t.text :description
|
||||
t.references :album
|
||||
t.timestamps
|
||||
|
|
|
@ -1,26 +1,53 @@
|
|||
class CreateUsers < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :users do |t|
|
||||
t.string :email, :null => false # optional, you can use login instead, or both
|
||||
t.string :crypted_password, :null => false # optional, see below
|
||||
t.string :password_salt, :null => false # optional, but highly recommended
|
||||
t.string :persistence_token, :null => false # required
|
||||
t.string :single_access_token, :null => false # optional, see Authlogic::Session::Params
|
||||
t.string :perishable_token, :null => false # optional, see Authlogic::Session::Perishability
|
||||
def change
|
||||
create_table(:users) do |t|
|
||||
## Database authenticatable
|
||||
t.string :email, :null => false, :default => ""
|
||||
t.string :encrypted_password, :null => false, :default => ""
|
||||
|
||||
## Recoverable
|
||||
t.string :reset_password_token
|
||||
t.datetime :reset_password_sent_at
|
||||
|
||||
## Rememberable
|
||||
t.datetime :remember_created_at
|
||||
|
||||
## Trackable
|
||||
t.integer :sign_in_count, :default => 0
|
||||
t.datetime :current_sign_in_at
|
||||
t.datetime :last_sign_in_at
|
||||
t.string :current_sign_in_ip
|
||||
t.string :last_sign_in_ip
|
||||
|
||||
## Encryptable
|
||||
t.string :password_salt
|
||||
|
||||
# Confirmable
|
||||
t.string :confirmation_token
|
||||
t.datetime :confirmed_at
|
||||
t.datetime :confirmation_sent_at
|
||||
t.string :unconfirmed_email # Only if using reconfirmable
|
||||
|
||||
# Lockable
|
||||
t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
|
||||
t.string :unlock_token # Only if unlock strategy is :email or :both
|
||||
t.datetime :locked_at
|
||||
|
||||
# Token authenticatable
|
||||
t.string :authentication_token
|
||||
|
||||
t.string :first_name
|
||||
t.string :second_name
|
||||
t.string :surname
|
||||
t.string :userpic
|
||||
|
||||
# Magic columns, just like ActiveRecord's created_at and updated_at. These are automatically maintained by Authlogic if they are present.
|
||||
t.integer :login_count, :null => false, :default => 0 # optional, see Authlogic::Session::MagicColumns
|
||||
t.integer :failed_login_count, :null => false, :default => 0 # optional, see Authlogic::Session::MagicColumns
|
||||
t.datetime :last_request_at # optional, see Authlogic::Session::MagicColumns
|
||||
t.datetime :current_login_at # optional, see Authlogic::Session::MagicColumns
|
||||
t.datetime :last_login_at # optional, see Authlogic::Session::MagicColumns
|
||||
t.string :current_login_ip # optional, see Authlogic::Session::MagicColumns
|
||||
t.string :last_login_ip # optional, see Authlogic::Session::MagicColumns
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :users
|
||||
add_index User.table_name, :email, :unique => true
|
||||
add_index User.table_name, :reset_password_token, :unique => true
|
||||
add_index User.table_name, :confirmation_token, :unique => true
|
||||
add_index User.table_name, :unlock_token, :unique => true
|
||||
add_index User.table_name, :authentication_token, :unique => true
|
||||
end
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
class AddNameToUser < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_column :users, :name, :string
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :users, :name
|
||||
end
|
||||
end
|
|
@ -1,16 +0,0 @@
|
|||
class CreatePermissions < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table "permissions", :force => true do |t|
|
||||
t.integer :permissible_id
|
||||
t.string :permissible_type
|
||||
t.string :action
|
||||
t.boolean :granted
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table "permissions"
|
||||
end
|
||||
end
|
|
@ -1,15 +0,0 @@
|
|||
class CreateRoleMemberships < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :role_memberships do |t|
|
||||
t.integer :roleable_id
|
||||
t.string :roleable_type
|
||||
t.integer :role_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :role_memberships
|
||||
end
|
||||
end
|
|
@ -1,13 +1,18 @@
|
|||
class CreateRoles < ActiveRecord::Migration
|
||||
def self.up
|
||||
def change
|
||||
create_table :roles do |t|
|
||||
t.string :name
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
create_table :roles_users, :id => false, :force => true do |t|
|
||||
t.references :role
|
||||
t.references :user
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :roles
|
||||
add_index :roles_users, :role_id, :name => 'index_roles_users_on_role_id'
|
||||
add_index :roles_users, :user_id, :name => 'index_roles_users_on_user_id'
|
||||
end
|
||||
|
||||
end
|
|
@ -1,9 +1,9 @@
|
|||
class AddFileToPhoto < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_column :photos, :file, :string
|
||||
add_column :photos, :attachment, :string
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :photos, :file
|
||||
remove_column :photos, :attachment
|
||||
end
|
||||
end
|
||||
|
|
72
db/schema.rb
72
db/schema.rb
|
@ -46,15 +46,6 @@ ActiveRecord::Schema.define(:version => 20100412220801) do
|
|||
|
||||
add_index "collections", ["id"], :name => "index_collections_on_id", :unique => true
|
||||
|
||||
create_table "permissions", :force => true do |t|
|
||||
t.integer "permissible_id"
|
||||
t.string "permissible_type"
|
||||
t.string "action"
|
||||
t.boolean "granted"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "photo_tags", :force => true do |t|
|
||||
t.integer "tag_id"
|
||||
t.integer "photo_id"
|
||||
|
@ -66,7 +57,7 @@ ActiveRecord::Schema.define(:version => 20100412220801) do
|
|||
add_index "photo_tags", ["tag_id"], :name => "index_photo_tags_on_tag_id"
|
||||
|
||||
create_table "photos", :force => true do |t|
|
||||
t.string "title", :null => false
|
||||
t.string "title"
|
||||
t.text "description"
|
||||
t.integer "album_id"
|
||||
t.datetime "created_at", :null => false
|
||||
|
@ -74,26 +65,26 @@ ActiveRecord::Schema.define(:version => 20100412220801) do
|
|||
t.text "path"
|
||||
t.float "longitude"
|
||||
t.float "latitude"
|
||||
t.string "file"
|
||||
t.string "attachment"
|
||||
end
|
||||
|
||||
add_index "photos", ["album_id"], :name => "index_photos_on_album_id"
|
||||
add_index "photos", ["id"], :name => "index_photos_on_id", :unique => true
|
||||
|
||||
create_table "role_memberships", :force => true do |t|
|
||||
t.integer "roleable_id"
|
||||
t.string "roleable_type"
|
||||
t.integer "role_id"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "roles", :force => true do |t|
|
||||
t.string "name"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "roles_users", :id => false, :force => true do |t|
|
||||
t.integer "role_id"
|
||||
t.integer "user_id"
|
||||
end
|
||||
|
||||
add_index "roles_users", ["role_id"], :name => "index_roles_users_on_role_id"
|
||||
add_index "roles_users", ["user_id"], :name => "index_roles_users_on_user_id"
|
||||
|
||||
create_table "tags", :force => true do |t|
|
||||
t.string "title", :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
|
@ -103,22 +94,37 @@ ActiveRecord::Schema.define(:version => 20100412220801) do
|
|||
add_index "tags", ["id"], :name => "index_tags_on_id", :unique => true
|
||||
|
||||
create_table "users", :force => true do |t|
|
||||
t.string "email", :null => false
|
||||
t.string "crypted_password", :null => false
|
||||
t.string "password_salt", :null => false
|
||||
t.string "persistence_token", :null => false
|
||||
t.string "single_access_token", :null => false
|
||||
t.string "perishable_token", :null => false
|
||||
t.integer "login_count", :default => 0, :null => false
|
||||
t.integer "failed_login_count", :default => 0, :null => false
|
||||
t.datetime "last_request_at"
|
||||
t.datetime "current_login_at"
|
||||
t.datetime "last_login_at"
|
||||
t.string "current_login_ip"
|
||||
t.string "last_login_ip"
|
||||
t.string "email", :default => "", :null => false
|
||||
t.string "encrypted_password", :default => "", :null => false
|
||||
t.string "reset_password_token"
|
||||
t.datetime "reset_password_sent_at"
|
||||
t.datetime "remember_created_at"
|
||||
t.integer "sign_in_count", :default => 0
|
||||
t.datetime "current_sign_in_at"
|
||||
t.datetime "last_sign_in_at"
|
||||
t.string "current_sign_in_ip"
|
||||
t.string "last_sign_in_ip"
|
||||
t.string "password_salt"
|
||||
t.string "confirmation_token"
|
||||
t.datetime "confirmed_at"
|
||||
t.datetime "confirmation_sent_at"
|
||||
t.string "unconfirmed_email"
|
||||
t.integer "failed_attempts", :default => 0
|
||||
t.string "unlock_token"
|
||||
t.datetime "locked_at"
|
||||
t.string "authentication_token"
|
||||
t.string "first_name"
|
||||
t.string "second_name"
|
||||
t.string "surname"
|
||||
t.string "userpic"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "name"
|
||||
end
|
||||
|
||||
add_index "users", ["authentication_token"], :name => "index_users_on_authentication_token", :unique => true
|
||||
add_index "users", ["confirmation_token"], :name => "index_users_on_confirmation_token", :unique => true
|
||||
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
|
||||
add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
|
||||
add_index "users", ["unlock_token"], :name => "index_users_on_unlock_token", :unique => true
|
||||
|
||||
end
|
||||
|
|
29
db/seeds.rb
29
db/seeds.rb
|
@ -1,7 +1,22 @@
|
|||
# This file should contain all the record creation needed to seed the database with its default values.
|
||||
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
|
||||
# Mayor.create(:name => 'Daley', :city => cities.first)
|
||||
#coding: utf-8
|
||||
require_relative "../test/blueprints"
|
||||
require 'fileutils'
|
||||
|
||||
@user_role = Role.make! name: 'user'
|
||||
|
||||
FileUtils.rm_rf "#{Rails.root}/public/uploads"
|
||||
FileUtils.mkdir_p "#{Rails.root}/tmp/attachments"
|
||||
|
||||
user = User.make! email: 'test@example.com', password: 'password', password_confirmation: 'password',
|
||||
first_name: 'Username', second_name: 'Secondname', surname: 'Surname', confirmed_at: Time.now,
|
||||
confirmation_sent_at: (Time.now+3)
|
||||
|
||||
user.roles << Role.make!(name: 'admin')
|
||||
|
||||
20.times.map { User.make! }
|
||||
20.times.map { Collection.make! }
|
||||
20.times.map { Album.make! }
|
||||
20.times.map { Photo.make! }
|
||||
10.times.map { CollectionAlbum.make! }
|
||||
|
||||
FileUtils.rm_rf "#{Rails.root}/tmp/attachments"
|
||||
|
|
|
@ -1,106 +0,0 @@
|
|||
# ActsAsPermissible
|
||||
module NoamBenAri
|
||||
module Acts #:nodoc:
|
||||
module Permissible #:nodoc:
|
||||
|
||||
def self.included(base)
|
||||
base.extend ClassMethods
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
def acts_as_permissible
|
||||
has_many :permissions, :as => :permissible, :dependent => :destroy
|
||||
|
||||
has_many :role_memberships, :as => :roleable, :dependent => :destroy
|
||||
has_many :roles, :through => :role_memberships, :source => :role
|
||||
|
||||
include NoamBenAri::Acts::Permissible::InstanceMethods
|
||||
extend NoamBenAri::Acts::Permissible::SingletonMethods
|
||||
|
||||
alias_method :full_permissions_hash, :permissions_hash
|
||||
end
|
||||
end
|
||||
|
||||
# This module contains class methods
|
||||
module SingletonMethods
|
||||
|
||||
# Helper method to lookup for permissions for a given object.
|
||||
# This method is equivalent to obj.permissions.
|
||||
def find_permissions_for(obj)
|
||||
permissible = ActiveRecord::Base.send(:class_name_of_active_record_descendant, self).to_s
|
||||
|
||||
Permission.find(:all,
|
||||
:conditions => ["permissible_id = ? and permissible_type = ?", obj.id, permissible]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
# This module contains instance methods
|
||||
module InstanceMethods
|
||||
|
||||
# returns permissions in hash form
|
||||
# from all levels recursively
|
||||
def permissions_hash
|
||||
@permissions_hash ||= lambda do
|
||||
@permissions_hash = permissions.inject({}) { |hsh,perm| hsh.merge(perm.to_hash) }.symbolize_keys!
|
||||
roles.each do |role|
|
||||
merge_permissions!(role.permissions_hash)
|
||||
end
|
||||
@permissions_hash
|
||||
end.call()
|
||||
end
|
||||
|
||||
# accepts a permission identifier string or an array of permission identifier strings
|
||||
# and return true if the user has all of the permissions given by the parameters
|
||||
# false if not.
|
||||
def has_permission?(*perms)
|
||||
perms.all? {|perm| permissions_hash.include?(perm.to_sym) && (permissions_hash[perm.to_sym] == true) }
|
||||
end
|
||||
|
||||
# accepts a permission identifier string or an array of permission identifier strings
|
||||
# and return true if the user has any of the permissions given by the parameters
|
||||
# false if none.
|
||||
def has_any_permission?(*perms)
|
||||
perms.any? {|perm| permissions_hash.include?(perm.to_sym) && (permissions_hash[perm.to_sym] == true) }
|
||||
end
|
||||
|
||||
# Merges another permissible object's permissions into this permissible's permissions hash
|
||||
# In the case of identical keys, a false value wins over a true value.
|
||||
def merge_permissions!(other_permissions_hash)
|
||||
permissions_hash.merge!(other_permissions_hash) {|key,oldval,newval| oldval.nil? ? newval : oldval && newval}
|
||||
end
|
||||
|
||||
# Resets permissions and then loads them.
|
||||
def reload_permissions!
|
||||
reset_permissions!
|
||||
permissions_hash
|
||||
end
|
||||
|
||||
def roles_list
|
||||
list = []
|
||||
roles.inject(list) do |list,role|
|
||||
list << role.name
|
||||
role.roles_list.inject(list) {|list,role| list << role}
|
||||
end
|
||||
list.uniq
|
||||
end
|
||||
|
||||
def in_role?(*role_names)
|
||||
role_names.all? {|role| roles_list.include?(role) }
|
||||
end
|
||||
|
||||
def in_any_role?(*role_names)
|
||||
role_names.any? {|role| roles_list.include?(role) }
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
# Nilifies permissions_hash instance variable.
|
||||
def reset_permissions!
|
||||
@permissions_hash = nil
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
13
lib/ext/group_for.rb
Normal file
13
lib/ext/group_for.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
module Ext
|
||||
module GroupFor
|
||||
def self.extended(base)
|
||||
if (ActiveRecord::Base.connection.adapter_name == 'PostgreSQL')
|
||||
if base.table_exists?
|
||||
base.scope :group_for, {:group => base.column_names.map { |col_name| "#{base.table_name}.#{col_name}" }}
|
||||
end
|
||||
else
|
||||
base.scope :group_for, {:group => "#{base.quoted_table_name}.id"}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -46,7 +46,7 @@ module ScanFiles
|
|||
end
|
||||
|
||||
def self.RecreateThumbnails
|
||||
Photo.find(:all).each {|photo|
|
||||
Photo.all.each {|photo|
|
||||
photo.file.recreate_versions!
|
||||
}
|
||||
end
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue