working on fixing issues with devise (wip)

This commit is contained in:
did 2011-11-04 16:55:51 +01:00
parent 8979957d43
commit 87d2440f14
50 changed files with 13972 additions and 162 deletions

View File

@ -6,7 +6,9 @@ gem 'rake', '0.9.2'
gem 'rails', '~> 3.1.1'
gem 'devise', '~> 1.4.9'
gem 'devise', :path => '../gems/devise' # FIXME: git clone git@github.com:locomotivecms/devise.git; git checkout scoped_mailer
# gem 'devise', '~> 1.4.9'
gem 'cancan', '~> 1.6.7'
gem 'bson', '~> 1.3.1'

View File

@ -27,6 +27,14 @@ PATH
carrierwave-mongoid (~> 0.1.3)
mongoid (~> 2.3.2)
PATH
remote: ../gems/devise
specs:
devise (1.5.0.dev)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.0.3)
warden (~> 1.0.3)
GEM
remote: http://rubygems.org/
specs:
@ -119,10 +127,6 @@ GEM
delayed_job_mongoid (1.0.4)
delayed_job (~> 2.1.1)
mongoid (>= 2.0)
devise (1.4.9)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.0.3)
warden (~> 1.0.3)
diff-lcs (1.1.3)
dragonfly (0.9.8)
rack
@ -334,7 +338,7 @@ DEPENDENCIES
database_cleaner
delayed_job (~> 2.1.1)
delayed_job_mongoid (~> 1.0.4)
devise (~> 1.4.9)
devise!
dragonfly (~> 0.9.8)
factory_girl_rails (~> 1.1)
fog (~> 1.0.0)

View File

@ -7,6 +7,8 @@
#panel {
.inner {
padding: 5px 20px 20px 20px;
a {
color: #1F82BC;
@include hover-link;
@ -43,23 +45,12 @@
} // li.question
li {
div.inline-errors {
background: transparent image-url("locomotive/form/error-arrow.png") no-repeat 17px 0;
margin: 2px 0 0 0;
padding: 8px 0 0 0;
input {
&[type=text] { width: 302px; }
p {
display: inline-block;
width: auto;
margin: 0px;
padding: 3px 12px 4px 30px;
color: #fff !important;
text-shadow: #000 0px 1px;
font-size: 11px;
padding-left: 30px;
background: #cd0f19 image-url("locomotive/form/icons/error.png") no-repeat 10px 6px;
}
&[type=password] { width: 180px; }
}
} // li
} // ol
} // fieldset

View File

@ -2,7 +2,6 @@
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
* the top of the compiled file, but it's generally better to create a new file per style scope.
*= require ./locomotive/blueprint/screen.css
*= require ./locomotive/box.css
*= require ./locomotive/installation.css
*= require ./blueprint/screen.css
*= require ./simple.css
*/

View File

