From e2b68ba86106c565be66e1346427c026cc8facb4 Mon Sep 17 00:00:00 2001 From: did Date: Sat, 23 Jul 2011 01:26:16 +0200 Subject: [PATCH] restore production settings + fix broken tests + apply the coding convention on the recently modified haml file --- app/views/admin/pages/index.html.haml | 2 +- app/views/admin/shared/_header.html.haml | 4 +- config/assets.yml | 4 +- config/environments/production.rb | 4 +- config/mongoid.yml | 2 +- features/admin/content_types.feature | 6 +- features/admin/contents.feature | 4 +- features/admin/pages.feature | 2 +- features/admin/snippets.feature | 8 +- features/admin/theme_assets.feature | 4 +- public/javascripts/admin/guiders-1.1.0.js | 26 ++-- public/javascripts/admin/tutorial.js | 150 +++++++++++----------- public/javascripts/admin/utils.js | 4 + 13 files changed, 112 insertions(+), 108 deletions(-) diff --git a/app/views/admin/pages/index.html.haml b/app/views/admin/pages/index.html.haml index 96346207..d4c41319 100644 --- a/app/views/admin/pages/index.html.haml +++ b/app/views/admin/pages/index.html.haml @@ -11,7 +11,7 @@ - if can? :create, Page - content_for :buttons do - = admin_button_tag :new, new_admin_page_url, :class => 'new', :id => "newpage" + = admin_button_tag :new, new_admin_page_url, :class => 'new', :id => 'newpage' %p!= t('.help') diff --git a/app/views/admin/shared/_header.html.haml b/app/views/admin/shared/_header.html.haml index db946364..097c3f4b 100644 --- a/app/views/admin/shared/_header.html.haml +++ b/app/views/admin/shared/_header.html.haml @@ -4,12 +4,12 @@ #global-actions-bar != t('.welcome', :name => link_to(current_admin.name, edit_admin_my_account_url)) %span= '|' - = link_to t('.see'), current_site_url, :id => "viewsite_ele", :target => "_blank" + = link_to t('.see'), current_site_url, :id => 'viewsite', :target => '_blank' - if multi_sites? && current_admin.sites.size > 1 %span= '|' = link_to t('.switch'), '#', :id => 'sites-picker-link' %span= '|' - = link_to 'Help', '#', :class => "tutorial", :id => "help" + = link_to 'Help', '#', :class => 'tutorial', :id => 'help' %span= '|' = link_to t('.logout'), destroy_admin_session_url, :confirm => t('admin.messages.confirm') diff --git a/config/assets.yml b/config/assets.yml index a0134b1c..40d1bc2b 100644 --- a/config/assets.yml +++ b/config/assets.yml @@ -1,10 +1,10 @@ embed_assets: off +# compress_assets: off +# package_assets: off s3_bucket: <%= ENV['S3_BUCKET'] %> s3_access_key_id: <%= ENV['S3_KEY_ID'] %> s3_secret_access_key: <%= ENV['S3_SECRET_KEY'] %> -# compress_assets: off -# package_assets: off javascripts: box: diff --git a/config/environments/production.rb b/config/environments/production.rb index f9003a2a..4235de2b 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -7,7 +7,7 @@ Locomotive::Application.configure do # Full error reports are disabled and caching is turned on config.consider_all_requests_local = false - config.action_controller.perform_caching = false + config.action_controller.perform_caching = true # Specifies the header that your server uses for sending files config.action_dispatch.x_sendfile_header = "X-Sendfile" @@ -29,7 +29,7 @@ Locomotive::Application.configure do # Disable Rails's static asset server # In production, Apache or nginx will already do this - config.serve_static_assets = true + config.serve_static_assets = false # Enable serving of images, stylesheets, and javascripts from an asset server # config.action_controller.asset_host = "http://assets.example.com" diff --git a/config/mongoid.yml b/config/mongoid.yml index 15b7e247..8b08b667 100644 --- a/config/mongoid.yml +++ b/config/mongoid.yml @@ -31,4 +31,4 @@ production: # uri: <%= ENV['MONGOHQ_URL'] %> # bushido (mongohq_url will also work) - uri: <%= ENV['MONGODB_URL'] %> + uri: <%= ENV['MONGODB_URL'] %> diff --git a/features/admin/content_types.feature b/features/admin/content_types.feature index 9ab79b6f..58f14512 100644 --- a/features/admin/content_types.feature +++ b/features/admin/content_types.feature @@ -15,8 +15,8 @@ Background: Scenario: I do not want my content form to have n duplicated fields if I submit n times the content type form with errors (bug) When I go to the "Projects" model edition page And I fill in "Name" with "" - And I press "Update" - And I press "Update" - And I press "Update" + And I press "Save" + And I press "Save" + And I press "Save" When I follow "new item" Then I should see once the "Name" field diff --git a/features/admin/contents.feature b/features/admin/contents.feature index cb26b66d..7becc685 100644 --- a/features/admin/contents.feature +++ b/features/admin/contents.feature @@ -42,7 +42,7 @@ Scenario: Update an existing entry When I go to the "Projects" model list page And I follow "My sexy project" When I fill in "Name" with "My other sexy project (UPDATED)" - And I press "Update" + And I press "Save" Then I should see "Content was successfully updated." When I go to the "Projects" model list page Then I should see "My other sexy project (UPDATED)" @@ -51,7 +51,7 @@ Scenario: Update an invalid entry When I go to the "Projects" model list page And I follow "My sexy project" When I fill in "Name" with "" - And I press "Update" + And I press "Save" Then I should not see "Content was successfully updated." Scenario: Destroy an entry diff --git a/features/admin/pages.feature b/features/admin/pages.feature index 2867b37a..0f976fb6 100644 --- a/features/admin/pages.feature +++ b/features/admin/pages.feature @@ -28,6 +28,6 @@ Scenario: Updating a valid page And I follow "Home page" And I fill in "page_title" with "Home page !" And I fill in "Raw template" with "My new content is here" - And I press "Update" + And I press "Save" Then I should see "Page was successfully updated." And I should have "My new content is here" in the index page diff --git a/features/admin/snippets.feature b/features/admin/snippets.feature index b59b2a9b..39bf1593 100644 --- a/features/admin/snippets.feature +++ b/features/admin/snippets.feature @@ -6,11 +6,11 @@ Feature: Snippets Background: Given I have the site: "test site" set up And I am an authenticated user - And a page named "home" with the template: + And a page named "home" with the template: """ {% include 'yield' %} """ - And a snippet named "yield" with the template: + And a snippet named "yield" with the template: """ "yield" """ @@ -27,13 +27,13 @@ Scenario: Creating a Snippet And I should have "banner" in the banner snippet Scenario: Updating a Snippet that includes another snippet - Given a snippet named "other" with the template: + Given a snippet named "other" with the template: """ "other" """ When I go to theme assets And I follow "yield" And I fill in "snippet_template" with "{% include 'other' %}" - And I press "Update" + And I press "Save" Then I should see "Snippet was successfully updated." And I should have "{% include 'other' %}" in the yield snippet diff --git a/features/admin/theme_assets.feature b/features/admin/theme_assets.feature index 022751d7..59aff842 100644 --- a/features/admin/theme_assets.feature +++ b/features/admin/theme_assets.feature @@ -35,7 +35,7 @@ Scenario: Updating a stylesheet When I go to theme assets And I follow "stylesheets/application.css" And I fill in "theme_asset[plain_text]" with "Lorem ipsum (updated)" - And I press "Update" + And I press "Save" Then I should see "File was successfully updated." And I should see "Editing application.css" And I should see "application.css" @@ -56,7 +56,7 @@ Scenario: Updating a javascript When I go to theme assets And I follow "javascripts/application.js" And I fill in "theme_asset[plain_text]" with "Lorem ipsum (updated)" - And I press "Update" + And I press "Save" Then I should see "File was successfully updated." Scenario: Uploading an image which already exists diff --git a/public/javascripts/admin/guiders-1.1.0.js b/public/javascripts/admin/guiders-1.1.0.js index a4982756..b5620225 100644 --- a/public/javascripts/admin/guiders-1.1.0.js +++ b/public/javascripts/admin/guiders-1.1.0.js @@ -11,14 +11,14 @@ * * Questions about Guiders or Optimizely? * Email us at jeff+pickhardt@optimizely.com or hello@optimizely.com. - * + * * Enjoy! */ var guiders = (function($){ var guiders = { version: "1.1.0", - + _defaultSettings: { attachTo: null, buttons: [{name: "Close"}], @@ -136,21 +136,21 @@ var guiders = (function($){ } return guiders._guiders[id]; }, - + _showOverlay: function() { $("#guider_overlay").fadeIn("fast"); }, - + _hideOverlay: function() { $("#guider_overlay").fadeOut("fast"); }, - + _initializeOverlay: function() { if ($("#guider_overlay").length === 0) { $("
").hide().appendTo("body"); } }, - + _styleArrow: function(myGuider) { var position = myGuider.position || 0; if (!position) { @@ -215,7 +215,7 @@ var guiders = (function($){ } } }, - + next: function() { var currentGuider = guiders._guiders[guiders._currentGuiderID]; if (typeof currentGuider === "undefined") { @@ -261,7 +261,7 @@ var guiders = (function($){ guiders._guiders[myGuider.id] = myGuider; guiders._lastCreatedGuiderID = myGuider.id; - + /** * If the URL of the current window is of the form * http://www.myurl.com/mypage.html#guider=id @@ -270,7 +270,7 @@ var guiders = (function($){ if (myGuider.isHashable) { guiders._showIfHashed(myGuider); } - + return guiders; }, @@ -288,19 +288,19 @@ var guiders = (function($){ if (!id && guiders._lastCreatedGuiderID) { id = guiders._lastCreatedGuiderID; } - + var myGuider = guiders._guiderById(id); if (myGuider.overlay) { guiders._showOverlay(); } - + guiders._attach(myGuider); - + // You can use an onShow function to take some action before the guider is shown. if (myGuider.onShow) { myGuider.onShow(myGuider); } - + myGuider.elem.fadeIn("fast"); var windowHeight = $(window).height(); diff --git a/public/javascripts/admin/tutorial.js b/public/javascripts/admin/tutorial.js index b829917e..d6f2f404 100644 --- a/public/javascripts/admin/tutorial.js +++ b/public/javascripts/admin/tutorial.js @@ -1,12 +1,12 @@ $(document).ready(function(){ - + /* * * /admin/pages * */ if(window.location.pathname == "/admin/pages"){ - + $('#new_page_tutorial').click(function(){ if($('#newpage').length > 0){ guiders.hideAll(); @@ -26,7 +26,7 @@ $(document).ready(function(){ width: 200, title: "Make a new page", }); - + guiders.createGuider({ attachTo: "undefined", description: "Thank you for choosing LocomotiveCMS!,

