├── lib
├── tasks
│ ├── .gitkeep
│ └── cucumber.rake
└── assets
│ └── .gitkeep
├── app
├── mailers
│ ├── .gitkeep
│ └── user_mailer.rb
├── models
│ ├── .gitkeep
│ ├── spammer.rb
│ ├── admin_auth.rb
│ ├── data_set.rb
│ ├── notification.rb
│ ├── ability.rb
│ ├── comment.rb
│ ├── user.rb
│ └── post.rb
├── helpers
│ ├── admin_helper.rb
│ ├── posts_helper.rb
│ ├── comments_helper.rb
│ ├── content_helper.rb
│ └── application_helper.rb
├── views
│ ├── comments
│ │ ├── new.html.erb
│ │ ├── edit.html.erb
│ │ ├── _print.html.erb
│ │ ├── index.html.erb
│ │ ├── _form.html.erb
│ │ ├── _show.html.erb
│ │ └── show.html.erb
│ ├── posts
│ │ ├── edit.html.erb
│ │ ├── new.html.erb
│ │ ├── show.html.erb
│ │ ├── index.html.erb
│ │ ├── _form.html.erb
│ │ ├── _preview.html.erb
│ │ └── _print.html.erb
│ ├── user_mailer
│ │ ├── notify.text.erb
│ │ ├── receive.text.erb
│ │ ├── newsletter.text.erb
│ │ └── newsletter.html.erb
│ ├── admin
│ │ ├── spam.html.erb
│ │ └── mail.html.erb
│ ├── content
│ │ ├── stats.html.erb
│ │ ├── ask.html.erb
│ │ ├── new.html.erb
│ │ ├── frontpage.html.erb
│ │ ├── notifications.html.erb
│ │ ├── new.rss.builder
│ │ ├── ask.rss.builder
│ │ ├── frontpage.rss.builder
│ │ └── about.html.erb
│ ├── devise
│ │ ├── mailer
│ │ │ ├── confirmation_instructions.html.erb
│ │ │ ├── unlock_instructions.html.erb
│ │ │ └── reset_password_instructions.html.erb
│ │ ├── unlocks
│ │ │ └── new.html.erb
│ │ ├── passwords
│ │ │ ├── new.html.erb
│ │ │ └── edit.html.erb
│ │ ├── confirmations
│ │ │ └── new.html.erb
│ │ ├── sessions
│ │ │ └── new.html.erb
│ │ ├── registrations
│ │ │ ├── new.html.erb
│ │ │ └── edit.html.erb
│ │ └── _links.erb
│ ├── users
│ │ └── show.html.erb
│ └── layouts
│ │ └── application.html.erb
├── assets
│ ├── images
│ │ ├── info.png
│ │ ├── rss.png
│ │ ├── 57x57.png
│ │ ├── email.png
│ │ ├── rails.png
│ │ ├── hackful.png
│ │ └── email_alert.png
│ ├── stylesheets
│ │ ├── scaffolds.css.scss
│ │ ├── admin.css.scss
│ │ ├── posts.css.scss
│ │ ├── comments.css.scss
│ │ ├── content.css.scss
│ │ ├── application.css
│ │ └── layout.css.scss
│ └── javascripts
│ │ ├── voting.js
│ │ ├── admin.js.coffee
│ │ ├── comments.js.coffee
│ │ ├── content.js.coffee
│ │ ├── posts.js.coffee
│ │ └── application.js
└── controllers
│ ├── filter_controller.rb
│ ├── users_controller.rb
│ ├── api
│ ├── application_controller.rb
│ ├── basic_api.rb
│ └── v1
│ │ ├── users_controller.rb
│ │ ├── sessions_controller.rb
│ │ ├── comments_controller.rb
│ │ └── posts_controller.rb
│ ├── application_controller.rb
│ ├── admin_controller.rb
│ ├── content_controller.rb
│ ├── comments_controller.rb
│ └── posts_controller.rb
├── vendor
├── plugins
│ └── .gitkeep
└── assets
│ └── stylesheets
│ └── .gitkeep
├── .rspec
├── .gitignore
├── public
├── favicon.ico
├── robots.txt
├── 422.html
├── 404.html
└── 500.html
├── config.ru
├── features
├── step_definitions
│ ├── posts_steps.rb
│ ├── devise_steps.rb
│ └── shared_steps.rb
├── devise.feature
├── profile.feature
├── posts.feature
└── support
│ └── env.rb
├── db
├── migrate
│ ├── 20120429110752_add_viewers_to_posts.rb
│ ├── 20120224135606_create_admin_auths.rb
│ ├── 20120629140850_create_spammers.rb
│ ├── 20120219131606_add_authentication_token_to_users.rb
│ ├── 20120208103944_create_notifications.rb
│ ├── 20120128225717_create_posts.rb
│ ├── 20120128225733_create_comments.rb
│ ├── 20120307155241_create_data_sets.rb
│ ├── 20120129132752_create_make_voteable_tables.rb
│ ├── 20120226193229_create_delayed_jobs.rb
│ └── 20120128225324_devise_create_users.rb
├── seeds.rb
└── schema.rb
├── config
├── environment.rb
├── boot.rb
├── initializers
│ ├── mime_types.rb
│ ├── inflections.rb
│ ├── backtrace_silencers.rb
│ ├── session_store.rb
│ ├── wrap_parameters.rb
│ └── devise.rb
├── locales
│ ├── en.yml
│ └── devise.en.yml
├── database.yml
├── cucumber.yml
├── environments
│ ├── development.rb
│ ├── test.rb
│ └── production.rb
├── application.rb
└── routes.rb
├── spec
├── factories
│ ├── posts.rb
│ └── users.rb
├── support
│ └── controller_macros.rb
├── controllers
│ ├── admin_controller_spec.rb
│ └── posts_controller_spec.rb
└── spec_helper.rb
├── Rakefile
├── script
├── rails
└── cucumber
├── LICENSE
├── Gemfile
├── Guardfile
├── README.md
└── Gemfile.lock
/lib/tasks/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/mailers/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/models/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/lib/assets/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/vendor/plugins/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.rspec:
--------------------------------------------------------------------------------
1 | --colour
2 | --drb
3 |
--------------------------------------------------------------------------------
/vendor/assets/stylesheets/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/helpers/admin_helper.rb:
--------------------------------------------------------------------------------
1 | module AdminHelper
2 | end
3 |
--------------------------------------------------------------------------------
/app/helpers/posts_helper.rb:
--------------------------------------------------------------------------------
1 | module PostsHelper
2 | end
3 |
--------------------------------------------------------------------------------
/app/helpers/comments_helper.rb:
--------------------------------------------------------------------------------
1 | module CommentsHelper
2 | end
3 |
--------------------------------------------------------------------------------
/app/helpers/content_helper.rb:
--------------------------------------------------------------------------------
1 | module ContentHelper
2 | end
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | config/initializers/secret_token.rb
3 | log/
4 | tmp/
--------------------------------------------------------------------------------
/app/views/comments/new.html.erb:
--------------------------------------------------------------------------------
1 |
New comment
2 |
3 | <%= render 'form' %>
4 |
--------------------------------------------------------------------------------
/app/views/posts/edit.html.erb:
--------------------------------------------------------------------------------
1 | Editing post
2 |
3 | <%= render 'form' %>
4 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/8bitpal/hackful/HEAD/public/favicon.ico
--------------------------------------------------------------------------------
/app/models/spammer.rb:
--------------------------------------------------------------------------------
1 | class Spammer < ActiveRecord::Base
2 | belongs_to :user
3 | end
4 |
--------------------------------------------------------------------------------
/app/views/comments/edit.html.erb:
--------------------------------------------------------------------------------
1 | Editing comment
2 |
3 | <%= render 'form' %>
4 |
--------------------------------------------------------------------------------
/app/models/admin_auth.rb:
--------------------------------------------------------------------------------
1 | class AdminAuth < ActiveRecord::Base
2 | belongs_to :user
3 | end
4 |
--------------------------------------------------------------------------------
/app/assets/images/info.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/8bitpal/hackful/HEAD/app/assets/images/info.png
--------------------------------------------------------------------------------
/app/assets/images/rss.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/8bitpal/hackful/HEAD/app/assets/images/rss.png
--------------------------------------------------------------------------------
/app/assets/images/57x57.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/8bitpal/hackful/HEAD/app/assets/images/57x57.png
--------------------------------------------------------------------------------
/app/assets/images/email.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/8bitpal/hackful/HEAD/app/assets/images/email.png
--------------------------------------------------------------------------------
/app/assets/images/rails.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/8bitpal/hackful/HEAD/app/assets/images/rails.png
--------------------------------------------------------------------------------
/config.ru:
--------------------------------------------------------------------------------
1 | require ::File.expand_path('../config/environment', __FILE__)
2 | run Hackful::Application
3 |
--------------------------------------------------------------------------------
/app/assets/images/hackful.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/8bitpal/hackful/HEAD/app/assets/images/hackful.png
--------------------------------------------------------------------------------
/app/assets/images/email_alert.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/8bitpal/hackful/HEAD/app/assets/images/email_alert.png
--------------------------------------------------------------------------------
/app/views/posts/new.html.erb:
--------------------------------------------------------------------------------
1 | New post
2 |
3 | <%= render 'form' %>
4 |
5 | <%= link_to 'Back', posts_path %>
6 |
--------------------------------------------------------------------------------
/app/views/user_mailer/notify.text.erb:
--------------------------------------------------------------------------------
1 | UserMailer#notify
2 |
3 | <%= @greeting %>, find me in app/views/app/views/user_mailer/notify.text.erb
4 |
--------------------------------------------------------------------------------
/app/views/user_mailer/receive.text.erb:
--------------------------------------------------------------------------------
1 | UserMailer#receive
2 |
3 | <%= @greeting %>, find me in app/views/app/views/user_mailer/receive.text.erb
4 |
--------------------------------------------------------------------------------
/features/step_definitions/posts_steps.rb:
--------------------------------------------------------------------------------
1 | When /^I fill in "([^"]*)" with "([^"]*)"$/ do |field, text|
2 | fill_in field, with: text
3 | end
4 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/scaffolds.css.scss:
--------------------------------------------------------------------------------
1 | a {
2 | color: #000;
3 | &:visited {
4 | color: #666; }
5 | &:hover {
6 | color: #000; } }
7 |
--------------------------------------------------------------------------------
/app/views/user_mailer/newsletter.text.erb:
--------------------------------------------------------------------------------
1 | Hi <%= @user.name %>.
2 |
3 | <%= @text %>
4 |
5 | ------------
6 | Hackful Europe
7 | http://hackful.com
8 |
--------------------------------------------------------------------------------
/app/views/admin/spam.html.erb:
--------------------------------------------------------------------------------
1 | <%= form_tag "/admin/save_spam_settings" do %>
2 | <%= text_area_tag :spammers %>
3 | <%= submit_tag "Submit" %>
4 | <% end %>
--------------------------------------------------------------------------------
/app/assets/javascripts/voting.js:
--------------------------------------------------------------------------------
1 | function vote_up(id, type) {
2 | $.ajax('/'+type+'/'+id+'/vote_up');
3 | $("#"+type+"_"+id).toggleClass("vote voted");
4 | }
5 |
--------------------------------------------------------------------------------
/app/views/content/stats.html.erb:
--------------------------------------------------------------------------------
1 | Statistics
2 |
3 | Comments per day
4 |
5 | Posts per day
6 |
7 | Average Comments per post
8 |
9 |
--------------------------------------------------------------------------------
/app/views/user_mailer/newsletter.html.erb:
--------------------------------------------------------------------------------
1 | Hi <%= @user.name %>.
2 |
3 | <%= markdown(@text) %>
4 |
5 | ------------
6 | Hackful Europe
7 | http://hackful.com
8 |
--------------------------------------------------------------------------------
/db/migrate/20120429110752_add_viewers_to_posts.rb:
--------------------------------------------------------------------------------
1 | class AddViewersToPosts < ActiveRecord::Migration
2 | def change
3 | add_column :posts, :viewers, :integer
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/app/views/posts/show.html.erb:
--------------------------------------------------------------------------------
1 | <%= render :partial => "posts/print", :locals => { post: @post } %>
2 |
3 | <%= render :partial => "comments/print", :locals => { commentable: @post } %>
4 |
5 |
--------------------------------------------------------------------------------
/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the rails application
2 | require File.expand_path('../application', __FILE__)
3 |
4 | # Initialize the rails application
5 | Hackful::Application.initialize!
6 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/admin.css.scss:
--------------------------------------------------------------------------------
1 | // Place all the styles related to the Admin controller here.
2 | // They will automatically be included in application.css.
3 | // You can use Sass (SCSS) here: http://sass-lang.com/
4 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/posts.css.scss:
--------------------------------------------------------------------------------
1 | // Place all the styles related to the Posts controller here.
2 | // They will automatically be included in application.css.
3 | // You can use Sass (SCSS) here: http://sass-lang.com/
4 |
--------------------------------------------------------------------------------
/app/models/data_set.rb:
--------------------------------------------------------------------------------
1 | class DataSet < ActiveRecord::Base
2 | #Initial table structure, could be changed in favor of more dynamic structure
3 |
4 | attr_accessible :contact_me, :user_id
5 |
6 | belongs_to :user
7 | end
8 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/comments.css.scss:
--------------------------------------------------------------------------------
1 | // Place all the styles related to the Comments controller here.
2 | // They will automatically be included in application.css.
3 | // You can use Sass (SCSS) here: http://sass-lang.com/
4 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/content.css.scss:
--------------------------------------------------------------------------------
1 | // Place all the styles related to the Content controller here.
2 | // They will automatically be included in application.css.
3 | // You can use Sass (SCSS) here: http://sass-lang.com/
4 |
--------------------------------------------------------------------------------
/config/boot.rb:
--------------------------------------------------------------------------------
1 | require 'rubygems'
2 |
3 | # Set up gems listed in the Gemfile.
4 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
5 |
6 | require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
7 |
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2 | #
3 | # To ban all spiders from the entire site uncomment the next two lines:
4 | # User-Agent: *
5 | # Disallow: /
6 |
--------------------------------------------------------------------------------
/config/initializers/mime_types.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new mime types for use in respond_to blocks:
4 | # Mime::Type.register "text/richtext", :rtf
5 | # Mime::Type.register_alias "text/html", :iphone
6 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Sample localization file for English. Add more files in this directory for other locales.
2 | # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3 |
4 | en:
5 | hello: "Hello world"
6 |
--------------------------------------------------------------------------------
/app/models/notification.rb:
--------------------------------------------------------------------------------
1 | class Notification < ActiveRecord::Base
2 | belongs_to :alerted, :polymorphic => true
3 | belongs_to :alertable, :polymorphic => true
4 |
5 | attr_accessible :alertable_type, :alertable_id, :user_id, :alerted_type, :alerted_id
6 | end
7 |
--------------------------------------------------------------------------------
/spec/factories/posts.rb:
--------------------------------------------------------------------------------
1 | FactoryGirl.define do
2 | factory :post do
3 | title { FactoryGirl.generate :unique_user_name }
4 | text { Faker::Internet.email }
5 | link { "http://#{Faker::Internet.domain_name}/#{Faker::Internet.domain_word}" }
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/spec/support/controller_macros.rb:
--------------------------------------------------------------------------------
1 | module ControllerMacros
2 | def login_user
3 | before(:each) do
4 | @request.env["devise.mapping"] = Devise.mappings[:user]
5 | user = Factory.create(:user)
6 | sign_in user
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/app/assets/javascripts/admin.js.coffee:
--------------------------------------------------------------------------------
1 | # Place all the behaviors and hooks related to the matching controller here.
2 | # All this logic will automatically be available in application.js.
3 | # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
4 |
--------------------------------------------------------------------------------
/app/assets/javascripts/comments.js.coffee:
--------------------------------------------------------------------------------
1 | # Place all the behaviors and hooks related to the matching controller here.
2 | # All this logic will automatically be available in application.js.
3 | # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
4 |
--------------------------------------------------------------------------------
/app/assets/javascripts/content.js.coffee:
--------------------------------------------------------------------------------
1 | # Place all the behaviors and hooks related to the matching controller here.
2 | # All this logic will automatically be available in application.js.
3 | # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
4 |
--------------------------------------------------------------------------------
/app/assets/javascripts/posts.js.coffee:
--------------------------------------------------------------------------------
1 | # Place all the behaviors and hooks related to the matching controller here.
2 | # All this logic will automatically be available in application.js.
3 | # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
4 |
--------------------------------------------------------------------------------
/app/views/admin/mail.html.erb:
--------------------------------------------------------------------------------
1 | Mails
2 |
3 | <%= form_tag "/admin/send_newsletter" do %>
4 | Test run <%= check_box_tag "test" %>
5 | <%= text_field_tag :subject %>
6 | <%= text_area_tag :text %>
7 | <%= submit_tag "Send" %>
8 | <% end %>
9 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env rake
2 | # Add your own tasks in files placed in lib/tasks ending in .rake,
3 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4 |
5 | require File.expand_path('../config/application', __FILE__)
6 |
7 | Hackful::Application.load_tasks
8 |
--------------------------------------------------------------------------------
/app/views/devise/mailer/confirmation_instructions.html.erb:
--------------------------------------------------------------------------------
1 | Welcome <%= @resource.email %>!
2 |
3 | You can confirm your account email through the link below:
4 |
5 | <%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %>
6 |
--------------------------------------------------------------------------------
/db/migrate/20120224135606_create_admin_auths.rb:
--------------------------------------------------------------------------------
1 | class CreateAdminAuths < ActiveRecord::Migration
2 | def change
3 | create_table :admin_auths do |t|
4 | t.integer :user_id
5 | t.string :resource
6 | t.string :action
7 |
8 | t.timestamps
9 | end
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/db/migrate/20120629140850_create_spammers.rb:
--------------------------------------------------------------------------------
1 | class CreateSpammers < ActiveRecord::Migration
2 | def change
3 | create_table :spammers do |t|
4 | t.references :user
5 | t.string :reason
6 |
7 | t.timestamps
8 | end
9 | add_index :spammers, :user_id
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/db/migrate/20120219131606_add_authentication_token_to_users.rb:
--------------------------------------------------------------------------------
1 | class AddAuthenticationTokenToUsers < ActiveRecord::Migration
2 | def change
3 | change_table :users do |t|
4 | t.string :authentication_token
5 | end
6 |
7 | add_index :users, :authentication_token, :unique => true
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/script/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3 |
4 | APP_PATH = File.expand_path('../../config/application', __FILE__)
5 | require File.expand_path('../../config/boot', __FILE__)
6 | require 'rails/commands'
7 |
--------------------------------------------------------------------------------
/app/views/comments/_print.html.erb:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/app/controllers/filter_controller.rb:
--------------------------------------------------------------------------------
1 | class FilterController < ApplicationController
2 | check_authorization
3 | load_and_authorize_resource
4 |
5 | rescue_from CanCan::AccessDenied do |exception|
6 | flash[:error] = exception.message
7 | session[:user_return_to] = request.url
8 | redirect_to new_user_session_path
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/script/cucumber:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
4 | if vendored_cucumber_bin
5 | load File.expand_path(vendored_cucumber_bin)
6 | else
7 | require 'rubygems' unless ENV['NO_RUBYGEMS']
8 | require 'cucumber'
9 | load Cucumber::BINARY
10 | end
11 |
--------------------------------------------------------------------------------
/app/views/devise/mailer/unlock_instructions.html.erb:
--------------------------------------------------------------------------------
1 | Hello <%= @resource.email %>!
2 |
3 | Your account has been locked due to an excessive amount of unsuccessful sign in attempts.
4 |
5 | Click the link below to unlock your account:
6 |
7 | <%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %>
8 |
--------------------------------------------------------------------------------
/spec/factories/users.rb:
--------------------------------------------------------------------------------
1 | FactoryGirl.define do
2 | sequence :unique_user_name do |n|
3 | Faker::Internet.user_name.delete('^a-zA-Z') + "#{n}"
4 | end
5 | factory :user do
6 | name { FactoryGirl.generate :unique_user_name }
7 | email { Faker::Internet.email }
8 | password "testing"
9 | password_confirmation "testing"
10 | end
11 | end
12 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/application.css:
--------------------------------------------------------------------------------
1 | /*
2 | * This is a manifest file that'll automatically include all the stylesheets available in this directory
3 | * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4 | * the top of the compiled file, but it's generally better to create a new file per style scope.
5 | *= require_self
6 | *= require_tree .
7 | */
--------------------------------------------------------------------------------
/db/migrate/20120208103944_create_notifications.rb:
--------------------------------------------------------------------------------
1 | class CreateNotifications < ActiveRecord::Migration
2 | def change
3 | create_table :notifications do |t|
4 | t.integer :user_id
5 | t.boolean :unread, :default => true
6 | t.references :alerted, :polymorphic => true
7 | t.references :alertable, :polymorphic => true
8 |
9 | t.timestamps
10 | end
11 | end
12 | end
13 |
--------------------------------------------------------------------------------
/db/migrate/20120128225717_create_posts.rb:
--------------------------------------------------------------------------------
1 | class CreatePosts < ActiveRecord::Migration
2 | def change
3 | create_table :posts do |t|
4 | t.integer :user_id
5 | t.string :title
6 | t.text :text
7 | t.text :link
8 | t.integer :up_votes, :null => false, :default => 0
9 | t.integer :down_votes, :null => false, :default => 0
10 |
11 | t.timestamps
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/app/views/devise/unlocks/new.html.erb:
--------------------------------------------------------------------------------
1 | Resend unlock instructions
2 |
3 | <%= form_for(resource, :as => resource_name, :url => unlock_path(resource_name), :html => { :method => :post }) do |f| %>
4 | <%= devise_error_messages! %>
5 |
6 | <%= f.label :email %>
7 | <%= f.email_field :email %>
8 |
9 | <%= f.submit "Resend unlock instructions" %>
10 | <% end %>
11 |
12 | <%= render "links" %>
--------------------------------------------------------------------------------
/app/views/devise/passwords/new.html.erb:
--------------------------------------------------------------------------------
1 | Forgot your password?
2 |
3 | <%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
4 | <%= devise_error_messages! %>
5 |
6 | <%= f.label :email %>
7 | <%= f.email_field :email %>
8 |
9 | <%= f.submit "Send me reset password instructions" %>
10 | <% end %>
11 |
12 | <%= render "links" %>
--------------------------------------------------------------------------------
/app/views/users/show.html.erb:
--------------------------------------------------------------------------------
1 | <%= @user.name %>'s profile:
2 |
3 | Submitted Stories: <%= @user.posts.count %>
4 |
5 | <% @posts.each do |post| %>
6 | <%= render partial: "posts/preview", locals: { post: post } %>
7 | <% end %>
8 |
9 | <%= link_to("< previous", "/?page="+(@page.to_i-1).to_s) if @page > 0 %> <%= link_to("next >", "/?page="+(@page.to_i+1).to_s) if @posts.count > 19 %>
--------------------------------------------------------------------------------
/db/migrate/20120128225733_create_comments.rb:
--------------------------------------------------------------------------------
1 | class CreateComments < ActiveRecord::Migration
2 | def change
3 | create_table :comments do |t|
4 | t.integer :user_id
5 | t.text :text
6 | t.references :commentable, :polymorphic => true
7 | t.integer :up_votes, :null => false, :default => 0
8 | t.integer :down_votes, :null => false, :default => 0
9 |
10 | t.timestamps
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | #this works on Ubuntu Linux, change for your OS.
2 | development:
3 | adapter: mysql2
4 | encoding: utf8
5 | database: hackful
6 | username: root
7 | password:
8 | socket: /var/run/mysqld/mysqld.sock
9 |
10 | test: &test
11 | adapter: mysql2
12 | encoding: utf8
13 | database: hackful_test
14 | username: root
15 | password:
16 | socket: /var/run/mysqld/mysqld.sock
17 |
18 | cucumber:
19 | <<: *test
20 |
--------------------------------------------------------------------------------
/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format
4 | # (all these examples are active by default):
5 | # ActiveSupport::Inflector.inflections do |inflect|
6 | # inflect.plural /^(ox)$/i, '\1en'
7 | # inflect.singular /^(ox)en/i, '\1'
8 | # inflect.irregular 'person', 'people'
9 | # inflect.uncountable %w( fish sheep )
10 | # end
11 |
--------------------------------------------------------------------------------
/db/migrate/20120307155241_create_data_sets.rb:
--------------------------------------------------------------------------------
1 | class CreateDataSets < ActiveRecord::Migration
2 | def change
3 | create_table :data_sets do |t|
4 | t.integer :user_id
5 | t.boolean :contact_me, default: true
6 | t.string :twitter
7 | t.string :github
8 | t.string :linkedin
9 | t.string :url
10 | t.string :blog
11 | t.text :about_me
12 |
13 | t.timestamps
14 | end
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/app/views/devise/confirmations/new.html.erb:
--------------------------------------------------------------------------------
1 | Resend confirmation instructions
2 |
3 | <%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
4 | <%= devise_error_messages! %>
5 |
6 | <%= f.label :email %>
7 | <%= f.email_field :email %>
8 |
9 | <%= f.submit "Resend confirmation instructions" %>
10 | <% end %>
11 |
12 | <%= render "links" %>
--------------------------------------------------------------------------------
/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5 |
6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7 | # Rails.backtrace_cleaner.remove_silencers!
8 |
--------------------------------------------------------------------------------
/db/seeds.rb:
--------------------------------------------------------------------------------
1 | # This file should contain all the record creation needed to seed the database with its default values.
2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3 | #
4 | # Examples:
5 | #
6 | # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
7 | # Mayor.create(:name => 'Emanuel', :city => cities.first)
8 |
9 | User.all.each do |user|
10 | DataSet.create(user_id: user.id)
11 | end
--------------------------------------------------------------------------------
/config/initializers/session_store.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | Hackful::Application.config.session_store :cookie_store, :key => '_hackful_session'
4 |
5 | # Use the database for sessions instead of the cookie-based default,
6 | # which shouldn't be used to store highly confidential information
7 | # (create the session table with "rails generate session_migration")
8 | # Hackful::Application.config.session_store :active_record_store
9 |
--------------------------------------------------------------------------------
/app/views/content/ask.html.erb:
--------------------------------------------------------------------------------
1 | <% content_for :head do %>
2 | <%= auto_discovery_link_tag :rss, "/ask.rss" %>
3 | <% end %>
4 |
5 | <% @posts.each do |post| %>
6 | <%= render partial: "posts/preview", locals: { post: post } if can? :see, post %>
7 | <% end %>
8 |
9 | <%= link_to("< previous", "/ask?page="+(@page.to_i-1).to_s) if @page > 1 %> <%= link_to("next >", "/ask?page="+(@page.to_i+1).to_s) if @show_next_link %>
10 |
--------------------------------------------------------------------------------
/app/views/content/new.html.erb:
--------------------------------------------------------------------------------
1 | <% content_for :head do %>
2 | <%= auto_discovery_link_tag :rss, "/new.rss" %>
3 | <% end %>
4 |
5 | <% @posts.each do |post| %>
6 | <%= render partial: "posts/preview", locals: { post: post } if can? :see, post %>
7 | <% end %>
8 |
9 | <%= link_to("< previous", "/new?page="+(@page.to_i-1).to_s) if @page > 1 %> <%= link_to("next >", "/new?page="+(@page.to_i+1).to_s) if @show_next_link %>
10 |
--------------------------------------------------------------------------------
/app/views/content/frontpage.html.erb:
--------------------------------------------------------------------------------
1 | <% content_for :head do %>
2 | <%= auto_discovery_link_tag :rss, "/frontpage.rss" %>
3 | <% end %>
4 |
5 | <% @posts.each do |post| %>
6 | <%= render partial: "posts/preview", locals: { post: post } if can? :see, post %>
7 | <% end %>
8 |
9 | <%= link_to("< previous", "/?page="+(@page.to_i-1).to_s) if @page > 1 %> <%= link_to("next >", "/?page="+(@page.to_i+1).to_s) if @show_next_link %>
10 |
--------------------------------------------------------------------------------
/app/controllers/users_controller.rb:
--------------------------------------------------------------------------------
1 | class UsersController < ApplicationController
2 |
3 | def show
4 | @user = User.find_by_name(params[:name].to_s)
5 |
6 | params[:page].nil? ? @page = 0 : @page = params[:page].to_i
7 | @posts = Post.find_by_sql ["SELECT * FROM posts WHERE user_id = #{@user.id} ORDER BY ((posts.up_votes - posts.down_votes) -1 )/POW((((UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(posts.created_at)) / 3600 )+2), 1.5) DESC LIMIT ?, 20", (@page*20)]
8 | end
9 |
10 | end
--------------------------------------------------------------------------------
/app/views/devise/mailer/reset_password_instructions.html.erb:
--------------------------------------------------------------------------------
1 | Hello <%= @resource.email %>!
2 |
3 | Someone has requested a link to change your password, and you can do this through the link below.
4 |
5 | <%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %>
6 |
7 | If you didn't request this, please ignore this email.
8 | Your password won't change until you access the link above and create a new one.
9 |
--------------------------------------------------------------------------------
/config/cucumber.yml:
--------------------------------------------------------------------------------
1 | <%
2 | rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3 | rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4 | std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
5 | %>
6 | default: --drb <%= std_opts %> features
7 | wip: --drb --tags @wip:3 --wip features
8 | rerun: --drb <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
9 |
--------------------------------------------------------------------------------
/app/assets/javascripts/application.js:
--------------------------------------------------------------------------------
1 | // This is a manifest file that'll be compiled into including all the files listed below.
2 | // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3 | // be included in the compiled file accessible from http://example.com/assets/application.js
4 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5 | // the compiled file.
6 | //
7 | //= require jquery
8 | //= require jquery_ujs
9 | //= require_tree .
10 |
11 |
--------------------------------------------------------------------------------
/app/helpers/application_helper.rb:
--------------------------------------------------------------------------------
1 | module ApplicationHelper
2 | def comment_count(object)
3 | count = object.comments.count
4 | object.comments.each do |comment|
5 | count += comment_count(comment)
6 | end
7 | count
8 | end
9 |
10 | def markdown(text, *options)
11 | require 'rdiscount'
12 |
13 | text = sanitize(text) unless text.html_safe? || options.delete(:safe)
14 | (text.blank? ? "" : RDiscount.new(text, :filter_html, :autolink ).to_html.gsub(/(?\1').html_safe)
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/config/initializers/wrap_parameters.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 | #
3 | # This file contains settings for ActionController::ParamsWrapper which
4 | # is enabled by default.
5 |
6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7 | ActiveSupport.on_load(:action_controller) do
8 | wrap_parameters :format => [:json]
9 | end
10 |
11 | # Disable root element in JSON by default.
12 | ActiveSupport.on_load(:active_record) do
13 | self.include_root_in_json = false
14 | end
15 |
--------------------------------------------------------------------------------
/app/views/devise/sessions/new.html.erb:
--------------------------------------------------------------------------------
1 | Sign in
2 |
3 | <%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
4 | <%= f.label :email %>
5 | <%= f.email_field :email %>
6 |
7 | <%= f.label :password %>
8 | <%= f.password_field :password %>
9 |
10 | <% if devise_mapping.rememberable? -%>
11 | <%= f.check_box :remember_me %> <%= f.label :remember_me %>
12 | <% end -%>
13 |
14 | <%= f.submit "Sign in" %>
15 | <% end %>
16 |
17 | <%= render "links" %>
--------------------------------------------------------------------------------
/app/views/posts/index.html.erb:
--------------------------------------------------------------------------------
1 | Listing posts
2 |
3 |
4 |
5 | | User |
6 | Text |
7 | |
8 | |
9 | |
10 |
11 |
12 | <% @posts.each do |post| %>
13 |
14 | | <%= post.user_id %> |
15 | <%= post.text %> |
16 | <%= link_to 'Show', post %> |
17 | <%= link_to 'Edit', edit_post_path(post) %> |
18 | <%= link_to 'Destroy', post, :confirm => 'Are you sure?', :method => :delete %> |
19 |
20 | <% end %>
21 |
22 |
23 |
24 |
25 | <%= link_to 'New Post', new_post_path %>
26 |
--------------------------------------------------------------------------------
/app/controllers/api/application_controller.rb:
--------------------------------------------------------------------------------
1 | class Api::ApplicationController < ApplicationController
2 | include BasicApi
3 |
4 | respond_to :json
5 |
6 | before_filter :set_format
7 |
8 | rescue_from Exception do |exception| internal_server_error(exception) end
9 | rescue_from ActionController::UnknownAction, :with => :unknown_action
10 | rescue_from ActionController::RoutingError, :with => :route_not_found
11 | rescue_from ActiveRecord::RecordNotFound, with: :not_found
12 | rescue_from Api::BasicApi::NotLogedIn, with: :not_loged_in
13 | rescue_from Api::BasicApi::NoParameter, with: :no_parameter_found
14 |
15 | end
--------------------------------------------------------------------------------
/app/views/devise/passwords/edit.html.erb:
--------------------------------------------------------------------------------
1 | Change your password
2 |
3 | <%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
4 | <%= devise_error_messages! %>
5 | <%= f.hidden_field :reset_password_token %>
6 |
7 | <%= f.label :password, "New password" %>
8 | <%= f.password_field :password %>
9 |
10 | <%= f.label :password_confirmation, "Confirm new password" %>
11 | <%= f.password_field :password_confirmation %>
12 |
13 | <%= f.submit "Change my password" %>
14 | <% end %>
15 |
16 | <%= render "links" %>
--------------------------------------------------------------------------------
/app/views/comments/index.html.erb:
--------------------------------------------------------------------------------
1 | Listing comments
2 |
3 |
4 |
5 | | User |
6 | Text |
7 | |
8 | |
9 | |
10 |
11 |
12 | <% @comments.each do |comment| %>
13 |
14 | | <%= comment.user_id %> |
15 | <%= comment.text %> |
16 | <%= link_to 'Show', comment %> |
17 | <%= link_to 'Edit', edit_comment_path(comment) %> |
18 | <%= link_to 'Destroy', comment, :confirm => 'Are you sure?', :method => :delete %> |
19 |
20 | <% end %>
21 |
22 |
23 |
24 |
25 | <%= link_to 'New Comment', new_comment_path %>
26 |
--------------------------------------------------------------------------------
/app/controllers/application_controller.rb:
--------------------------------------------------------------------------------
1 | class ApplicationController < ActionController::Base
2 | protect_from_forgery
3 |
4 | before_filter :meta_defaults
5 |
6 | def meta_defaults
7 | @title = ""
8 | @meta_keywords = "Europe, Startups, Entrepreneurs"
9 | @meta_description = "Hackful Europe is a place for European entrepreneurs to share demos, stories or ask questions."
10 | end
11 |
12 | def after_sign_out_path_for(resource)
13 | super
14 | end
15 |
16 | def after_sign_in_path_for(resource)
17 | super
18 | end
19 |
20 | def page_number(page = nil)
21 | page.nil? ? page = 1 : page = page.to_i
22 | return page
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/app/views/devise/registrations/new.html.erb:
--------------------------------------------------------------------------------
1 | Sign up
2 |
3 | <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
4 | <%= devise_error_messages! %>
5 |
6 | <%= f.label :name, "User Name" %>
7 | <%= f.text_field :name %>
8 |
9 | <%= f.label :email %>
10 | <%= f.email_field :email %>
11 |
12 | <%= f.label :password %>
13 | <%= f.password_field :password %>
14 |
15 | <%= f.label :password_confirmation %>
16 | <%= f.password_field :password_confirmation %>
17 |
18 | <%= f.submit "Sign up" %>
19 | <% end %>
20 |
21 | <%= render "links" %>
22 |
--------------------------------------------------------------------------------
/features/step_definitions/devise_steps.rb:
--------------------------------------------------------------------------------
1 | When /^I fill in new user details$/ do
2 | within(".body") do
3 | fill_in 'User Name', with: 'pbjorklund'
4 | fill_in 'Email', with: 'p.bjorklund@gmail.com'
5 | fill_in 'Password', :with => 'password'
6 | fill_in 'Password confirmation', :with => 'password'
7 | end
8 | click_button "Sign up"
9 | end
10 |
11 | When /^I fill in my user details$/ do
12 | within(".body") do
13 | fill_in 'User Name', with: 'pbjorklund'
14 | fill_in 'Email', with: 'p.bjorklund@gmail.com'
15 | fill_in 'Password', :with => 'password'
16 | fill_in 'Password confirmation', :with => 'password'
17 | end
18 | click_button "Sign up"
19 | end
20 |
--------------------------------------------------------------------------------
/app/models/ability.rb:
--------------------------------------------------------------------------------
1 | class Ability
2 | include CanCan::Ability
3 |
4 | def initialize(user)
5 | user ||= User.new
6 | can :see, Post do |post|
7 | if !post.user.nil? && post.user.is_spammer? && post.user.id != user.id
8 | false
9 | else
10 | true
11 | end
12 | end
13 | unless user.id.nil?
14 | can [:read, :create, :vote_up, :vote_down], [Post, Comment]
15 | can [:update, :destroy], [Post, Comment], :user_id => user.id
16 |
17 | user.admin_auths.each do |auth|
18 | (defined?(auth.resource.upcase) == "constant") ? (can auth.action.to_sym, auth.resource.constantize) : (can auth.action.to_sym, auth.resource.to_sym)
19 | end
20 | end
21 | can [:read], :all
22 | can :create, User
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/public/422.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The change you wanted was rejected (422)
5 |
17 |
18 |
19 |
20 |
21 |
22 |
The change you wanted was rejected.
23 |
Maybe you tried to change something you didn't have access to.
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/controllers/admin_controller.rb:
--------------------------------------------------------------------------------
1 | class AdminController < ApplicationController
2 | authorize_resource :class => false
3 |
4 | def mail
5 |
6 | end
7 |
8 | def send_newsletter
9 | if user_signed_in?
10 | unless params[:test]
11 | User.all.each do |user|
12 | UserMailer.delay.newsletter(user, params[:subject], params[:text])
13 | end
14 | else
15 | UserMailer.delay.newsletter(current_user, params[:subject], params[:text])
16 | end
17 | redirect_to "/admin/mail", notice: "Mail sent"
18 | end
19 | end
20 |
21 | def spam
22 |
23 | end
24 |
25 | def save_spam_settings
26 | @spammers = JSON(params[:spammers])
27 | @spammers.each do |spammer|
28 | Spammer.create(user_id: User.find_by_name(spammer["name"]).id, reason: spammer["reason"])
29 | end
30 | end
31 |
32 | end
33 |
--------------------------------------------------------------------------------
/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The page you were looking for doesn't exist (404)
5 |
17 |
18 |
19 |
20 |
21 |
22 |
The page you were looking for doesn't exist.
23 |
You may have mistyped the address or the page may have moved.
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/public/500.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | We're sorry, but something went wrong (500)
5 |
17 |
18 |
19 |
20 |
21 |
22 |
We're sorry, but something went wrong.
23 |
We've been notified about this issue and we'll take a look at it shortly.
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/views/posts/_form.html.erb:
--------------------------------------------------------------------------------
1 | <%= form_for(@post) do |f| %>
2 | <% if @post.errors.any? %>
3 |
4 |
<%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:
5 |
6 |
7 | <% @post.errors.full_messages.each do |msg| %>
8 | - <%= msg %>
9 | <% end %>
10 |
11 |
12 | <% end %>
13 |
14 |
15 | <%= f.label :title %>
16 | <%= f.text_field :title %>
17 |
18 |
19 |
20 | <%= f.label :text %>
21 | <%= f.text_area :text %>
22 |
23 |
24 |
25 | <%= f.label :link %>
26 | <%= f.text_field :link %>
27 |
28 |
29 | <%= f.submit %>
30 |
31 | <% end %>
32 |
--------------------------------------------------------------------------------
/features/devise.feature:
--------------------------------------------------------------------------------
1 | Feature: User authentication
2 |
3 | As a user
4 | To submit, vote and post news items
5 | I want to be able to sign in
6 |
7 | Scenario: Sign up
8 | #Issue :
9 | #Given I am not authenticated
10 | Given I am on the startpage
11 | When I click "Sign in"
12 | And I click "Sign up"
13 | And I fill in new user details
14 | Then I should see "Welcome! You have signed up successfully."
15 |
16 | Scenario: Sign in
17 | Given I am a new authenticated user
18 | Then I should see "Signed in"
19 |
20 | #Issue :
21 | #Scenario: Sign out
22 | # Given I am a new authenticated user
23 | # When I click "Sign out"
24 | # Then I should see "Signed out successfully."
25 |
26 | Scenario: Sign out
27 | Given I am a new authenticated user
28 | When I click "Sign out"
29 | Then I should see "Signed out successfully."
30 |
31 |
--------------------------------------------------------------------------------
/app/views/content/notifications.html.erb:
--------------------------------------------------------------------------------
1 | Notifications
2 | <% @new_notifications.each do |notification| %>
3 |
4 |
<%= link_to(notification.alertable.user.name, user_path(notification.alertable.user.name)) %> replied to your <%= link_to notification.alerted.class.name, notification.alerted %>
5 | <%= render :partial => "comments/show", :locals => { comment: notification.alertable } %>
6 |
7 | <% end %>
8 | <% @old_notifications.each do |notification| %>
9 |
10 |
<%= link_to(notification.alertable.user.name, user_path(notification.alertable.user.name)) %> replied to your <%= link_to notification.alerted.class.name, notification.alerted %>
11 | <%= render :partial => "comments/show", :locals => { comment: notification.alertable } %>
12 |
13 | <% end %>
14 | <% @new_notifications.update_all(:unread => false) %>
15 |
--------------------------------------------------------------------------------
/db/migrate/20120129132752_create_make_voteable_tables.rb:
--------------------------------------------------------------------------------
1 | class CreateMakeVoteableTables < ActiveRecord::Migration
2 | def self.up
3 | create_table :votings do |t|
4 | t.string :voteable_type
5 | t.integer :voteable_id
6 | t.string :voter_type
7 | t.integer :voter_id
8 | t.boolean :up_vote, :null => false
9 |
10 | t.timestamps
11 | end
12 |
13 | add_index :votings, [:voteable_type, :voteable_id]
14 | add_index :votings, [:voter_type, :voter_id]
15 | add_index :votings, [:voteable_type, :voteable_id, :voter_type, :voter_id], :name => "unique_voters", :unique => true
16 | end
17 |
18 | def self.down
19 | remove_index :votings, :column => [:voteable_type, :voteable_id]
20 | remove_index :votings, :column => [:voter_type, :voter_id]
21 | remove_index :votings, :name => "unique_voters"
22 |
23 | drop_table :votings
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/app/views/content/new.rss.builder:
--------------------------------------------------------------------------------
1 | xml.instruct! :xml, :version => "1.0"
2 | xml.rss :version => "2.0", "xmlns:he" => 'http://hackful.com/rss/hackful' do
3 | xml.channel do
4 | xml.title "Hackful Europe - New posts"
5 | xml.description "A place for European entrepreneurs to share demos, stories or ask questions."
6 | xml.link "http://hackful.com"
7 |
8 | for post in @posts
9 | unless post.user.is_spammer?
10 | xml.item do
11 | xml.title post.title
12 | xml.description markdown(post.text)
13 | xml.pubDate post.created_at.to_s(:rfc822)
14 | xml.link post.link
15 | xml.comments post_url(post)
16 | xml.guid post_url(post)
17 | xml.he :submitter, (post.user.nil? ? "[Deleted]" : post.user.name)
18 | xml.he :points, post.votes
19 | xml.he :commentcount, comment_count(post)
20 | end
21 | end
22 | end
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/app/views/content/ask.rss.builder:
--------------------------------------------------------------------------------
1 | xml.instruct! :xml, :version => "1.0"
2 | xml.rss :version => "2.0", "xmlns:he" => 'http://hackful.com/rss/hackful' do
3 | xml.channel do
4 | xml.title "Hackful Europe - Ask posts"
5 | xml.description "A place for European entrepreneurs to share demos, stories or ask questions."
6 | xml.link "http://hackful.com"
7 |
8 | for post in @posts
9 | unless post.user.is_spammer?
10 | xml.item do
11 | xml.title post.title
12 | xml.description markdown(post.text)
13 | xml.pubDate post.created_at.to_s(:rfc822)
14 | xml.link post_url(post)
15 | xml.comments post_url(post)
16 | xml.guid post_url(post)
17 | xml.he :submitter, (post.user.nil? ? "[Deleted]" : post.user.name)
18 | xml.he :points, post.votes
19 | xml.he :commentcount, comment_count(post)
20 | end
21 | end
22 | end
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/app/views/content/frontpage.rss.builder:
--------------------------------------------------------------------------------
1 | xml.instruct! :xml, :version => "1.0"
2 | xml.rss :version => "2.0", "xmlns:he" => 'http://hackful.com/rss/hackful' do
3 | xml.channel do
4 | xml.title "Hackful Europe - Top posts"
5 | xml.description "A place for European entrepreneurs to share demos, stories or ask questions."
6 | xml.link "http://hackful.com"
7 |
8 | for post in @posts
9 | unless post.user.is_spammer?
10 | xml.item do
11 | xml.title post.title
12 | xml.description markdown(post.text)
13 | xml.pubDate post.created_at.to_s(:rfc822)
14 | xml.link post.link
15 | xml.comments post_url(post)
16 | xml.guid post_url(post)
17 | xml.he :submitter, (post.user.nil? ? "[Deleted]" : post.user.name)
18 | xml.he :points, post.votes
19 | xml.he :commentcount, comment_count(post)
20 | end
21 | end
22 | end
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/app/views/comments/_form.html.erb:
--------------------------------------------------------------------------------
1 | <%= form_for(@comment) do |f| %>
2 | <% if @comment.errors.any? %>
3 |
4 |
<%= pluralize(@comment.errors.count, "error") %> prohibited this comment from being saved:
5 |
6 |
7 | <% @comment.errors.full_messages.each do |msg| %>
8 | - <%= msg %>
9 | <% end %>
10 |
11 |
12 | <% end %>
13 |
14 |
15 | <%= f.text_area :text, :rows => 5 %>
16 |
17 |
18 | <% if defined? commentable_id %>
19 | <%= f.hidden_field :commentable_id, :value => commentable_id %>
20 | <%= f.hidden_field :commentable_type, :value => commentable_type %>
21 | <% end %>
22 |
23 | <% if @comment.errors.any? %>
24 | <%= f.hidden_field :commentable_id %>
25 | <%= f.hidden_field :commentable_type %>
26 | <% end %>
27 |
28 |
29 | <%= f.submit( :value => "Post Comment", :class => "blue button" ) %>
30 |
31 | <% end %>
32 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (C) 2012 Elias Haase
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of
4 | this software and associated documentation files (the "Software"), to deal in
5 | the Software without restriction, including without limitation the rights to
6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7 | of the Software, and to permit persons to whom the Software is furnished to do
8 | so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | SOFTWARE.
20 |
--------------------------------------------------------------------------------
/features/profile.feature:
--------------------------------------------------------------------------------
1 | Feature: Updating user profile
2 |
3 | To share information about me or update my settings
4 | As a user
5 | I want to be able to update my settings
6 |
7 | Scenario: Changing user-name
8 | Given I am a new authenticated user
9 | When I visit "/users/edit"
10 | And I fill in my user details without submitting
11 | And I fill in "User Name" with "newtestname"
12 | And I click the button "Update"
13 | Then I should see "You updated your account successfully."
14 |
15 | Scenario: Changing password
16 | Given I am a new authenticated user
17 | When I visit "/users/edit"
18 | And I fill in my user details without submitting
19 | And I fill in "Password" with "newtestpassword"
20 | And I fill in "Password confirmation" with "newtestpassword"
21 | And I click the button "Update"
22 | Then I should see "You updated your account successfully."
23 |
24 | Scenario: Deleting account
25 | Given I am a new authenticated user
26 | When I visit "/users/edit"
27 | And I click "Cancel my account"
28 | Then I should see "Bye! Your account was successfully cancelled. We hope to see you again soon."
29 |
--------------------------------------------------------------------------------
/app/views/devise/_links.erb:
--------------------------------------------------------------------------------
1 | <%- if controller_name != 'sessions' %>
2 | <%= link_to "Sign in", new_session_path(resource_name) %>
3 | <% end -%>
4 |
5 | <%- if devise_mapping.registerable? && controller_name != 'registrations' %>
6 | <%= link_to "Sign up", new_registration_path(resource_name) %>
7 | <% end -%>
8 |
9 | <%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
10 | <%= link_to "Forgot your password?", new_password_path(resource_name) %>
11 | <% end -%>
12 |
13 | <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
14 | <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %>
15 | <% end -%>
16 |
17 | <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
18 | <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %>
19 | <% end -%>
20 |
21 | <%- if devise_mapping.omniauthable? %>
22 | <%- resource_class.omniauth_providers.each do |provider| %>
23 | <%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %>
24 | <% end -%>
25 | <% end -%>
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | Hackful::Application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb
3 |
4 | # In the development environment your application's code is reloaded on
5 | # every request. This slows down response time but is perfect for development
6 | # since you don't have to restart the web server when you make code changes.
7 | config.cache_classes = false
8 |
9 | # Log error messages when you accidentally call methods on nil.
10 | config.whiny_nils = true
11 |
12 | # Show full error reports and disable caching
13 | config.consider_all_requests_local = true
14 | config.action_controller.perform_caching = false
15 |
16 | # Don't care if the mailer can't send
17 | config.action_mailer.raise_delivery_errors = false
18 |
19 | # Print deprecation notices to the Rails logger
20 | config.active_support.deprecation = :log
21 |
22 | # Only use best-standards-support built into browsers
23 | config.action_dispatch.best_standards_support = :builtin
24 |
25 | # Do not compress assets
26 | config.assets.compress = false
27 |
28 | # Expands the lines which load the assets
29 | config.assets.debug = true
30 | end
31 |
--------------------------------------------------------------------------------
/app/mailers/user_mailer.rb:
--------------------------------------------------------------------------------
1 | class UserMailer < ActionMailer::Base
2 | helper :application
3 |
4 | default from: "mail@hackful.com"
5 |
6 | def receive(email)
7 | commentable_string = email.subject.scan(/\(\w{1,} #\d*\)/mi)[0]
8 | commentable_type = commentable_string.scan(/[a-zA-Z]+/mi)[0]
9 | commentable_id = commentable_string.scan(/[0-9]{1,}/)[0].to_i
10 | text = email.body.decoded.gsub(/(^>.*)|((\w*\s*)[0-9]{1,}.*:$)/mi, "")
11 | Comment.new(commentable_type: commentable_type, commentable_id: commentable_id, text: text, user_id: User.find_by_email(email.from.first).id).save! unless User.find_by_email(email.from.first).nil?
12 | end
13 |
14 | # Subject can be set in your I18n file at config/locales/en.yml
15 | # with the following lookup:
16 | #
17 | # en.user_mailer.newsletter.subject
18 | #
19 | def newsletter(user, subject, text)
20 | @user = user
21 | @text = text
22 |
23 | mail(to: user.email, subject: subject)
24 | end
25 |
26 | # Subject can be set in your I18n file at config/locales/en.yml
27 | # with the following lookup:
28 | #
29 | # en.user_mailer.notify.subject
30 | #
31 | def notify
32 | @greeting = "Hi"
33 |
34 | mail to: "to@example.org"
35 | end
36 | end
37 |
--------------------------------------------------------------------------------
/app/models/comment.rb:
--------------------------------------------------------------------------------
1 | class Comment < ActiveRecord::Base
2 | include ActionView::Helpers::SanitizeHelper
3 |
4 | after_create { |comment| Notification.new(:user_id => comment.commentable.user_id, :alerted_type => comment.commentable.class.name, :alerted_id => comment.commentable.id, :alertable_type => comment.class.name, :alertable_id => comment.id ).save! }
5 |
6 | belongs_to :commentable, :polymorphic => true
7 | belongs_to :user
8 |
9 | attr_accessible :commentable_type, :commentable_id, :text, :user_id
10 |
11 | has_many :comments, :as => :commentable
12 |
13 | make_voteable
14 |
15 | validates :text, :length => { :minimum => 2 }, :allow_blank => false
16 |
17 | def root
18 | commentable = self.commentable
19 | while commentable.class == "Comment"
20 | commentable = commentable.commentable
21 | end
22 | commentable
23 | end
24 |
25 | def as_json(options = {})
26 | super(
27 | :include => {:user => {:only => [:id, :name]}},
28 | :except => [:user_id, :down_votes, :commentable_type],
29 | :methods => :voted
30 | )
31 | end
32 |
33 | def voted
34 | current_user = User.current_user
35 | unless current_user.blank?
36 | current_user.voted?(self)
37 | else
38 | false
39 | end
40 | end
41 | end
42 |
--------------------------------------------------------------------------------
/app/views/posts/_preview.html.erb:
--------------------------------------------------------------------------------
1 |
2 | <% if user_signed_in? %>
3 | <% if current_user.voted?(post) %>
4 |
5 | <% else %>
6 |
7 | <% end %>
8 | <%= link_to "▲".html_safe, "#", :onClick => "vote_up("+post.id.to_s+", 'posts'); return false" %>
9 | <% else %>
10 |
11 | <%= link_to "▲".html_safe, new_user_session_path %>
12 | <% end %>
13 |
14 |
15 |
16 | <%= (post.link.nil? or post.link.empty?) ? (link_to post.title, post) : (link_to post.title, post.link) %>
17 | <% uri = URI.parse(post.link) %>
18 | <% unless post.link.nil? or post.link.empty? or uri.host.nil? %>
19 | <%= link_to("("+uri.host.gsub("www.","")+")", "http://"+uri.host) %>
20 | <% end %>
21 |
22 |
<%= pluralize(post.votes, "point") %> by <%= (post.user.nil? ? "[Deleted]" : link_to(post.user.name, user_path(post.user.name))) %> <%= time_ago_in_words(post.created_at) %> ago | <%= link_to(pluralize(comment_count(post), "comment"), post) %>
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/controllers/api/basic_api.rb:
--------------------------------------------------------------------------------
1 | require 'action_controller'
2 | module Api::BasicApi
3 | class NotLogedIn < StandardError; end
4 | class NoParameter < StandardError; end
5 | class NoPermission < StandardError; end
6 |
7 | def not_found
8 | head :not_found
9 | end
10 |
11 | def internal_server_error(exception = nil)
12 | error = {
13 | :error => "internal server error",
14 | :exception => exception.message,
15 | :stacktrace => exception.backtrace
16 | }
17 | render :json => error, :status => 500
18 | end
19 |
20 | def no_parameter_found
21 | render :json => failure_message("Missing parameters"), :status => 422
22 | end
23 |
24 | def not_loged_in
25 | render :json => failure_message("Please login"), :status => 401
26 | end
27 |
28 | def success_message(message, info = nil)
29 | json = {:success => true, :message => message}
30 | json.merge! info unless info.nil?
31 | return json
32 | end
33 |
34 | def failure_message(message, errors = nil)
35 | json = {:success => false, :message => message}
36 | json.merge! errors unless errors.nil?
37 | return json
38 | end
39 |
40 | def check_login
41 | raise NotLogedIn unless user_signed_in?
42 | end
43 |
44 | private
45 | def set_format
46 | request.format = 'json'
47 | end
48 | end
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'http://rubygems.org'
2 | source 'http://gemcutter.org'
3 |
4 | gem 'rails', '3.1.10'
5 |
6 | gem 'sqlite3'
7 | gem 'json', '>=1.7.7'
8 |
9 | group :assets do
10 | gem 'sass-rails'
11 | gem 'coffee-rails'
12 | gem 'uglifier', '>= 1.0.3'
13 | end
14 |
15 | group :test, :development do
16 | gem 'cucumber-rails'
17 | gem 'database_cleaner'
18 | gem 'rspec-rails'
19 | gem 'cucumber-rails', require: false
20 | gem "factory_girl_rails"
21 | gem 'capybara'
22 | gem "capybara-webkit"
23 | gem 'fakeweb'
24 | gem "launchy"
25 | gem 'database_cleaner', :group => :test
26 | gem 'faker'
27 | gem 'pry'
28 | gem 'rest-client'
29 |
30 | if RUBY_PLATFORM.downcase.include?("darwin")
31 | gem "guard"
32 | gem "guard-rspec"
33 | gem "guard-cucumber"
34 | gem "guard-bundler"
35 | gem "guard-spork"
36 | gem 'spork'
37 | gem 'rb-fsevent'
38 | gem 'growl' # also install growlnotify from the Extras/growlnotify/growlnotify.pkg in Growl disk image
39 | end
40 | end
41 |
42 | gem 'execjs'
43 | gem 'therubyracer'
44 | gem 'devise'
45 | gem 'nested_form', :git => 'git://github.com/fxposter/nested_form.git'
46 | gem 'jquery-rails'
47 | gem 'cancan'
48 | gem 'make_voteable'
49 | gem 'mysql2'
50 | gem 'rails_autolink'
51 | gem 'rdiscount'
52 | gem 'delayed_job'
53 | gem 'delayed_job_active_record'
54 | gem 'whenever'
--------------------------------------------------------------------------------
/app/views/devise/registrations/edit.html.erb:
--------------------------------------------------------------------------------
1 |
Edit <%= resource_name.to_s.humanize %>
2 |
3 | <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
4 | <%= devise_error_messages! %>
5 |
6 |
<%= f.label :name, "User Name" %>
7 | <%= f.text_field :name %>
8 |
9 |
<%= f.label :email %>
10 | <%= f.email_field :email %>
11 |
12 |
<%= f.label :password %> (leave blank if you don't want to change it)
13 | <%= f.password_field :password %>
14 |
15 |
<%= f.label :password_confirmation %>
16 | <%= f.password_field :password_confirmation %>
17 |
18 |
<%= f.label :current_password %> (we need your current password to confirm your changes)
19 | <%= f.password_field :current_password %>
20 |
21 |
<%= f.fields_for :data_set do |data_set_form| %>
22 | <%= data_set_form.label :contact_me, "Send email notifications" %>
23 | <%= data_set_form.check_box :contact_me %>
24 | <% end %>
25 |
26 |
<%= f.submit "Update" %>
27 | <% end %>
28 |
29 |
Cancel my account
30 |
31 |
Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.
32 |
33 | <%= link_to "Back", :back %>
34 |
--------------------------------------------------------------------------------
/db/migrate/20120226193229_create_delayed_jobs.rb:
--------------------------------------------------------------------------------
1 | class CreateDelayedJobs < ActiveRecord::Migration
2 | def self.up
3 | create_table :delayed_jobs, :force => true do |table|
4 | table.integer :priority, :default => 0 # Allows some jobs to jump to the front of the queue
5 | table.integer :attempts, :default => 0 # Provides for retries, but still fail eventually.
6 | table.text :handler # YAML-encoded string of the object that will do work
7 | table.text :last_error # reason for last failure (See Note below)
8 | table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future.
9 | table.datetime :locked_at # Set when a client is working on this object
10 | table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead)
11 | table.string :locked_by # Who is working on this object (if locked)
12 | table.string :queue # The name of the queue this job is in
13 | table.timestamps
14 | end
15 |
16 | add_index :delayed_jobs, [:priority, :run_at], :name => 'delayed_jobs_priority'
17 | end
18 |
19 | def self.down
20 | drop_table :delayed_jobs
21 | end
22 | end
23 |
--------------------------------------------------------------------------------
/app/controllers/content_controller.rb:
--------------------------------------------------------------------------------
1 | class ContentController < ApplicationController
2 | def frontpage
3 | @page = page_number(params[:page])
4 | @posts = Post.find_frontpage(@page)
5 | @show_next_link = (Post.find_frontpage(@page+1).length > 0)
6 |
7 | respond_to do |f|
8 | f.html
9 | f.rss { render :layout => false }
10 | end
11 | end
12 |
13 | def new
14 | @page = page_number(params[:page])
15 | @posts = Post.find_new(@page)
16 | @show_next_link = (Post.find_frontpage(@page+1).length > 0)
17 |
18 | respond_to do |f|
19 | f.html
20 | f.rss { render :layout => false }
21 | end
22 | end
23 |
24 | def ask
25 | @page = page_number(params[:page])
26 | @posts = Post.find_ask(@page)
27 | @show_next_link = (Post.find_frontpage(@page+1).length > 0)
28 |
29 | respond_to do |f|
30 | f.html
31 | f.rss { render :layout => false }
32 | end
33 | end
34 |
35 | def about
36 | respond_to do |f|
37 | f.html
38 | end
39 | end
40 |
41 | def notifications
42 | notifications = current_user.all_notifications
43 | @new_notifications = notifications[:new_notifications]
44 | @old_notifications = notifications[:old_notifications]
45 | @comment = Comment.new
46 | respond_to do |f|
47 | f.html
48 | end
49 | end
50 |
51 | def hackfulthon
52 | render layout: false
53 | end
54 |
55 | end
56 |
--------------------------------------------------------------------------------
/app/models/user.rb:
--------------------------------------------------------------------------------
1 | class User < ActiveRecord::Base
2 | # Include default devise modules. Others available are:
3 | # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
4 | devise :database_authenticatable, :registerable,
5 | :recoverable, :rememberable, :trackable, :validatable,
6 | :token_authenticatable
7 |
8 | cattr_accessor :current_user
9 |
10 | # Setup accessible (or protected) attributes for your model
11 | attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :data_set_attributes
12 |
13 | has_many :votes, :as => :voteable
14 | has_many :comments
15 | has_many :posts
16 | has_many :notifications, :order => "created_at DESC"
17 | has_many :admin_auths
18 |
19 | has_one :data_set
20 | accepts_nested_attributes_for :data_set
21 |
22 | validates_uniqueness_of :name
23 | validates_format_of :name, :with => /\A[a-zA-Z0-9]+\z/i,
24 | :message => "can only contain letters and numbers."
25 |
26 | make_voter
27 |
28 | def is_spammer?
29 | !Spammer.find_by_user_id(self.id).nil?
30 | end
31 |
32 | def all_notifications
33 | {
34 | :new_notifications => self.notifications.where(:unread => true),
35 | :old_notifications => self.notifications.find(:all,
36 | :conditions => { :unread => false }, :limit => 20)
37 | }
38 | end
39 | end
40 |
41 |
--------------------------------------------------------------------------------
/features/step_definitions/shared_steps.rb:
--------------------------------------------------------------------------------
1 | Given /^I am on the startpage$/ do
2 | visit "/"
3 | end
4 |
5 | Given /^I am a new authenticated user$/ do
6 | email = 'testing@man.net'
7 | password = 'secretpass'
8 | @user = FactoryGirl.create(:user, email: email, password: password, password_confirmation: password)
9 |
10 | visit '/users/sign_in'
11 | fill_in "user_email", :with=>email
12 | fill_in "user_password", :with=>password
13 | click_button "Sign in"
14 | end
15 |
16 | Given /^I am not authenticated$/ do
17 | visit('/users/sign_out')
18 | end
19 |
20 | Given /^I am on the page for a submitted post$/ do
21 | post = @user.posts.create(FactoryGirl.build(:post).attributes)
22 | visit "/posts/#{post.id}"
23 | end
24 |
25 |
26 | Given /^the user has deleted his account$/ do
27 | User.delete_all
28 | end
29 |
30 | When /^I click "([^"]*)"$/ do |link|
31 | click_link link
32 | end
33 |
34 | When /^I click the button "([^"]*)"$/ do |button|
35 | click_button button
36 | end
37 |
38 | Then /^I should see "([^"]*)"$/ do |text|
39 | page.should have_content(text)
40 | end
41 |
42 | When /^I visit "([^"]*)"$/ do |page|
43 | visit page
44 | end
45 |
46 | When /^I fill in my user details without submitting$/ do
47 | fill_in 'User Name', with: 'pbjorklund'
48 | fill_in 'Email', with: 'p.bjorklund@gmail.com'
49 | fill_in 'Current password', :with => 'secretpass'
50 | end
51 |
--------------------------------------------------------------------------------
/features/posts.feature:
--------------------------------------------------------------------------------
1 | Feature: Submitting news items
2 |
3 | To share news about startup related news in europe
4 | As a user
5 | I want to be able to submit stories
6 |
7 | Scenario: Submitting
8 | Given I am a new authenticated user
9 | When I click "submit"
10 | And I fill in "Title" with "Hackful integration tests pull request submitted"
11 | And I fill in "Text" with "Check out the github issues list to see the pull request"
12 | And I fill in "Link" with "https://github.com/8bitpal/hackful/issues"
13 | And I click the button "Create Post"
14 | Then I should see "Post was successfully created."
15 |
16 | Scenario: Editing
17 | Given I am a new authenticated user
18 | And I am on the page for a submitted post
19 | When I click "Edit"
20 | And I fill in "Title" with "Hackful integration tests pull request declined"
21 | And I fill in "Text" with "See this example of how not to submit pull requests"
22 | And I fill in "Link" with "https://github.com/8bitpal/hackful/pull/41"
23 | And I click the button "Update Post"
24 | Then I should see "Post was successfully updated."
25 |
26 | Scenario: Editing a post where the user has deleted his account
27 | Given I am a new authenticated user
28 | And I am on the page for a submitted post
29 | And the user has deleted his account
30 | When I am on the startpage
31 | Then I should see "[Deleted]"
32 |
--------------------------------------------------------------------------------
/app/views/comments/_show.html.erb:
--------------------------------------------------------------------------------
1 |