Skip to content

Commit

Permalink
Merge branch 'master' of github.com:joshsoftware/ideahub
Browse files Browse the repository at this point in the history
Conflicts:
	app/views/ideas/_idea.html.haml
  • Loading branch information
gautamrege committed Jul 13, 2012
2 parents f081e06 + f4f75ef commit 90bcf92
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 23 deletions.
6 changes: 6 additions & 0 deletions app/assets/javascripts/ideas.js.coffee
Expand Up @@ -5,6 +5,12 @@
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

$(document).ready ->
#Idea filteration according to category
$("h6 l").click ->
cat = $(this).html()
$(".idea-box").hide()
$("." + cat).show()

# Where there is change in the typeahead text box
$('#idea_category_ids').on 'change', (e) ->
add_category @
Expand Down
5 changes: 5 additions & 0 deletions app/assets/stylesheets/application.css.sass
Expand Up @@ -51,3 +51,8 @@ input.span8, .uneditable-input.span8
.row
margin-left: 0px !important

.marTop5
margin-top: 5px

.marTop10
margin-top: 10px
12 changes: 10 additions & 2 deletions app/assets/stylesheets/style.css.sass
Expand Up @@ -72,8 +72,10 @@ input.span8, .uneditable-input.span8

.idea-index
.grid
.categoriesNames
padding-left: 5px
.description
min-height: 150px
min-height: 140px
padding: 5px
span
display: block
Expand Down Expand Up @@ -139,7 +141,7 @@ input.span8, .uneditable-input.span8
margin-left: 55px
.detail
font-weight: bold
margin-left: 10px
margin: 10px
font-size: 12px
height: 25px
span
Expand All @@ -165,3 +167,9 @@ input.span8, .uneditable-input.span8
margin: -330px 0 0 -285px
width: 575px
text-align: center

div.floatLeft
float: left

div.floatRight
float: right
8 changes: 6 additions & 2 deletions app/helpers/ideas_helper.rb
Expand Up @@ -9,8 +9,12 @@ def display_categories(idea)
end

def participate_button(idea)
participant = idea.users.include?(current_user) ? 'Leave' : 'Participate'
link_to participant, participate_idea_path(idea), :class => 'participate btn btn-info', :remote => true
if user_signed_in?
participant = idea.users.include?(current_user) ? 'Leave' : 'Participate'
link_to participant, participate_idea_path(idea), :class => 'participate btn btn-info', :remote => true
else
link_to 'Participate', participate_idea_path(idea), :class => 'participate btn btn-info', onclick: "alert('You need to login to participate,you will be redirected to twitter authentication');window.location='/auth/twitter'; return false;"
end
end

def display_participants(idea)
Expand Down
6 changes: 4 additions & 2 deletions app/models/idea.rb
Expand Up @@ -8,11 +8,13 @@ class Idea < ActiveRecord::Base
has_many :categories, :through => :idea_categories

validates :user_id, :title, :original_desc, :presence => true
attr_accessible :title, :original_desc, :user_id, :category_ids, :github

attr_accessible :title, :original_desc, :user_id, :category_ids, :github, :description

before_save :format_description

delegate :name, to: :user, prefix: true