@ -10,7 +10,7 @@ div.application-message {
font-size: 1.2em;
font-weight: bold;
padding: 8px;
margin: 10px 20px 0 20px;
margin: 10px 0px 0 0px;
text-align: justify;
}
@ -36,11 +36,10 @@ div#flash-notice {
}
#panel {
width: 356px;
height: 344px;
padding: 0px 0px 0 0px;
width: 346px;
padding: 0px;
@include box-shadow(rgba(0, 0, 0, 0.2) 0px 0px 10px 3px);
@include box-shadow(rgba(0, 0, 0, 0.6) 0px 0px 7px 1px);
h1 {
height: 41px;
@ -60,7 +59,7 @@ div#flash-notice {
.inner {
background: #fff;
padding: 5px 20px 20px 20px;
padding: 5px 40px 20px 40px;
fieldset {
border: 0px;
@ -83,7 +82,6 @@ div#flash-notice {
} // label
input {
// background: white url(/assets/locomotive/box/input_bg.png) no-repeat 0 0;
padding: 7px;
border: 1px solid #b5b7c4;
@ -92,13 +90,7 @@ div#flash-notice {
font-size: 14px;
color: #222;
&[type=text] {
width: 302px;
}
&[type=password] {
width: 180px;
}
&[type=text], &[type=password] { width: 248px; }
&[type=file] {
background: none;
@ -107,13 +99,23 @@ div#flash-notice {
} // input
div.inline-errors {
background: transparent image-url("locomotive/form/error-arrow.png") no-repeat 17px 0;
margin: 2px 0 0 0;
padding: 8px 0 0 0;
div.inline-errors p {
padding: 3px 5px;
margin: 5px 0px;
background: #FFE5E5;
color: #CE2525;
} // inline-errors p
p {
display: inline-block;
width: auto;
margin: 0px;
padding: 3px 12px 4px 30px;
color: #fff !important;
text-shadow: #000 0px 1px;
font-size: 11px;
padding-left: 30px;
background: #cd0f19 image-url("locomotive/form/icons/error.png") no-repeat 10px 6px;
}
} // div.inline-errors
} // li
} // ol
@ -127,7 +129,7 @@ div#flash-notice {
} // p.notice
p.link {
margin: 15px 0 0 49px;
margin: 15px 0 0 0px;
a {
color: #1f82bc;
@ -148,7 +150,7 @@ div#flash-notice {
.footer {
margin: 0px 0px 0 0px;
padding: 22px 0;
padding: 15px 0;
background: #8b8d9a;
@include border-bottom-radius(3px);

View File

@ -0,0 +1,116 @@
@mixin clearfix {
&:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
};
}
/* ___ rounded ___ */
@mixin rounded($side, $radius: 10px, $important: false) {
@if $important == true {
$important: !important; }
@else {
$important: ""; }
border-#{$side}-radius: $radius unquote($important);
-moz-border-radius-#{$side}: $radius unquote($important);
-webkit-border-#{$side}-radius: $radius unquote($important);
}
@mixin border-rounded($vert, $horz, $radius, $important: false) {
@if $important == true {
$important: !important; }
@else {
$important: ""; }
border-#{$vert}-#{$horz}-radius: $radius unquote($important);
-moz-border-radius-#{$vert}#{$horz}: $radius unquote($important);
-webkit-border-#{$vert}-#{$horz}-radius: $radius unquote($important);
}
@mixin full-rounded($radius: 10px) {
border-radius: $radius;
-moz-border-radius: $radius;
-webkit-border-radius: $radius;
}
/* ___ box shadow ___ */
@mixin box-shadow($hoffset, $voffset, $depth, $color) {
box-shadow: $hoffset $voffset $depth $color;
-moz-box-shadow: $hoffset $voffset $depth $color;
-webkit-box-shadow: $hoffset $voffset $depth $color;
}
@mixin box-shadow-with-inset($color_top, $color_bottom: $color_top, $important: false) {
$color_bottom: $color_top !default;
@if $important == true {
$important: " !important"; }
@else {
$important: ""; }
box-shadow: inset 0 1px 0 0 $color_top, 0 1px 0 0 $color_bottom unquote($important);
-moz-box-shadow: inset 0 1px 0 0 $color_top, 0 1px 0 0 $color_bottom unquote($important);
-webkit-box-shadow: inset 0 1px 0 0 $color_top, 0 1px 0 0 $color_bottom unquote($important);
}
@mixin no-box-shadow($important: false) {
@if $important == true {
$important: " !important"; }
@else {
$important: ""; }
box-shadow: none $important;
-moz-box-shadow: none $important;
-webkit-box-shadow: none $important;
}
@mixin popup-box {
@include full-rounded(4px);
box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.17), 3px 3px 5px 0 rgba(0, 0, 0, 0.41);
-moz-box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.17), 3px 3px 5px 0 rgba(0, 0, 0, 0.41);
-webkit-box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.17), 3px 3px 5px 0 rgba(0, 0, 0, 0.41);
}
/* ___ others ___ */
@mixin reset {
padding: 0px;
margin: 0px;
list-style: none;
a {
text-decoration: none;
}
}
@mixin absolute-position($vside, $vvalue, $hside, $hvalue, $display: block) {
display: $display;
position: absolute;
#{$vside}: $vvalue;
#{$hside}: $hvalue;
}
@mixin linear-background-gradient($from, $to) {
background: mix($from, $to);
background: -moz-linear-gradient(0% 100% 90deg, $to, $from);
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from($from), to($to));
}
@mixin icon($where, $width, $height, $enabled: false, $top: 0, $left: 0) {
position: relative;
width: $width;
height: $height;
line-height: $height + 1;
@if $enabled == true {
background-position: -#{$width} $where; }
@else {
background-position: 0 $where; }
top: $top;
left: $left;
}

View File

@ -0,0 +1,126 @@
/* ___ AUTOMATICALLY GENERATED: see admin/button.scss for the source file */
@import "helpers";
.button {
display: inline-block;
background: transparent url(/assets/locomotive//buttons/dark-gray-left.png) no-repeat 0 0;
padding: 0px 0px 0px 2px;
font-size: 0.9em;
color: white;
cursor: pointer;
border: none;
height: 31px;
outline: none;
span {
display: inline-block;
background: transparent url(/assets/locomotive//buttons/dark-gray-right.png) no-repeat right top;
position: relative;
top: -1px;
padding: 3px 9px 9px 4px;
line-height: 21px;
text-shadow: 1px 1px 1px #000;
outline: none;
}
&.light {
background-image: url(/assets/locomotive//buttons/light-gray-left.png);
color: #787a89;
span {
background-image: url(/assets/locomotive//buttons/light-gray-right.png);
text-shadow: 1px 1px 1px #fff;
}
}
&.small {
background: #ebedf4;
outline: none;
-moz-border-radius : 10px;
-webkit-border-radius: 10px;
height: 20px;
font-size: 0.7em;
padding: 0px 12px 0px 12px;
color: #8B8D9A !important;
text-decoration: none;
text-shadow: 1px 1px 1px #fff;
}
&.mini.add {
background: transparent;
height: 20px;
@include linear-background-gradient(#ebedf4, #d7dbe7);
@include full-rounded(4px);
@include box-shadow(1px, 1px, 1px, rgba(0, 0, 0, 0.4));
span {
background: none;
line-height: 10px;
padding: 0px 5px 0 0;
}
}
&.remove {
color: #ff092c !important;
font-size: 1.1em;
&:hover { text-decoration: underline; }
}
}
// .button {
// display: inline-block;
// background: transparent url(/assets/locomotive//buttons/dark-gray-left.png) no-repeat 0 0;
// padding: 0px 0px 0px 2px;
// font-size: 0.9em;
// color: white;
// cursor: pointer;
// border: none;
// height: 31px;
// outline: none;
// }
//
// .button span {
// display: inline-block;
// background: transparent url(/assets/locomotive//buttons/dark-gray-right.png) no-repeat right top;
// position: relative;
// top: -1px;
// padding: 3px 9px 9px 4px;
// line-height: 21px;
// text-shadow: 1px 1px 1px #000;
// outline: none;
// }
//
// .button.light {
// background-image: url(/assets/locomotive//buttons/light-gray-left.png);
// color: #787a89;
// }
//
// .button.light span {
// background-image: url(/assets/locomotive//buttons/light-gray-right.png);
// text-shadow: 1px 1px 1px #fff;
// }
//
// .button.small {
// background: #ebedf4;
// outline: none;
// -moz-border-radius : 10px;
// -webkit-border-radius: 10px;
// height: 20px;
// font-size: 0.7em;
// padding: 0px 12px 0px 12px;
// color: #8B8D9A !important;
// text-decoration: none;
// text-shadow: 1px 1px 1px #fff;
// }
//
// .button.small.add {
// }
//
// .button.remove {
// color: #ff092c !important;
// font-size: 1.1em;
// }
//
// .button.remove:hover { text-decoration: underline; }

View File

@ -0,0 +1,455 @@
/* ___ AUTOMATICALLY GENERATED: see admin/menu.scss for the source file */
@import "helpers";
/* ___ submenu: bg ___*/
#submenu {
clear: both;
position: relative;
top: -1px;
z-index: 998;
height: 60px;
margin: 0px;
padding: 0 8px;
background: transparent url(/assets/locomotive//menu/shadow.png) repeat-y 0 0;
/* ___ submenu items ___ */
& > ul {
@include reset;
border-top: 1px solid rgba(255, 255, 255, 0.4);
background: transparent url(/assets/locomotive//menu/submenu/shadow.png) repeat-x 0 0;
@include rounded(top-right, 3px);
height: 60px;
& > li {
margin: 15px 7px 0 8px;
float: left;
&.hoverable > a span {
em {
display: inline-block;
background: transparent url(/assets/locomotive//menu/icons.png) no-repeat 0 -16px;
width: 12px;
height: 7px;
position: relative;
top: 0px;
left: 6px;
}
}
& > a {
display: inline-block;
@include full-rounded(16px);
@include box-shadow-with-inset(rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1));
border: 1px solid rgba(0, 0, 0, 0.4);
border-top: 1px solid rgba(0, 0, 0, 0.3);
padding: 0px 16px 0px 16px;
height: 26px;
line-height: 22px;
outline: none;
span {
color: #fff;
font-size: 0.8em;
font-weight: normal;
text-shadow: 1px 1px 1px #000;
}
&:hover {
border: 1px solid rgba(0, 0, 0, 0.9);
border-top: 1px solid rgba(0, 0, 0, 0.8);
}
&.on, &:active {
border: 1px solid rgba(0, 0, 0, 0.2);
border-top: 1px solid rgba(0, 0, 0, 0.4);
border-bottom: 1px solid transparent !important;
@include box-shadow-with-inset(rgba(0, 0, 0, 0), rgba(255, 255, 255, 0.2), true);
}
&.hover {
background: #fff !important;
border-color: transparent !important;
border-color-bottom: #fff;
padding-bottom: 0px;
@include border-rounded(bottom, left, 0px, true);
@include border-rounded(bottom, right, 0px, true);
position: relative;
z-index: 998;
span {
color: #8b8d9a;
text-shadow: none;
@include no-box-shadow(true);
}
span em {
background-position: -12px -16px;
}
& > em {
@include absolute-position(bottom, 0px, right, -11px);
width: 13px;
height: 13px;
background: transparent url(/assets/locomotive//menu/popup/bottom-right-corner.png) no-repeat 0 0;
}
}
}
}
}
/* ___ submenu: actions ___ */
& > .action {
@include absolute-position(top, 0px, right, 22px);
height: 60px;
padding-left: 20px;
z-index: 1;
background: transparent url(/assets/locomotive//menu/submenu/action-border.png) repeat-y left 0;
a {
margin-top: 18px;
display: inline-block;
background: rgba(0, 0, 0, 0.4);
@include full-rounded(16px);
padding: 0px 10px 0 15px;
height: 22px;
line-height: 20px;
text-decoration: none;
border: 1px solid transparent;
outline: none;
em {
display: inline-block;
position: relative;
background: transparent url(/assets/locomotive//menu/icons.png) no-repeat 0 0px;
height: 11px;
width: 11px;
top: 1px;
left: -5px;
}
span {
position: relative;
top: -2px;
color: #fff;
font-size: 0.7em;
text-shadow: 1px 1px 1px #000;
}
&:hover {
border-color: rgba(0, 0, 0, 1);
}
}
}
/* ___ submenu: popup ___ */
.popup {
position: absolute;
top: 42px;
min-width: 250px;
background: #fff;
@include box-shadow(0px, 0px, 10px, rgba(0, 0, 0, 0.5));
@include full-rounded(16px);
@include border-rounded(top, left, 0px);
z-index: 997;
a {
color: #1f82bc;
text-decoration: none;
&:hover { text-decoration: underline; }
}
.header {
border-bottom: 1px dotted #bbbbbd;
padding-bottom: 6px;
margin: 0px 16px;
}
.inner { padding: 8px 16px; }
h2 {
font-size: 0.7em;
font-weight: bold;
color: #1e1f26;
margin-bottom: 0px;
}
p {
margin: 0px;
padding: 10px 0 0 0px;
a {
font-size: 0.8em;
background: transparent url(/assets/locomotive//menu/popup/add.png) no-repeat left 4px;
padding-left: 12px;
}
&.edit {
padding-top: 0px;
a {
background: transparent url(/assets/locomotive//menu/popup/bullet.png) no-repeat left 5px;
}
}
}
ul {
list-style-image: url(/assets/locomotive//menu/popup/bullet.png);
margin: 0px 0px 0 15px;
li {
position: relative;
a { font-size: 0.7em; }
span {
@include absolute-position(top, 6px, right, 15px, inline);
color: #8b8d9a;
font-size: 0.7em;
}
}
&.big-links {
list-style: none;
margin: 0px;
li {
margin: 10px 0;
a {
@include full-rounded(16px);
padding: 3px 10px;
background: #ebedf4;
font-weight: bold;
font-size: 0.8em;
}
}
}
}
.footer {
background: #ebedf4;
padding: 8px 16px;
@include rounded("bottom-left", 16px);
@include rounded("bottom-right", 16px);
a {
color: #8b8d9a;
font-weight: bold;
}
}
}
}
@mixin black-submenu {
& > ul {
background: #23242b url(/assets/locomotive//menu/submenu/black-bg.png) repeat-x 0 0;
border-color: rgba(255, 255, 255, 0.2);
& > li > a {
border: 1px solid rgba(0, 0, 0, 0.2);
border-top: 1px solid rgba(0, 0, 0, 0.1);
border-bottom: 1px solid rgba(0, 0, 0, 0.6);
@include box-shadow-with-inset(rgba(255, 255, 255, 0.1));
@include linear-background-gradient(#303138, #1e1e24);
&.on, &:active {
border: 1px solid rgba(0, 0, 0, 0.4);
border-top: 1px solid rgba(0, 0, 0, 0.6);
@include linear-background-gradient(#1e1e24, #212229);
}
}
}
& > .action {
background-image: url(/assets/locomotive//menu/submenu/black-action-border.png) !important;
}
}
@mixin green-submenu {
& > ul {
background-color: #2e9a7d;
& > li > a {
@include linear-background-gradient(#258c70, #13604b);
&.on, &:active {
@include linear-background-gradient(#195e4b, #166d55);
}
}
}
}
@mixin blue-submenu {
& > ul {
background-color: #2579ae;
& > li > a {
@include linear-background-gradient(#1f6ea1, #135179);
&.on, &:active {
@include linear-background-gradient(#13496c, #175b88);
}
}
}
}
@mixin orange-submenu {
& > ul {
background-color: #ed8102;
& > li > a {
@include linear-background-gradient(#e07a02, #a25804);
&.on, &:active {
@include linear-background-gradient(#965201, #9d5603);
}
}
}
}
@mixin red-submenu {
& > ul {
background-color: #d23c45;
& > li > a {
@include linear-background-gradient(#b63e45, #89272d);
&.on, &:active {
@include linear-background-gradient(#7b292e, #972e35);
}
}
}
}
@mixin submenu-color($color) {
@if $color == black { @include black-submenu; }
@if $color == green { @include green-submenu; }
@if $color == blue { @include blue-submenu; }
@if $color == orange { @include orange-submenu; }
@if $color == red { @include red-submenu; }
}
/* ___ menu ___ */
#menu {
@include reset;
margin: 20px 0 0 0px;
li.item {
float: left;
position: relative;
z-index: 994;
& > span, a {
float: left;
display: block;
}
& > span {
background: transparent url(/assets/locomotive//menu/left.png) no-repeat 0 0;
width: 40px;
height: 39px;
background-position: 0 -39px;
}
&.first > span {
width: 18px;
background-position: 0 0;
}
a {
background: transparent url(/assets/locomotive//menu/right.png) no-repeat right 0px;
padding: 0px 52px 0 2px;
height: 39px;
line-height: 26px;
outline: none;
em, span { display: inline-block; position: relative; }
em {
background: transparent url(/assets/locomotive//menu/icons.png) no-repeat 0px 0px;
}
span {
top: 9px;
left: 6px;
color: #787A89;
text-shadow: #C5CFD1 1px 1px 1px;
font-size: 0.8em;
}
}
@for $i from 2 through 5 {
&.item-#{$i} { left: -35px * ($i - 1); z-index: 993 - $i; }
}
}
}
@mixin menu-color($color) {
$color-index: 1;
@if $color == green { $color-index: 1; }
@if $color == black { $color-index: 2; }
@if $color == blue { $color-index: 3; }
@if $color == orange { $color-index: 4; }
@if $color == red { $color-index: 5; }
z-index: 999;
a {
background-position: right -39px * $color-index;
span {
color: #fff;
text-shadow: none;
}
}
& > span { background-position: -40px * $color-index -39px; }
&.first > span { background-position: -18px * $color-index 0px; }
}
@mixin menu-contents-icon($enabled: false) {
@include icon(-64px, 16px, 12px, $enabled, 10px);
}
@mixin menu-assets-icon($enabled: false) {
@include icon(-48px, 20px, 16px, $enabled, 11px);
}
@mixin menu-settings-icon($enabled: false) {
@include icon(-32px, 14px, 13px, $enabled, 11px);
}
/* ___ section/color/icon associations ___ */
#menu li.contents a em { @include menu-contents-icon; }
body.contents {
$color: black;
#menu li.contents {
@include menu-color($color);
em { @include menu-contents-icon(true); }
}
#submenu { @include submenu-color($color); }
}
#menu li.assets a em { @include menu-assets-icon; }
body.assets {
$color: green;
#menu li.assets {
@include menu-color($color);
em { @include menu-assets-icon(true); }
}
#submenu { @include submenu-color($color); }
}
#menu li.settings a em { @include menu-settings-icon; }
body.settings {
$color: blue;
#menu li.settings {
@include menu-color($color);
em { @include menu-settings-icon(true); }
}
#submenu { @include submenu-color($color); }
}

View File

@ -0,0 +1,82 @@
/* ___ AUTOMATICALLY GENERATED: see admin/sites_picker.scss for the source file */
@import "helpers";
#sites-picker {
position: absolute;
top: 97px;
padding: 0px 0 0 0;
@include popup-box;
border: 1px solid #000;
background: rgba(50, 51, 59, 1);
min-width: 160px;
z-index: 999;
font-size: 12px;
p {
margin-bottom: 0px;
padding: 0 8px;
&, a {
color: #fff;
text-shadow: #000 0px 1px;
}
a {
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
&.action {
margin-top: 0px;
padding: 2px 8px 4px 8px;
text-align: right;
font-size: 11px;
}
}
ul {
@include reset;
margin: 1px 0 0 0;
li {
color: #aaa;
text-shadow: #000 0px 1px;
background: transparent url(/assets/locomotive//plugins/sites_picker_entry_bg.png) repeat-x 0 bottom;
padding: 2px 8px 6px 8px;
cursor: pointer;
a {
text-decoration: none;
color: #aaa;
}
&:hover {
&, a { color: #fff; }
}
}
}
&:before {
content: " ";
display: block;
width: 21px;
height: 13px;
position: absolute;
top: -11px;
right: 20px;
background: transparent url(/assets/locomotive//plugins/sites_picker_top_arrow.png) no-repeat 0 0;
}
}

View File

@ -1,9 +1,9 @@
class Locomotive::GlobalActionsCell < ::Locomotive::MenuCell
attr_reader :current_account, :current_site_url
attr_reader :current_locomotive_account, :current_site_url
def show(args)
@current_account = args[:current_account]
@current_locomotive_account = args[:current_locomotive_account]
@current_site_url = args[:current_site_url]
super
end
@ -14,12 +14,12 @@ class Locomotive::GlobalActionsCell < ::Locomotive::MenuCell
add :welcome, :url => edit_my_account_url, :i18n_options => {
:key => 'locomotive.shared.header.welcome',
:arg => :name,
:value => @current_account.name
:value => @current_locomotive_account.name
}
add :see, :url => current_site_url, :id => 'viewsite', :target => '_blank'
if Locomotive.config.multi_sites? && current_account.sites.size > 1
if Locomotive.config.multi_sites? && current_locomotive_account.sites.size > 1
add :switch, :url => '#', :id => 'sites-picker-link'
end

View File

@ -46,16 +46,16 @@ module Locomotive
protected
def set_current_thread_variables
Thread.current[:account] = current_account
Thread.current[:account] = current_locomotive_account
Thread.current[:site] = current_site
end
def current_ability
@current_ability ||= Ability.new(current_account, current_site)
@current_ability ||= Ability.new(current_locomotive_account, current_site)
end
def require_account
authenticate_account!
authenticate_locomotive_account!
end
def begin_of_association_chain
@ -79,7 +79,7 @@ module Locomotive
end
def set_locale
I18n.locale = current_account.locale rescue Locomotive.config.default_locale
I18n.locale = current_locomotive_account.locale rescue Locomotive.config.default_locale
end
# ___ site/page urls builder ___

View File

@ -1,7 +1,7 @@
module Locomotive
class CrossDomainSessionsController < BaseController
layout '/locomotive/layouts/box'
layout '/locomotive/layouts/not_logged_in'
skip_before_filter :verify_authenticity_token
@ -12,14 +12,14 @@ module Locomotive
skip_load_and_authorize_resource
def new
if site = current_account.sites.detect { |s| s._id.to_s == params[:target_id] }
if site = current_locomotive_account.sites.detect { |s| s._id.to_s == params[:target_id] }
if Rails.env == 'development'
@target = site.full_subdomain
else
@target = site.domains_without_subdomain.first || site.full_subdomain
end
current_account.reset_switch_site_token!
current_locomotive_account.reset_switch_site_token!
else
redirect_to admin_pages_path
end

View File

@ -1,22 +1,12 @@
module Locomotive
class InstallationController < BaseController
class InstallationController < ::ApplicationController
layout '/locomotive/layouts/box'
skip_before_filter :require_site
skip_before_filter :require_account
skip_before_filter :verify_authenticity_token
skip_before_filter :validate_site_membership
layout '/locomotive/layouts/not_logged_in'
before_filter :is_step_already_done?
before_filter :allow_installation?
skip_load_and_authorize_resource
def show
request.get? ? self.handle_get : self.handle_post
end

View File

@ -16,7 +16,7 @@ module Locomotive
protected
def resource
@account = current_account
@account = current_locomotive_account
end
def begin_of_association_chain; nil; end # not related directly to current_site

View File

@ -3,11 +3,16 @@ module Locomotive
include Locomotive::Routing::SiteDispatcher
layout '/locomotive/layouts/box'
layout '/locomotive/layouts/not_logged_in'
before_filter :require_site
helper 'locomotive/base', 'locomotive/box'
helper 'locomotive/base'
def edit
logger.debug 'I am here'
super
end
end
end

View File

@ -3,11 +3,11 @@ module Locomotive
include Locomotive::Routing::SiteDispatcher
layout '/locomotive/layouts/box'
layout '/locomotive/layouts/not_logged_in'
before_filter :require_site
helper 'locomotive/base', 'locomotive/box'
helper 'locomotive/base'
protected

View File

@ -7,13 +7,13 @@ module Locomotive
def create
@site = Site.new(params[:site])
@site.memberships.build :account => @current_account, :role => 'admin'
@site.memberships.build :account => @current_locomotive_account, :role => 'admin'
create! { edit_my_account_url }
end
def destroy
@site = current_account.sites.find(params[:id])
@site = current_locomotive_account.sites.find(params[:id])
if @site != current_site
@site.destroy

View File

@ -1,7 +1,7 @@
module Locomotive::AccountsHelper
def admin_on?(site = current_site)
site.memberships.detect { |m| m.admin? && m.account == current_account }
site.memberships.detect { |m| m.admin? && m.account == current_locomotive_account }
end
end

View File

@ -9,7 +9,7 @@ module Locomotive::BaseHelper
end
end
def admin_content_menu_item(name, url, options = {}, &block)
def admin_content_menu_item(name, url, options = {}, &block) # TODO: rename method name (remove admin)
default_options = { :i18n => true, :css => name.dasherize.downcase }
default_options.merge!(options)
@ -54,6 +54,19 @@ module Locomotive::BaseHelper
end
end
def flash_message
if not flash.empty?
puts "flash = #{flash.inspect}"
first_key = flash.keys.first
content_tag :div, flash[first_key],
:id => "flash-#{first_key}",
:class => 'application-message'
else
puts "empty :-("
''
end
end
def nocoffee_tag
link_to 'noCoffee', 'http://www.nocoffee.fr', :id => 'nocoffee'
end

View File

@ -1,21 +0,0 @@
module Locomotive::BoxHelper
def box_flash_message
if not flash.empty?
content_tag :div, flash.values.first,
:id => "flash-#{flash.keys.first}",
:class => 'application-message'
else
''
end
end
# def box_button_tag(label)
# content_tag(:button, content_tag(:span, label), :type => 'submit', :class => 'button')
# end
# def next_installation_step_link(step = 1, label = nil)
# link_to(content_tag(:span, label || t('locomotive.installation.common.next')), installation_step_url(step), :class => 'button')
# end
end

View File

@ -79,7 +79,7 @@ module Locomotive::ContentTypesHelper
registers = {
:controller => self,
:site => current_site,
:current_account => current_account
:current_locomotive_account => current_locomotive_account
}
preserve(content._parent.item_template.render(::Liquid::Context.new({}, assigns, registers)))

View File

@ -0,0 +1,8 @@
module Locomotive
class DeviseMailer < ::Devise::Mailer
include ::Locomotive::Engine.routes.url_helpers
end
end

View File

@ -2,7 +2,7 @@
= form_tag cross_domain_sessions_url(:host => @target, :port => request.port), :method => 'post' do
= hidden_field_tag 'token', current_account.switch_site_token
= hidden_field_tag 'token', current_locomotive_account.switch_site_token
.inner
%p.notice= t('.notice')

View File

@ -0,0 +1,12 @@
%p
!= t('locomotive.mailer.common.hello')
= @resource.email
\!
%p
!= t('.reset_password_instruction')
%p
= link_to t('.change_my_password'), edit_password_url(@resource, :reset_password_token => @resource.reset_password_token)
%p
!= t('.wrong_request_instruction')
%p
!= t('.unchange_password_message')

View File

@ -1,6 +1,9 @@
- content_for :head_title do
= t('locomotive.installation.common.title')
- content_for :head do
= stylesheet_link_tag 'locomotive_installation', :media => 'screen'
- title t('.title')
- if @step_done.blank?

View File

@ -1,6 +1,9 @@
- content_for :head_title do
= t('locomotive.installation.common.title')
- content_for :head do
= stylesheet_link_tag 'locomotive/installation', :media => 'screen'
- title t('.title')
= semantic_form_for(@site, :url => installation_step_url(2), :html => { :multipart => true }) do |f|

View File

@ -5,13 +5,13 @@
%title= yield(:head_title) || escape_once("#{Locomotive.config.name} &mdash; #{current_site.name}")
= javascript_include_tag 'locomotive/jquery.js'
= stylesheet_link_tag 'locomotive_installation', :media => 'screen'
/ [if IE]
= stylesheet_link_tag 'locomotive/blueprint/ie', :media => 'screen'
= stylesheet_link_tag 'locomotive/not_logged_in', :media => 'screen'
= yield :head
/ [if IE]
= stylesheet_link_tag 'locomotive/blueprint/ie', :media => 'screen'
%body{ :class => controller.controller_name }
#wrapper
#light.container

View File

@ -1,12 +1,12 @@
%p
!= t('locomotive.mailer.common.hello')
= @resource.email
\!
%p
!= t('.reset_password_instruction')
%p
= link_to t('.change_my_password'), edit_password_url(@resource, :reset_password_token => @resource.reset_password_token)
%p
!= t('.wrong_request_instruction')
%p
!= t('.unchange_password_message')
/ %p
/ != t('locomotive.mailer.common.hello')
/ = @resource.email
/ \!
/ %p
/ != t('.reset_password_instruction')
/ %p
/ = link_to t('.change_my_password'), edit_password_url(@resource, :reset_password_token => @resource.reset_password_token)
/ %p
/ != t('.wrong_request_instruction')
/ %p
/ != t('.unchange_password_message')

View File

@ -5,14 +5,14 @@
= f.hidden_field :reset_password_token
.inner
= box_flash_message
= flash_message
= f.inputs do
= f.input :password, :label => t('.password'), :required => false
= f.input :password_confirmation, :label => t('.password_confirmation'), :required => false
%p.link
= link_to preserve(t('.link')), new_admin_session_path
= link_to preserve(t('.link')), new_locomotive_account_session_path
.footer
= box_button_tag t('locomotive.buttons.change_password')
= submit_tag t('locomotive.buttons.change_password')

View File

@ -1,17 +1,17 @@
- title t('.title')
= semantic_form_for(resource, :as => resource_name, :url => password_path(resource_name)) do |f|
= semantic_form_for(resource, :as => resource_name, :url => locomotive_account_password_path) do |f|
= f.hidden_field :reset_password_token
.inner
= box_flash_message
= flash_message
= f.inputs do
= f.input :email, :label => t('.email'), :required => false
%p.link
= link_to preserve(t('.link')), new_admin_session_path
= link_to preserve(t('.link')), new_locomotive_account_session_path
.footer
= box_button_tag t('locomotive.buttons.send_password')
= submit_tag t('locomotive.buttons.send_password')

View File

@ -1,17 +1,17 @@
- title t('.title')
= semantic_form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f|
= semantic_form_for(resource, :as => resource_name, :url => locomotive_account_session_path) do |f|
= f.hidden_field :remember_me, :value => 'true'
.inner
= box_flash_message
= flash_message
= f.inputs do
= f.input :email, :label => t('.email'), :required => false
= f.input :password, :label => t('.password'), :required => false
%p.link
= link_to t('.link'), new_locomotive_password_path
= link_to t('.link'), new_locomotive_account_password_path
.footer
= box_button_tag t('locomotive.buttons.login')
= submit_tag t('locomotive.buttons.login')

View File

@ -1,12 +1,12 @@
%h1
= link_to current_site.name, pages_url, :class => 'single'
= render_cell 'admin/global_actions', :show, :current_account => current_account, :current_site_url => current_site_url
= render_cell 'admin/global_actions', :show, :current_locomotive_account => current_locomotive_account, :current_site_url => current_site_url
- if multi_sites? && current_account.sites.size > 1
- if multi_sites? && current_locomotive_account.sites.size > 1
#sites-picker{ :style => 'display: none' }
%ul
- current_account.sites.each do |site|
- current_locomotive_account.sites.each do |site|
- unless current_site._id == site._id
%li
= link_to site.name, new_cross_domain_session_url(:target_id => site._id)

View File

@ -1,3 +1,14 @@
Devise.mailer[:locomotive_account] = 'Locomotive::DeviseMailer'
# require 'devise'
#
# puts "overidding Devise::Mailer"
#
# # The devise mailer has also to know about the urls built in the engine
# class Devise::Mailer < ::ActionMailer::Base
# include Locomotive::Engine.routes.url_helpers
# end
# require 'locomotive'
#
# # Use this hook to configure devise mailer, warden hooks and so forth. The first

View File

@ -7,7 +7,7 @@ en:
devise:
failure:
locomotive:
locomotive_account:
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.'
@ -17,34 +17,34 @@ en:
timeout: 'Your session expired, please sign in again to continue.'
inactive: 'Your account was not activated yet.'
sessions:
locomotive:
locomotive_account:
signed_in: 'Signed in successfully.'
signed_out: 'Signed out successfully.'
passwords:
locomotive:
locomotive_account:
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.'
confirmations:
locomotive:
locomotive_account:
send_instructions: '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:
locomotive:
locomotive_account:
signed_up: 'You have signed up successfully.'
updated: 'You updated your account successfully.'
destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
unlocks:
locomotive:
locomotive_account:
send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
unlocked: 'Your account was successfully unlocked. You are now signed in.'
mailer:
locomotive:
locomotive_account:
confirmation_instructions: 'Confirmation instructions'
reset_password_instructions: 'Reset password instructions'
unlock_instructions: 'Unlock Instructions'
locomotive:
locomotive_account:
mailer:
common:
hello: Hello

View File

@ -9,12 +9,16 @@ Locomotive::Engine.routes.draw do
# end
# locomotive authentication
devise_for :account, :class_name => 'Locomotive::Account', :controllers => { :sessions => 'locomotive/sessions', :passwords => 'locomotive/passwords' } do
match '/' => 'sessions#new'
match '/sign_in' => 'sessions#new'
devise_for :locomotive_account,
:mailer => 'Locomotive::DeviseMailer',
:class_name => 'Locomotive::Account',
:path => '',
:path_prefix => nil,
:controllers => { :sessions => 'locomotive/sessions', :passwords => 'locomotive/passwords' } do
match '/' => 'sessions#new'
end
# root :to => 'sessions#new'
root :to => 'pages#index'
resources :pages do
put :sort, :on => :member

View File

@ -4,6 +4,7 @@ require 'locomotive/version'
require 'locomotive/core_ext'
require 'locomotive/configuration'
require 'locomotive/logger'
require 'locomotive/devise'
require 'locomotive/dragonfly'
require 'locomotive/liquid'
require 'locomotive/mongoid'

View File

@ -22,7 +22,7 @@ module Locomotive
:metastore => URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/meta"), # URI encoded in case of spaces
:entitystore => URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/body")
},
:devise_modules => [:database_authenticatable, :recoverable, :rememberable, :trackable, :validatable, :encryptable, { :encryptor => :sha1 }],
:devise_modules => [:rememberable, :database_authenticatable, :recoverable, :trackable, :validatable, :encryptable, { :encryptor => :sha1 }],
:context_assign_extensions => { }
}

32
lib/locomotive/devise.rb Normal file
View File

@ -0,0 +1,32 @@
# require 'devise/mailers/helpers'
# puts Devise.warden_config.inspect
# monkey patch to let Devise know about custom Locomotive mailer views
# module Devise
# module Mailers
# module Helpers
#
# included do
# include Devise::Controllers::ScopedViews
# include Locomotive::Engine.routes.url_helpers
# attr_reader :scope_name, :resource
# end
#
# def template_paths_with_locomotive
# template_path = self.template_paths_without_locomotive
#
# if self.class.scoped_views?
# scoped_path = @devise_mapping.scoped_path
# scoped_path = 'locomotive' if scoped_path =~ /^locomotive_/
# template_path.unshift "#{scoped_path}/mailer"
# end
#
# template_path
# end
#
# alias_method_chain :template_paths, :locomotive
# end
# end
# end

View File

@ -4,9 +4,9 @@ module Liquid
class InlineEditor < ::Liquid::Tag
def render(context)
if context.registers[:current_account]
if context.registers[:current_locomotive_account]
output = %{
<meta name="locale" content="#{context.registers[:current_account].locale}" />
<meta name="locale" content="#{context.registers[:current_locomotive_account].locale}" />
<meta name="page-fullpath" content="/#{context.registers[:page].fullpath}" />
<meta name="edit-page-url" content="#{context.registers[:controller].send(:edit_page_url, context.registers[:page])}" />
}

View File

@ -41,13 +41,13 @@ module Locomotive
end
if page = current_site.pages.any_in(:fullpath => [*path]).first
if not page.published? and current_account.nil?
if not page.published? and current_locomotive_account.nil?
page = nil
else
if page.templatized?
@content_instance = page.content_type.contents.where(:_slug => File.basename(path.first)).first
if @content_instance.nil? || (!@content_instance.visible? && current_account.nil?) # content instance not found or not visible
if @content_instance.nil? || (!@content_instance.visible? && current_locomotive_account.nil?) # content instance not found or not visible
page = nil
end
end
@ -84,7 +84,7 @@ module Locomotive
:site => current_site,
:page => @page,
:inline_editor => self.editing_page?,
:current_account => current_account
:current_locomotive_account => current_locomotive_account
}
::Liquid::Context.new({}, assigns, registers)

View File

@ -43,9 +43,9 @@ module Locomotive
end
def validate_site_membership
return true if current_site.present? && current_site.accounts.include?(current_account)
return true if current_site.present? && current_site.accounts.include?(current_locomotive_account)
sign_out(current_account)
sign_out(current_locomotive_account)
flash[:alert] = I18n.t(:no_membership, :scope => [:devise, :failure, :locomotive])
redirect_to new_session_url and return false
end

View File

@ -28,7 +28,7 @@ module ActionDispatch
[sid, unpack(session.data)]
end
def set_session(env, sid, session_data)
def set_session(env, sid, session_data, options)
record = env[SESSION_RECORD_KEY] ||= find_session(sid)
record.data = pack(session_data)
# Rack spec dictates that set_session should return true or false

View File

@ -4,7 +4,7 @@ describe Admin::GlobalActionsCell do
render_views
let(:menu) { render_cell('admin/global_actions', :show, :current_account => FactoryGirl.build('admin user'), :current_site_url => 'http://www.yahoo.fr') }
let(:menu) { render_cell('admin/global_actions', :show, :current_locomotive_account => FactoryGirl.build('admin user'), :current_site_url => 'http://www.yahoo.fr') }
describe 'show menu' do

View File

@ -0,0 +1,8 @@
class FooController < ApplicationController
def index
render :text => 'Foo'
end
end

View File

@ -6,7 +6,7 @@ Devise.setup do |config|
config.mailer_sender = 'sender@dummyapp.org'
# Configure the class responsible to send e-mails.
# config.mailer = "Devise::Mailer"
# config.mailer = "Locomotive::DeviseMailer"
# ==> ORM configuration
# Load and configure the ORM. Supports :active_record (default) and
@ -155,7 +155,7 @@ Devise.setup do |config|
# Configure the default scope given to Warden. By default it's the first
# devise role declared in your routes (usually :user).
config.default_scope = :account
# config.default_scope = :account
# Configure sign_out behavior.
# Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).

View File

@ -1,5 +1,7 @@
Rails.application.routes.draw do
mount Locomotive::Engine => '/foo'
mount Locomotive::Engine => '/locomotive'
match '/foo' => 'foo#index', :as => 'foo'
end

File diff suppressed because it is too large Load Diff

View File

@ -161,7 +161,7 @@ describe 'Locomotive rendering system' do
before(:each) do
@page.published = false
@controller.current_account = nil
@controller.current_locomotive_account = nil
end
it 'should return the 404 page if the page has not been published yet' do
@ -173,7 +173,7 @@ describe 'Locomotive rendering system' do
end
it 'should not return the 404 page if the page has not been published yet and admin is logged in' do
@controller.current_account = true
@controller.current_locomotive_account = true
@controller.request.fullpath = '/contact'
@controller.current_site.pages.expects(:any_in).with({ :fullpath => %w{contact content_type_template} }).returns([@page])
@controller.send(:locomotive_page).should == @page

View File

@ -163,7 +163,7 @@ describe Locomotive::Routing::SiteDispatcher do
@controller.instance_variable_set('@_response', ActionDispatch::Response.new)
@controller.stubs(:request).returns(@request)
@controller.stubs(:current_account).returns(@account)
@controller.stubs(:current_locomotive_account).returns(@account)
@controller.stubs(:sign_out).with(@account)
@controller.stubs(:new_session_url).returns('/new/admin/session')
end

View File

@ -3,7 +3,7 @@ module Locomotive
include Locomotive::Render
attr_accessor :output, :status, :current_site, :current_account
attr_accessor :output, :status, :current_site, :current_locomotive_account
def render(options = {})
self.output = options[:text]