\ @@ -41,7 +41,7 @@ $(document).ready(function(){ overlay: true, title: "Welcome to Locomotive CMS" }); - + guiders.createGuider({ attachTo: "#help", buttons: [], @@ -53,10 +53,10 @@ $(document).ready(function(){ height: 100, title: "" }); - + var pagehook = (function(){ - var possibles = ['ul.folder:first li', - 'ul#pages-list li']; + var possibles = ['ul.folder:first li', + 'ul#pages-list li']; for(var i = 0; i 0){ @@ -64,7 +64,7 @@ $(document).ready(function(){ } } }()); - + guiders.createGuider({ attachTo: pagehook, buttons: [{name: "Quit", onclick: guiders.hideAll}, @@ -80,7 +80,7 @@ $(document).ready(function(){ overlay: true, title: "" }); - + guiders.createGuider({ attachTo: "undefined", description: "A page is a collection of content on your site that can be reached at a web address

\ @@ -95,13 +95,13 @@ $(document).ready(function(){ // guiders.show('pagepointer') // } }); - + guiders.createGuider({ attachTo: 'li.hoverable:eq(2)', buttons: [{name: "Quit", onclick: guiders.hideAll}, {name: "Next - Edit an Event", onclick: function(){ - window.location = $('li.hoverable:eq(2) li:first a').attr('href') + "#guider=editmodelwelcome"; + window.location = $('li.hoverable:eq(2) li:first a').attr('href') + "#guider=editmodelwelcome"; }}], description: "These are models.
You can hover over to edit them. For this next section of the guide. We will edit an Event model. '"+$('.inner:eq(3) li:first a').text()+"' ", id: "modelpointer", @@ -110,7 +110,7 @@ $(document).ready(function(){ position: 4, title: "" }); - + guiders.createGuider({ attachTo: 'div.action span', buttons: [], @@ -122,7 +122,7 @@ $(document).ready(function(){ width: 200, title: "" }); - + guiders.createGuider({ attachTo: 'div.action span', buttons: [], @@ -138,21 +138,21 @@ $(document).ready(function(){ $('div.action a').attr('href') + "#guider=newmodelwelcome"); } }); - - + + guiders.createGuider({ attachTo: "undefined", description: (function(){ var ret = "What is a model?
\ The concept of a model within locomotiveCMS is a peice of content that you might reuse through out your site.\ Some example models could be: Blog posts, Products, Events, Locations, Photos

" - + if($('li.hoverable').length > 1){ ret += "For this next section of the guide. We will edit our Event model. '"+$('.inner:eq(3) li:first a').text()+"' "; }else{ ret += "For this next section of the guide, lets make a new model"; } - + return ret; }()), buttons: [{name: "Quit", onclick: guiders.hideAll}, @@ -170,7 +170,7 @@ $(document).ready(function(){ // return { // name: "Next - Edit an Event", // onclick: function(){ - // window.location = $('li.hoverable:eq(2) li:first a').attr('href') + "#guider=editmodelwelcome"; + // window.location = $('li.hoverable:eq(2) li:first a').attr('href') + "#guider=editmodelwelcome"; // } // }; // } @@ -191,7 +191,7 @@ $(document).ready(function(){ // //guiders.show('newmodelpointer'); // } }); - + guiders.createGuider({ attachTo: 'li.settings a', buttons: [], @@ -201,7 +201,7 @@ $(document).ready(function(){ width: 200, title: "" }); - + guiders.createGuider({ attachTo: "undefined", description: "LocomotiveCMS has several features that you can adjust in the settings panel. Lets head there now!", @@ -216,16 +216,16 @@ $(document).ready(function(){ guiders.show("settingspointer"); } }); - + } - + /* * - * /admin/pages/edit + * /admin/pages/edit * */ if(window.location.pathname.match('admin/pages/.+\/edit') != null){ - + // /* // * We have to delay the creation of this guider // * so TinyMCE can render it @@ -244,7 +244,7 @@ $(document).ready(function(){ // }); // }, 2000); // }; - + guiders.createGuider({ attachTo: "undefined", description: "You are now editing the '"+$('a.editable:first').text()+"' page. Lets start by changing the title of this page.", @@ -255,10 +255,10 @@ $(document).ready(function(){ overlay: true, title: "Editing A Page" }); - - + + var page_title = 'Guide Demo Page'; - + guiders.createGuider({ attachTo: "a.editable:first", buttons: [], @@ -270,7 +270,7 @@ $(document).ready(function(){ height: 100, description: "Click here to edit the page title.

Change the title to '"+page_title+"'" }); - + guiders.createGuider({ attachTo: "undefined", description: "You just changed the title of this page. Lets continue by editing the page content.", @@ -280,8 +280,8 @@ $(document).ready(function(){ next: "pageeditcontent", overlay: true, title: "Great Job!" - }); - + }); + guiders.createGuider({ buttons: [], attachTo: "button.light:last", @@ -290,11 +290,11 @@ $(document).ready(function(){ position: 12, title: "Save Your Work", onShow: function(){ - $('form.save-with-shortcut').attr('action', + $('form.save-with-shortcut').attr('action', $('form.save-with-shortcut').attr('action')+"#guider=editsavesuccess"); } }); - + guiders.createGuider({ attachTo: "undefined", description: "Great work! you've update this page. You can review your work by checking out the 'frontend' of the site.", @@ -302,10 +302,10 @@ $(document).ready(function(){ {name: "Next"}], id: "editsavesuccess", next: "viewsite2", - overlay: true, + overlay: true, title: "Page Saved Successfully!" }); - + function viewSiteClick(e){ console.log("viewsite click!"); var $this = $(e.target); @@ -317,9 +317,9 @@ $(document).ready(function(){ return false; //should probably unbind this to prevent double clicking } - + guiders.createGuider({ - attachTo: "#viewsite_ele", + attachTo: "#viewsite", buttons: [], description: "This will open a new tab in your browser and take you to the 'frontend' of your site. The frontend is what other visitors to your site will see. Come back to this tab in your browser to continue the guide.", id: "viewsite2", @@ -328,11 +328,11 @@ $(document).ready(function(){ width: 280, title: "Click Here To View Your Site", onShow: function(){ - console.log("binding click for view site", $('#viewsite_ele')); - $('#viewsite_ele').bind('click', viewSiteClick); + console.log("binding click for view site", $('#viewsite')); + $('#viewsite').bind('click', viewSiteClick); } }); - + guiders.createGuider({ attachTo: "undefined", description: "Congratulations. You've just edited a page using LocomotiveCMS! Moving on, we will now move onto models. Lets return to the admin home.", @@ -344,9 +344,9 @@ $(document).ready(function(){ overlay: true, title: "Done editing." }); - + } - + /* * * New model @@ -354,7 +354,7 @@ $(document).ready(function(){ */ if(window.location.pathname.match('admin/content_types/new') != null || window.location.pathname.match('admin/content_types/.+/edit')){ - + guiders.createGuider({ attachTo: "undefined", description: "A model is how you define the content on your site. Lots of sites have: Blog Posts, Products, Photo Albums, Events.\ @@ -367,8 +367,8 @@ $(document).ready(function(){ next: "createmodel", overlay: true, title: "Lets create a new model!" - }); - + }); + guiders.createGuider({ buttons: [], attachTo: "button.light:first", @@ -378,19 +378,19 @@ $(document).ready(function(){ position: 9, title: "Save Your Work", onShow: function(){ - $('#new_content_type').attr('action', + $('#new_content_type').attr('action', $('#new_content_type').attr('action')+"#guider=newmodelsuccess"); } }); - + guiders.createGuider({ attachTo: "undefined", - description: (function(){ + description: (function(){ if($('.inline-errors').length > 0){ return "Looks like you forgot something. Please Check out the errors and try again!"; }else{ return "You've Successfully created a model! Moving on. Lets adjust the settings of your LocomotiveCMS"; - } + } }), buttons: [{name: "Quit", onclick: guiders.hideAll}, {name: "Next - Settings", onclick: function(){ @@ -399,29 +399,29 @@ $(document).ready(function(){ id: "newmodelsuccess", next: "editsubdomain", overlay: true, - title: (function(){ + title: (function(){ if($('.inline-errors').length > 0){ return "Uh oh."; }else{ return "Great Work! You Made A New Model."; - } + } }), - onShow: (function(){ + onShow: (function(){ if($('.inline-errors').length > 0){ guiders.show('createmodel'); } }) }); - + } - + /* * * Content edits * */ if(window.location.pathname.match('admin/content_types/events/contents/.+/edit') != null){ - + guiders.createGuider({ attachTo: "undefined", description: "You are now edting an instance of our event model.\ @@ -433,7 +433,7 @@ $(document).ready(function(){ overlay: true, title: "Editing an Event model" }); - + guiders.createGuider({ buttons: [], attachTo: "button.light:last", @@ -442,11 +442,11 @@ $(document).ready(function(){ position: 12, title: "Save Your Work", onShow: function(){ - $('form.save-with-shortcut').attr('action', + $('form.save-with-shortcut').attr('action', $('form.save-with-shortcut').attr('action')+"#guider=modelsavesuccess"); } }); - + guiders.createGuider({ attachTo: "undefined", description: "You've Successfully updated this model", @@ -458,17 +458,17 @@ $(document).ready(function(){ overlay: true, title: "Great Work!" }); - + } - - + + /* * * Settings page * */ if(window.location.pathname.match("admin/current_site/edit") != null){ - + guiders.createGuider({ attachTo: "undefined", description: "Welcome to the Settings page. Here you can create new user accounts to use LocomotiveCMS, Edit SEO options, and more. We will start by changing the subomain of our site.", @@ -479,7 +479,7 @@ $(document).ready(function(){ overlay: true, title: "The Settings Page" }); - + guiders.createGuider({ attachTo: "#site_subdomain", description: "Edit this field to change the subdomain of your site", @@ -494,7 +494,7 @@ $(document).ready(function(){ }); } }); - + guiders.createGuider({ buttons: [], attachTo: "button.light:last", @@ -503,11 +503,11 @@ $(document).ready(function(){ position: 12, title: "Save Your Work", onShow: function(){ - $('form.save-with-shortcut').attr('action', + $('form.save-with-shortcut').attr('action', $('form.save-with-shortcut').attr('action')+"#guider=settingssavesuccess"); } }); - + guiders.createGuider({ attachTo: "undefined", title: "Great Work!", @@ -526,11 +526,11 @@ $(document).ready(function(){ overlay: true }); } - - + + /* * - * Global + * Global * */ guiders.createGuider({ @@ -547,7 +547,7 @@ $(document).ready(function(){ width: 200, title: "Locomotive Guides", }); - + $(".tutorial").click(function(){ var $this = $(this); guiders.hideAll(); @@ -559,9 +559,9 @@ $(document).ready(function(){ } return false; }); - + guiders.createGuider({ - attachTo: "#viewsite_ele", + attachTo: "#viewsite", buttons: [{name: "Close", onclick: guiders.hideAll}], description: "This will take you to the 'frontend' of your site. Where you can see what users visiting your site see.", id: "viewsite", @@ -569,7 +569,7 @@ $(document).ready(function(){ width: 280, title: "Click Here To View Your Site", }); - + guiders.createGuider({ attachTo: "undefined", description: "You've gone through the LocomotiveCMS guide! For more info on LocomotiveCMS,\ @@ -580,7 +580,7 @@ $(document).ready(function(){ overlay: true, title: "Congratulations!" }); - + window.onload = function(){ window.setTimeout(function(){ guiders.createGuider({ @@ -596,5 +596,5 @@ $(document).ready(function(){ }); }, 1000); }; - + }); \ No newline at end of file diff --git a/public/javascripts/admin/utils.js b/public/javascripts/admin/utils.js index 0a06b06d..30f76c6b 100644 --- a/public/javascripts/admin/utils.js +++ b/public/javascripts/admin/utils.js @@ -1,3 +1,7 @@ +if (typeof window.console === 'undefined') { + window.console = { log: function() { return false; } }; +} + function makeSlug(val, sep) { // code largely inspired by http://www.thewebsitetailor.com/jquery-slug-plugin/ if (typeof val == 'undefined') return(''); if (typeof sep == 'undefined') sep = '_';