def format_description
self.description = RedCloth.new(original_desc, [:lite_mode]).to_html
end
Expand Down
23 changes: 17 additions & 6 deletions app/views/ideas/_idea.html.haml
Expand Up @@ -3,16 +3,17 @@
%h2{class: "title"}
= idea.title.truncate(20)
%i{class: "#{'favorite' if idea.users.include?(current_user)}"}
%h6= idea.categories.limit(2).collect{|c| content_tag(:l, c.name, :style => 'cursor:pointer') }.join(', ').html_safe or "Category"
%h6.categoriesNames
= idea.categories.empty? ? 'No Categories' : idea.categories.limit(2).collect{|c| content_tag(:l, c.name, :style => 'cursor:pointer') }.join(', ').html_safe
.description
%span= raw idea.description.truncate(140)
= link_to 'Overview', "#idea-detail-#{idea.id}", class: 'details btn btn-info', data: {toggle: 'modal'}
.detail
%span
.floatLeft
%i.icon-calendar>
= idea.schedules.last.try(:scheduled_at).try(:idea_date) or "soon"
|
%span
.floatLeft
%i.icon-user>
= idea.users.count
%span
Expand All @@ -23,9 +24,19 @@
%button{class: "close", data: {:dismiss => "modal"}} x
%h3= idea.title
.modal-body
%h6= idea.categories.collect(&:name).join(', ')
%h5= link_to idea.github, idea.github, target: '_blank'
%br/
%h5
Categories:
%h6
= idea.categories.collect(&:name).join(', ')
%h5
Github URL:
= link_to idea.github, idea.github, target: '_blank'
%h5.marTop10
Idea By:
%p
= idea.user_name
%h5.marTop10
Description
%p= raw idea.description
.modal-footer
= participate_button(idea)
Expand Down
6 changes: 0 additions & 6 deletions app/views/ideas/index.html.haml
@@ -1,8 +1,2 @@
.container.idea-index
= render @ideas, participate: true
:javascript
$('h6 l').click(function(){
cat = $(this).html();
$('.idea-box').hide();
$('.'+cat).show();
});
2 changes: 1 addition & 1 deletion app/views/ideas/participate.js.haml
@@ -1,4 +1,4 @@
$('#idea-#{@idea.id} .detail span:last').html("<i class='icon-user'></i> #{pluralize(@idea.users.count, 'participant')}")
$('#idea_count_#{@idea.id}').text("#{@idea.users.count}")
- if @participant
$('#idea-#{@idea.id} a.participate.btn').text('Participate')
$('#idea-#{@idea.id} a h2 i').removeClass('favorite')
Expand Down
27 changes: 23 additions & 4 deletions db/seeds.rb
Expand Up @@ -10,9 +10,28 @@
%w{Ruby Javascript Rails CMS CRM Testing Nodejs Gem Api }.collect { |c| { name: c } }
)

Setting.consumer_key = 'your twitter consumer key'
Setting.consumer_secret = 'your twitter consumer secret'
Setting.oauth_token = 'your twitter access token'
Setting.oauth_token_secret = 'your twitter access token secret'
Setting.consumer_key = 'your consumer key here'
Setting.consumer_secret = 'your consumer secret here.'
#Setting.oauth_token = 'your twitter access token'
#Setting.oauth_token_secret = 'your twitter access token secret'


5.times do |i|
User.create({name: "test#{i}", email: "test#{i}@testers.com", screen_name: "testers#{i}"})
end

10.times do |i|
idea = Idea.new({
title: "Idea title#{i}",
description: "a. A integer. Et? Est diam ridiculus mattis scelerisque, scelerisque cras, in ultricies? Ultricies sociis velit quis scelerisque sit scelerisque cum diam a odio adipiscing? Duis egestas et sociis. Nec sed porttitor, pulvinar eros integer a aenean sociis placerat? Elit aliquam. Quis quis cum sit in velit? Massa duis sociis mus porta? ",
github: 'http://github.com/something/#{i}',
original_desc: "a. A integer. Et? Est diam ridiculus mattis scelerisque, scelerisque cras, in ultricies? Ultricies sociis velit quis scelerisque sit scelerisque cum diam a odio adipiscing? Duis egestas et sociis. Nec sed porttitor, pulvinar eros integer a aenean sociis placerat? Elit aliquam. Quis quis cum sit in velit? Massa duis sociis mus porta? "
})
idea.user = User.all.shuffle.first
idea.save
end

20.times do |i|
## Randomly assign few categories to the few ideas.
IdeaCategory.create({idea_id: Idea.all.shuffle.first.id, category_id: Category.all.shuffle.first.id})
end

0 comments on commit 90bcf92

Please sign in to comment.