Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixing conflicts

  • Loading branch information...
commit 690c5f055b7357716ecc4464ce96906bc23bde82 2 parents ba5e93f + bb33707
@rorra rorra authored
View
1  .gitignore
@@ -33,6 +33,7 @@ config/deploy/*.json
!config/deploy/example_site.rb
*.pid
ical
+log/*.db
db/*.db
db/*.sqlite3
config/initializers/your_site_host.rb
View
5 Gemfile
@@ -15,7 +15,7 @@ gem "friendly_id", '3.3.1'
gem 'will_paginate'
gem "oauth-plugin", ">= 0.4.0.pre1"
gem "twitter", :git => "https://github.com/jnunemaker/twitter.git"
-gem "mysql"
+gem "mysql2"
gem "bitly"
gem "redis"
gem "redis-namespace"
@@ -33,7 +33,8 @@ gem 'routing-filter'
# JVD: having problems getting this working with an empty database
# The gem tries to load the locales table before it exists.
-gem 'i18n_backend_database', :git => "git://github.com/rorra/i18n_backend_database.git"
+# Patched this to fix issues with the Translation model
+gem 'i18n_backend_database', :git => "git://github.com/chewbranca/i18n_backend_database.git"
# JVD: Use this when developing, checkout the i18n_backend_database to ../
# gem 'i18n_backend_database', :path => "../i18n_backend_database"
View
11 Gemfile.lock
@@ -1,4 +1,11 @@
GIT
+ remote: git://github.com/chewbranca/i18n_backend_database.git
+ revision: 3c5be2c7b79ec9e0c3283de82d913e840e06c9c5
+ specs:
+ i18n_backend_database (0.0.1)
+ rails (>= 3)
+
+GIT
remote: git://github.com/chriseppstein/compass.git
revision: 8c84869b0b6bc5396e264fea15c71d4e346ac5d0
specs:
@@ -190,7 +197,7 @@ GEM
multi_json (1.0.4)
multi_xml (0.4.1)
multipart-post (1.1.4)
- mysql (2.8.1)
+ mysql2 (0.3.11)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-sftp (2.0.5)
@@ -368,7 +375,7 @@ DEPENDENCIES
launchy
loofah
mogli
- mysql
+ mysql2
newrelic_rpm
nokogiri
oauth-plugin (>= 0.4.0.pre1)
View
7 README.md
@@ -86,6 +86,7 @@ The primary(required) config files are:
* database.yml
* facebooker.yml -- remember to set callback_url to your base site, ie http://my.site.com
+ * locales.yml -- select the languagues you will be using
The optional config files for advanced settings are:
@@ -96,7 +97,6 @@ The optional config files for advanced settings are:
* menu.yml -- configure what menu items you want to appear in your application
* application.god for use with the [God monitoring system](http://god.rubyforge.org/)
* unicorn.conf.rb
- * locales.yml -- select the languagues you will be using
* There are a number of other advanced files in the config directory
We provide .sample files for the majority of these config files to facilitate easy setup.
@@ -122,8 +122,9 @@ Now that we got the hard part out of the way, there are just a few commands left
# Install the required gems
bundle install
# Run the newscloud setup process, this will create your database along with configuring your application
- LOCALE_FILE=./config/locales.yml rake n2:setup
-
+ rake n2:setup
+ # Load the default locales
+ bundle exec rake i18n:populate:load_default_locales LOCALE_FILE=config/locales.yml
Post Installation
-----------------
View
356 app/assets/javascripts/jquery.ui.nestedSortable.js
@@ -0,0 +1,356 @@
+/*
+ * jQuery UI Nested Sortable
+ * v 1.3.4 / 28 apr 2011
+ * http://mjsarfatti.com/sandbox/nestedSortable
+ *
+ * Depends:
+ * jquery.ui.sortable.js 1.8+
+ *
+ * License CC BY-SA 3.0
+ * Copyright 2010-2011, Manuele J Sarfatti
+ */
+
+(function($) {
+
+ $.widget("ui.nestedSortable", $.extend({}, $.ui.sortable.prototype, {
+
+ options: {
+ tabSize: 20,
+ disableNesting: 'ui-nestedSortable-no-nesting',
+ errorClass: 'ui-nestedSortable-error',
+ listType: 'ol',
+ maxLevels: 0,
+ noJumpFix: 0
+ },
+
+ _create: function(){
+ if (this.noJumpFix == false)
+ this.element.height(this.element.height());
+ this.element.data('sortable', this.element.data('nestedSortable'));
+ return $.ui.sortable.prototype._create.apply(this, arguments);
+ },
+
+
+
+ _mouseDrag: function(event) {
+
+ //Compute the helpers position
+ this.position = this._generatePosition(event);
+ this.positionAbs = this._convertPositionTo("absolute");
+
+ if (!this.lastPositionAbs) {
+ this.lastPositionAbs = this.positionAbs;
+ }
+
+ //Do scrolling
+ if(this.options.scroll) {
+ var o = this.options, scrolled = false;
+ if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') {
+
+ if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
+ this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
+ else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
+ this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
+
+ if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
+ this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
+ else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
+ this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
+
+ } else {
+
+ if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
+ scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
+ else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
+ scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
+
+ if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
+ scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
+ else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
+ scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
+
+ }
+
+ if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
+ $.ui.ddmanager.prepareOffsets(this, event);
+ }
+
+ //Regenerate the absolute position used for position checks
+ this.positionAbs = this._convertPositionTo("absolute");
+
+ //Set the helper position
+ if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
+ if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
+
+ //Rearrange
+ for (var i = this.items.length - 1; i >= 0; i--) {
+
+ //Cache variables and intersection, continue if no intersection
+ var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item);
+ if (!intersection) continue;
+
+ if(itemElement != this.currentItem[0] //cannot intersect with itself
+ && this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
+ && !$.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
+ && (this.options.type == 'semi-dynamic' ? !$.contains(this.element[0], itemElement) : true)
+ //&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container
+ ) {
+
+ this.direction = intersection == 1 ? "down" : "up";
+
+ if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) {
+ this._rearrange(event, item);
+ } else {
+ break;
+ }
+
+ // Clear emtpy ul's/ol's
+ this._clearEmpty(itemElement);
+
+ this._trigger("change", event, this._uiHash());
+ break;
+ }
+ }
+
+ var parentItem = (this.placeholder[0].parentNode.parentNode && $(this.placeholder[0].parentNode.parentNode).closest('.ui-sortable').length) ? $(this.placeholder[0].parentNode.parentNode) : null;
+ var level = this._getLevel(this.placeholder);
+ var childLevels = this._getChildLevels(this.helper);
+ var previousItem = this.placeholder[0].previousSibling ? $(this.placeholder[0].previousSibling) : null;
+ if (previousItem != null) {
+ while (previousItem[0].nodeName.toLowerCase() != 'li' || previousItem[0] == this.currentItem[0]) {
+ if (previousItem[0].previousSibling) {
+ previousItem = $(previousItem[0].previousSibling);
+ } else {
+ previousItem = null;
+ break;
+ }
+ }
+ }
+
+ newList = document.createElement(o.listType);
+
+ this.beyondMaxLevels = 0;
+
+ // If the item is moved to the left, send it to its parent level
+ if (parentItem != null && this.positionAbs.left < parentItem.offset().left) {
+ parentItem.after(this.placeholder[0]);
+ this._clearEmpty(parentItem[0]);
+ this._trigger("change", event, this._uiHash());
+ }
+ // If the item is below another one and is moved to the right, make it a children of it
+ else if (previousItem != null && this.positionAbs.left > previousItem.offset().left + o.tabSize) {
+ this._isAllowed(previousItem, level+childLevels+1);
+ if (!previousItem.children(o.listType).length) {
+ previousItem[0].appendChild(newList);
+ }
+ previousItem.children(o.listType)[0].appendChild(this.placeholder[0]);
+ this._trigger("change", event, this._uiHash());
+ }
+ else {
+ this._isAllowed(parentItem, level+childLevels);
+ }
+
+ //Post events to containers
+ this._contactContainers(event);
+
+ //Interconnect with droppables
+ if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
+
+ //Call callbacks
+ this._trigger('sort', event, this._uiHash());
+
+ this.lastPositionAbs = this.positionAbs;
+ return false;
+
+ },
+
+ _mouseStop: function(event, noPropagation) {
+
+ // If the item is in a position not allowed, send it back
+ if (this.beyondMaxLevels) {
+ var parent = this.placeholder.parent().closest(this.options.items);
+
+ for (var i = this.beyondMaxLevels - 1; i > 0; i--) {
+ parent = parent.parent().closest(this.options.items);
+ }
+
+ this.placeholder.removeClass(this.options.errorClass);
+ parent.after(this.placeholder);
+ this._trigger("change", event, this._uiHash());
+ }
+
+ $.ui.sortable.prototype._mouseStop.apply(this, arguments);
+
+ },
+
+ serialize: function(o) {
+
+ var items = this._getItemsAsjQuery(o && o.connected);
+ var str = []; o = o || {};
+
+ $(items).each(function() {
+ var res = ($(o.item || this).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
+ var pid = ($(o.item || this).parent(o.listType).parent('li').attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
+ if(res) str.push((o.key || res[1]+'['+(o.key && o.expression ? res[1] : res[2])+']')+'='+(pid ? (o.key && o.expression ? pid[1] : pid[2]) : 'root'));
+ });
+
+ if(!str.length && o.key) {
+ str.push(o.key + '=');
+ }
+
+ return str.join('&');
+
+ },
+
+ toHierarchy: function(o) {
+
+ o = o || {};
+ var sDepth = o.startDepthCount || 0;
+ var ret = [];
+
+ $(this.element).children('li').each(function() {
+ var level = _recursiveItems($(this));
+ ret.push(level);
+ });
+
+ return ret;
+
+ function _recursiveItems(li) {
+ var id = ($(li).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
+ if (id != null) {
+ var item = {"id" : id[2]};
+ if ($(li).children(o.listType).children('li').length > 0) {
+ item.children = [];
+ $(li).children(o.listType).children('li').each(function () {
+ var level = _recursiveItems($(this));
+ item.children.push(level);
+ });
+ }
+ return item;
+ }
+ }
+ },
+
+ toArray: function(o) {
+
+ o = o || {};
+ var sDepth = o.startDepthCount || 0;
+ var ret = [];
+ var left = 2;
+
+ ret.push({"item_id": 'root', "parent_id": 'none', "depth": sDepth, "left": '1', "right": ($('li', this.element).length + 1) * 2});
+
+ $(this.element).children('li').each(function () {
+ left = _recursiveArray(this, sDepth + 1, left);
+ });
+
+ function _sortByLeft(a,b) {
+ return a['left'] - b['left'];
+ }
+ ret = ret.sort(_sortByLeft);
+
+ return ret;
+
+ function _recursiveArray(item, depth, left) {
+
+ right = left + 1;
+
+ if ($(item).children(o.listType).children('li').length > 0) {
+ depth ++;
+ $(item).children(o.listType).children('li').each(function () {
+ right = _recursiveArray($(this), depth, right);
+ });
+ depth --;
+ }
+
+ id = ($(item).attr(o.attribute || 'id')).match(o.expression || (/(.+)[-=_](.+)/));
+
+ if (depth === sDepth + 1) pid = 'root';
+ else {
+ parentItem = ($(item).parent(o.listType).parent('li').attr('id')).match(o.expression || (/(.+)[-=_](.+)/));
+ pid = parentItem[2];
+ }
+
+ if (id != null) {
+ ret.push({"item_id": id[2], "parent_id": pid, "depth": depth, "left": left, "right": right});
+ }
+
+ return left = right + 1;
+ }
+
+ },
+
+ _clear: function(event, noPropagation) {
+
+ $.ui.sortable.prototype._clear.apply(this, arguments);
+
+ // Clean last empty ul/ol
+ for (var i = this.items.length - 1; i >= 0; i--) {
+ var item = this.items[i].item[0];
+ this._clearEmpty(item);
+ }
+ return true;
+
+ },
+
+ _clearEmpty: function(item) {
+
+ if (item.children[1] && item.children[1].children.length == 0) {
+ item.removeChild(item.children[1]);
+ }
+
+ },
+
+ _getLevel: function(item) {
+
+ var level = 1;
+
+ if (this.options.listType) {
+ var list = item.closest(this.options.listType);
+ while (!list.is('.ui-sortable')/* && level < this.options.maxLevels*/) {
+ level++;
+ list = list.parent().closest(this.options.listType);
+ }
+ }
+
+ return level;
+ },
+
+ _getChildLevels: function(parent, depth) {
+ var self = this,
+ o = this.options,
+ result = 0;
+ depth = depth || 0;
+
+ $(parent).children(o.listType).children(o.items).each(function (index, child) {
+ result = Math.max(self._getChildLevels(child, depth + 1), result);
+ });
+
+ return depth ? result + 1 : result;
+ },
+
+ _isAllowed: function(parentItem, levels) {
+ var o = this.options
+ // Are we trying to nest under a no-nest or are we nesting too deep?
+ if (parentItem == null || !(parentItem.hasClass(o.disableNesting))) {
+ if (o.maxLevels < levels && o.maxLevels != 0) {
+ this.placeholder.addClass(o.errorClass);
+ this.beyondMaxLevels = levels - o.maxLevels;
+ } else {
+ this.placeholder.removeClass(o.errorClass);
+ this.beyondMaxLevels = 0;
+ }
+ } else {
+ this.placeholder.addClass(o.errorClass);
+ if (o.maxLevels < levels && o.maxLevels != 0) {
+ this.beyondMaxLevels = levels - o.maxLevels;
+ } else {
+ this.beyondMaxLevels = 1;
+ }
+ }
+ }
+
+ }));
+
+ $.ui.nestedSortable.prototype.options = $.extend({}, $.ui.sortable.prototype.options, $.ui.nestedSortable.prototype.options);
+})(jQuery);
View
7 app/assets/javascripts/widgets.js
@@ -0,0 +1,7 @@
+(function() {
+ $.timeago.settings.strings.suffixAgo = '';
+ $('abbr.timeago').timeago();
+ setTimeout(function() {
+ $('abbr.timeago').timeago();
+ }, 500);
+})(jQuery);
View
7 app/assets/stylesheets/default_v3.sass
@@ -1660,3 +1660,10 @@ body div.jGrowl div.jGrowl-closer
.add-this-wrap
padding: 10px 0
+
+// Russell's Section Stuff //
+.hidden
+ display: none !important
+
+.hide-strong
+ display: none !important
View
2  app/helpers/application_helper.rb
@@ -402,6 +402,8 @@ def tag_link(tag, item)
tagged_forum_path(item.forum, :tag => tag_name)
elsif item.class.name == 'Gallery'
tagged_galleries_path(:tag => tag_name)
+ elsif item.class.name == 'Resource'
+ resource_tag_path(:tag => tag_name)
elsif item.class.name == 'PredictionQuestion'
tagged_prediction_questions_path(:tag => tag_name)
elsif item.class.name == 'PredictionGroup'
View
6 app/helpers/locales_helper.rb
@@ -1,17 +1,17 @@
module LocalesHelper
def generic_posted_by item, user = nil, date = nil
- user ||= item.user
+ user ||= item.item_user
posted_by item, :user => user
end
def stories_posted_by item, user = nil, format = nil
- user ||= item.user
+ user ||= item.item_user
posted_by item, :user => user, :date => true, :format => nil
end
def user_posted_item item, user = nil
- user ||= item.user
+ user ||= item.item_user
I18n.translate('user_posted_item', :fb_name => local_linked_profile_name(user, :only_path => false, :format => 'html'), :title => link_to(item.item_title, polymorphic_url(item.item_link,:only_path => false) ), :date => timeago(item.created_at)).html_safe
end
View
4 app/models/item_score.rb
@@ -25,6 +25,10 @@ def self.get_score item
self.find_or_create(item).score
end
+ def self.top_for_class klass, limit = nil
+ ItemScore.for_class(klass).active.top(limit).map(&:scorable)
+ end
+
def self.calc_item_score item
positive_actions_count = ItemAction.tally_for_item(item) + 1
negative_actions_count = 0 # Eventually change this
View
22 app/views/idea_boards/show.html.haml
@@ -15,20 +15,26 @@
%ul
- @ideas.each do |idea|
%li{'data-id' => idea.cache_key}
- .item_1
+ .item-image
.thumb
- if idea.images.present?
= image_tag idea.images.first.url(:thumb)
- else
= image_tag ('skin/watermark.jpg')
- .item-block
- %h2= link_to idea.title, idea_path(idea)
+ .content
+ %h3= link_to idea.title, idea_path(idea)
%p= linked_item_details idea
- .profile-pic= local_linked_profile_pic idea.user
- .meta-data
- %h3= generic_posted_by idea
- %span== #{like_link idea} #{idea.votes_tally}
- %span== #{link_to t('comments'), idea_path(idea, :anchor => "commentListTop")} #{idea.comments_count}
+ .meta-profile
+ .profile-pic= local_linked_profile_pic idea.user
+ %h6
+ = generic_posted_by idea
+ - if idea.idea_board.present?
+ in
+ = link_to(idea.idea_board.name, idea.idea_board)
+ %h6
+ %span== #{like_link idea} #{idea.votes_tally}
+ = pipe_spacer
+ %span== #{link_to t('.ideas_comments'), idea_path(idea, :anchor => "commentListTop")} #{idea.comments_count}
- if @paginate
.clearfix
= will_paginate @ideas
View
2  app/views/layouts/new_admin.html.haml
@@ -24,7 +24,7 @@
= stylesheet_link_tag 'superfish'
= stylesheet_link_tag 'tablesorter'
- = stylesheet_link_tag 'ui-lightness/jquery-ui-1.7.2.custom'
+ = stylesheet_link_tag 'ui-lightness/jquery-ui-1.7.2.custom.css'
:javascript
$(function() {
View
20 app/views/questions/my_questions.html.haml
@@ -11,7 +11,6 @@
.refine-search-wrap
= render :partial => 'shared/forms/refine_dropdown', :locals => { :select_options => Question.refineable_select_options }
%h2= t('questions.my_list_title')
- - if @questions.present? and @questions.first.refineable?
.subtitle
%span= t('questions.my_list_subtitle')
- unless @questions.empty?
@@ -20,21 +19,22 @@
%ul
- @questions.each do |question|
%li.askQuestionWrap{'data-id' => question.cache_key}
- .item_1
+ .item-image
.thumb
- if question.images.present?
= image_tag question.images.first.url(:thumb)
- else
= image_tag ('skin/watermark.jpg')
- .item-block
- %h2= link_to question.question, question
+ .content
+ %h3= link_to question.question, question
%p= linked_item_details question
- .profile-pic= local_linked_profile_pic question.user
- .meta-data
- %h3= asked_by question
- %span== #{like_link question} #{question.votes.size}
- %span== #{link_to answer_translate(question.answers.count), question_path(question, :anchor => "commentListTop")}
- -#%span= fb_share_item_button question
+ .meta-profile
+ .profile-pic= local_linked_profile_pic question.user
+ %h6= asked_by question
+ %h6
+ %span== #{like_link question} #{question.votes.size}
+ = pipe_spacer
+ %span== #{link_to answer_translate(question.answers.count), question_path(question, :anchor => "commentListTop")}
- if @paginate
.panel-2
View
2  app/views/shared/_forums.html.haml
@@ -32,7 +32,7 @@
%span= t('forums.topics_count', :topics_count => forum.topics_count)
%span= t('forums.posts_count', :posts_count => forum.comments_count)
-.panel-2.mod-panel
+.panel-2.mod-panel.admin-links.hidden
.subtitle.clearfix
= link_to t('forums.new'), new_admin_forum_path(), :class => "float-right", :target => '_parent'
View
2  app/views/shared/sidebar/_top_events.html.haml
@@ -1,7 +1,7 @@
-# @expects: local 'event'
- cache :top_events_html do
- - top_events ||= Event.active.tally({ :at_least => 1, :limit => 5, :order => "votes.count desc" })
+ - top_events ||= ItemScore.top_for_class(Event)
%div{:class => "panel-1 #{defined?(widget_page) ? widget_page.css_class : ''}"}
.panel-bar
%h2= t('.top_events_title')
View
4 app/workers/classifieds_worker.rb
@@ -15,7 +15,7 @@ def self.perform()
chirp = Chirp.new({
:chirper => user,
:recipient => classified.user,
- :message => ActionView::Base.new.render(:partial => "#{Rails.root}/app/views/classifieds/_near_expiration.html.haml", :locals => { :user => classified.user, :title => classified } )
+ :message => ActionView::Base.new.render(:partial => "#{Rails.root.to_s}/app/views/classifieds/_near_expiration.html.haml", :locals => { :user => classified.user, :title => classified } )
})
#if chirp.valid? and user.sent_chirps.push chirp
#recipient.user_profile.update_attribute(:email_last_ask, Time.now)
@@ -31,7 +31,7 @@ def self.perform()
chirp = Chirp.new({
:chirper => user,
:recipient => classified.user,
- :message => ActionView::Base.new.render(:partial => "#{Rails.root}/app/views/classifieds/_expired.html.haml", :locals => { :user => classified.user, :title => classified } )
+ :message => ActionView::Base.new.render(:partial => "#{Rails.root.to_s}/app/views/classifieds/_expired.html.haml", :locals => { :user => classified.user, :title => classified } )
})
end
end
View
2  app/workers/reminders_worker.rb
@@ -19,7 +19,7 @@ def self.perform()
chirp = Chirp.new({
:chirper => user,
:recipient => recipient,
- :message => ActionView::Base.new.render(:partial => "#{Rails.root}/app/views/reminders/email_signup.html.haml", :locals => { :user => recipient } )
+ :message => ActionView::Base.new.render(:partial => "#{Rails.root.to_s}/app/views/reminders/email_signup.html.haml", :locals => { :user => recipient } )
})
if chirp.valid? and user.sent_chirps.push chirp
recipient.user_profile.update_attribute(:email_last_ask, Time.now)
View
2  config/application.rb
@@ -23,6 +23,8 @@ class Application < Rails::Application
tablesorter
fb_grid
admin
+ admin_grid
+ superfish
cards
base
scaffold
View
40 config/deploy.rb
@@ -24,7 +24,7 @@
after("deploy:symlink") do
# setup shared files
- %w{/config/unicorn.conf.rb /tmp/sockets /config/database.yml
+ %w{/config/thin.yml /tmp/sockets /config/database.yml
/config/facebooker.yml /config/application_settings.yml /config/providers.yml
/config/application.god /config/newrelic.yml /config/s3.yml
/config/smtp.yml /config/resque_schedule.yml /config/menu.yml}.each do |file|
@@ -50,7 +50,7 @@
after("deploy:update_code") do
unless exists?(:skip_post_deploy) and skip_post_deploy
deploy.load_skin
- deploy.server_post_deploy
+ #deploy.server_post_deploy
set :rake_post_path, release_path
deploy.rake_post_deploy
end
@@ -109,16 +109,16 @@
namespace :resque do
desc "Restart Resque workers"
task :restart_workers, :roles => :workers do
- run "cd #{current_path} && bundle exec rake n2:queue:stop_workers RAILS_ENV=#{rails_env}"
- run "cd #{current_path} && bundle exec rake n2:queue:stop_scheduler APP_NAME=#{application} RAILS_ENV=#{rails_env}"
+ run "cd #{release_path} && bundle exec rake n2:queue:stop_workers RAILS_ENV=#{rails_env}"
+ run "cd #{release_path} && bundle exec rake n2:queue:stop_scheduler APP_NAME=#{application} RAILS_ENV=#{rails_env}"
end
desc "Stop Resque workers"
task :stop_workers, :roles => :workers do
# TODO:: switch this to god.stop_workers
deploy.god.stop
- run "cd #{current_path} && bundle exec rake n2:queue:stop_workers RAILS_ENV=#{rails_env}"
- run "cd #{current_path} && bundle exec rake n2:queue:stop_scheduler APP_NAME=#{application} RAILS_ENV=#{rails_env}"
+ run "cd #{release_path} && bundle exec rake n2:queue:stop_workers RAILS_ENV=#{rails_env}"
+ run "cd #{release_path} && bundle exec rake n2:queue:stop_scheduler APP_NAME=#{application} RAILS_ENV=#{rails_env}"
end
desc "Start Resque workers"
@@ -135,19 +135,22 @@
desc "Restart application"
task :restart, :roles => :app, :except => { :no_release => true } do
- run "cat #{current_path}/tmp/pids/unicorn.pid | xargs kill -USR2"
+ #run "cat #{current_path}/tmp/pids/unicorn.pid | xargs kill -USR2"
+ run "cd #{current_path} && bundle exec thin -C #{current_path}/config/thin.yml restart"
end
desc "Start application"
task :start, :roles => :app do
- run "cd #{current_path} && bundle exec unicorn_rails -c #{current_path}/config/unicorn.conf.rb -E #{rails_env} -D"
- deploy.god.start
+ #run "cd #{current_path} && bundle exec unicorn_rails -c #{current_path}/config/unicorn.conf.rb -E #{rails_env} -D"
+ #deploy.god.start
+ run "cd #{current_path} && bundle exec thin -C #{current_path}/config/thin.yml start"
end
desc "Stop application"
task :stop, :roles => :app do
deploy.god.stop
- run "cat #{current_path}/tmp/pids/unicorn.pid | xargs kill -QUIT"
+ #run "cat #{current_path}/tmp/pids/unicorn.pid | xargs kill -QUIT"
+ run "cd #{current_path} && bundle exec thin -C #{current_path}/config/thin.yml stop"
run "cd #{current_path} && bundle exec rake n2:queue:stop_workers RAILS_ENV=#{rails_env}"
run "cd #{current_path} && bundle exec rake n2:queue:stop_scheduler APP_NAME=#{application} RAILS_ENV=#{rails_env}"
end
@@ -184,7 +187,8 @@
desc "Run rake after deploy tasks"
task :rake_post_deploy, :roles => :app do
path = rake_post_path || release_path
- run "cd #{path} && bundle exec rake n2:deploy:after RAILS_ENV=#{rails_env}"
+ #run "cd #{path} && bundle exec rake n2:deploy:after RAILS_ENV=#{rails_env}"
+ run "cd #{path} && bundle exec rake assets:precompile --trace"
end
desc "Run rake post upgrade after upgrade_newscloud"
@@ -198,8 +202,8 @@
if roles[:workers].any?
resque.restart_workers
else
- run "cd #{current_path} && bundle exec rake n2:queue:restart_workers RAILS_ENV=#{rails_env}"
- run "cd #{current_path} && bundle exec rake n2:queue:restart_scheduler APP_NAME=#{application} RAILS_ENV=#{rails_env}"
+ run "cd #{release_path} && bundle exec rake n2:queue:restart_workers RAILS_ENV=#{rails_env}"
+ run "cd #{release_path} && bundle exec rake n2:queue:restart_scheduler APP_NAME=#{application} RAILS_ENV=#{rails_env}"
end
deploy.god.start
newrelic.notice_deployment
@@ -208,9 +212,9 @@
desc "Load the app skin if it exists"
task :load_skin, :roles => :app do
if skin_dir_exists? and skin_file_exists?
- run "ln -nfs /data/config/n2_sites/#{application}/app/stylesheets/skin.sass #{release_path}/app/stylesheets/skin.sass"
- run "rm -r #{release_path}/public/images/skin"
- run "ln -nfs /data/config/n2_sites/#{application}/public/images/skin #{release_path}/public/images/skin"
+ run "ln -nfs /data/config/n2_sites/#{application}/app/stylesheets/skin.sass #{release_path}/app/assets/stylesheets/skin.sass"
+ run "rm -r #{release_path}/app/assets/images/skin"
+ run "ln -nfs /data/config/n2_sites/#{application}/public/images/skin #{release_path}/app/assets/images/skin"
end
end
@@ -241,7 +245,7 @@
end
end
-begin
+=begin
Dir[File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', 'hoptoad_notifier-*')].each do |vendored_notifier|
$: << File.join(vendored_notifier, 'lib')
end
@@ -249,4 +253,4 @@
require 'hoptoad_notifier/capistrano'
rescue Exception => e
# puts "Error could not load hoptoad notifier: #{e}"
-end
+=end
View
2  config/deploy/recipes/config_wizard.rb
@@ -82,7 +82,7 @@
say_headline("\nSetting up rails directory structure..\n")
deploy.setup
say_headline("\nBootstrapping newscloud rails framework..\n")
- deploy.cold
+ deploy.cold_bootstrap
say_headline("\nCongragulations, your server #{settings[:app_name]}(#{settings[:base_url]}) is up and running!!\n")
end
View
2  config/initializers/resque.rb
@@ -15,7 +15,7 @@
Resque.redis = resque_config[rails_env]
APP_CONFIG['redis'] = resque_config[rails_env]
-app_name = Rails.root =~ %r(/([^/]+)/(current|release)) ? $1 : nil
+app_name = Rails.root.to_s =~ %r(/([^/]+)/(current|release)) ? $1 : nil
APP_CONFIG['namespace'] = app_name
Resque.redis.namespace = "resque:#{app_name}" if app_name
View
2  config/initializers/resque_connection_fix.rb
@@ -11,6 +11,7 @@
# From:
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/
+=begin
module ActiveRecord::ConnectionAdapters
class MysqlAdapter
alias_method :execute_without_retry, :execute
@@ -28,3 +29,4 @@ def execute(*args)
end
end
end
+=end
View
12 config/routes/main.rb
@@ -194,6 +194,7 @@
post :index
get :drafts
end
+ resources :flags
end
resources :cards do
@@ -215,7 +216,7 @@
get :my_items
end
resources :comments
- resources :fags
+ resources :flags
resources :related_items
end
@@ -250,11 +251,12 @@
get :my_events
post :my_events
end
-
+ resources :flags
end
resources :forums do
resources :topics
+ resources :flags
end
resources :galleries do
@@ -294,7 +296,10 @@
end
- resources :idea_boards
+ resources :idea_boards do
+ resources :ideas
+ end
+
resources :ideas do
collection do
get :index
@@ -366,6 +371,7 @@
get :index
post :index
end
+ resources :flags, :comments, :related_items
end
resources :questions do
View
8 lib/activerecord_model_extensions.rb
@@ -17,7 +17,7 @@ def item_klasses
def rankable_classes
#["Image", "PredictionGuess", "Question", "Idea", "Forum", "Event", "PredictionGroup", "IdeaBoard", "Video", "Url", "Gallery", "Resource", "Comment", "Audio", "Classified", "GalleryItem", "PredictionQuestion", "Feed", "Card", "Content", "ResourceSection", "Article", "Topic", "Answer"].map(&:constantize)
- ["PredictionGuess", "Question", "Idea", "Forum", "Event", "PredictionGroup", "IdeaBoard", "Gallery", "Resource", "Classified", "PredictionQuestion", "Card", "Content", "ResourceSection", "Article", "Topic", "Answer"].map(&:constantize)
+ ["PredictionGuess", "Question", "Idea", "Event", "PredictionGroup", "Gallery", "Resource", "Classified", "PredictionQuestion", "Content", "Article", "Topic", "Answer"].map(&:constantize)
end
def top_article_items limit = 100
@@ -27,6 +27,10 @@ def top_article_items limit = 100
end
def top_story_items(limit = 100, within_last_week = false)
+ # HACK ALERT
+ # This will return an ordered set of results based on number of votes and time since posting
+ # RAILS3 TODO
+ return self.order('created_at desc').limit(limit)
table = self.name.tableize
now = Time.now.utc.strftime("%Y-%m-%d %H:%M:%S")
if !within_last_week
@@ -178,7 +182,7 @@ def item_user
[:user, :author].each do |method|
return self.send(method) if self.respond_to?(method) and self.send(method).present?
end
- User.new
+ nil
end
# Breadcrumb parents method
View
24 lib/locale_extensions.rb
@@ -9,36 +9,28 @@ class Translation
I18nUtil.class_eval do
- # Create tanslation records from the YAML file. Will create the required locales if they do not exist.
+ # Create tanslation records from the YAML file. Will create the required locales if they do not exist.
def self.update_from_yml(file_name)
puts "Loading #{file_name}"
data = YAML::load(IO.read(file_name))
data.each do |code, translations|
- locale = I18n::Backend::Locale.find_or_create_by_code(code)
- backend = I18n::Backend::Simple.new
- keys = self.extract_i18n_keys(translations)
- keys.each do |key|
- value = backend.send(:lookup, code, key)
-
+ locale = I18n::Backend::Locale.find_by_code(code)
+ raise "Locale not found: #{code}" unless locale
+ translations_array = extract_translations_from_hash(translations)
+ translations_array.each do |key, value|
pluralization_index = 1
-
- if key.ends_with?('.one')
- key.gsub!('.one', '')
- end
-
+ key.gsub!('.one', '') if key.ends_with?('.one')
if key.ends_with?('.other')
key.gsub!('.other', '')
pluralization_index = 0
end
-
if value.is_a?(Array)
value.each_with_index do |v, index|
- create_translation(locale, "#{key}", index, v) unless v.nil?
+ create_translation(locale, key, index, v) unless v.nil?
end
else
create_translation_without_update(locale, key, pluralization_index, value)
end
-
end
end
end
@@ -48,7 +40,7 @@ def self.create_translation_without_update(locale, key, pluralization_index, val
translation = locale.translations.find_by_key_and_pluralization_index(Translation.hk(key), pluralization_index) # find existing record by hash key
unless translation # or build new one with raw key
translation = locale.translations.build(:key =>key, :pluralization_index => pluralization_index)
- puts "from yaml create translation for #{locale.code} : #{key} : #{pluralization_index}" unless RAILS_ENV['test']
+ puts "from yaml create translation for #{locale.code} : #{key} : #{pluralization_index}" unless Rails.env.test?
end
unless (translation.value.present? and translation.value != translation.raw_key)
translation.value = value

0 comments on commit 690c5f0

Please sign in to comment.
Something went wrong with that request. Please try again.