diff --git a/.gitignore b/.gitignore index c74ce787..ab76df04 100644 --- a/.gitignore +++ b/.gitignore @@ -17,5 +17,10 @@ /config/database.yml /config/config.yml +/db/seeds.rb + +/public/assets + +# files from other forks +/coverage -/public/assets \ No newline at end of file diff --git a/README.md b/README.md index e90f04f5..cb49586c 100644 --- a/README.md +++ b/README.md @@ -52,16 +52,17 @@ cp config/config.yml{.example,} bundle exec rake db:migrate ``` -* Make sure `ppcoind` is running with RPC enabled - -* Run the server +* Install phantomjs >= 1.8.1 in order to run the cucumber tests +* Make sure `ppcoind` is running with RPC enabled - (see the [ppcoin repo](https://github.com/ppcoin/ppcoin/wiki/Installation)) +* Run the server +``` bundle exec rails server +``` * Connect to the server at http://localhost:3000/ - To update the project balances run this command: ``` bundle exec rails runner "BalanceUpdater.work" diff --git a/config/application.rb b/config/application.rb index 59da21f9..56a5ea04 100644 --- a/config/application.rb +++ b/config/application.rb @@ -6,7 +6,8 @@ # you've limited to :test, :development, or :production. Bundler.require(:default, Rails.env) -CONFIG ||= YAML::load(File.open("config/config.yml")) +# load config.yaml preprocessed +CONFIG ||= YAML::load(ERB.new(File.read("config/config.yml")).result) COIN = 1000000 # ppcoin/src/util.h diff --git a/config/cross-fork-dev/Gemfile.dev b/config/cross-fork-dev/Gemfile.dev new file mode 100644 index 00000000..91f22eb4 --- /dev/null +++ b/config/cross-fork-dev/Gemfile.dev @@ -0,0 +1,174 @@ +=begin + ** DO NOT COMMIT THIS FILE IN THE RAILS ROOT DIR ** + bundle then then restore the original + (see: config/cross-fork-dev/cross-fork-dev-REAMDE.md) + cd RAILS_ROOT + mv Gemfile ./Gemfile.bak + cp config/cross-fork-dev/Gemfile.dev ./Gemfile + bundle install --without production mysql postgresql + mv Gemfile.bak ./Gemfile +=end + + +source 'https://rubygems.org' + +ruby '2.0.0' + +gem 'rails', '4.0.2' +gem 'mysql2', group: :production +gem 'sass-rails', '~> 4.0.0' +gem 'haml-rails', '~> 0.5.3' +gem 'less-rails', '~> 2.4.2' +gem 'kaminari', '~> 0.15.0' +gem 'uglifier', '>= 1.3.0' +gem 'coffee-rails', '~> 4.0.0' +gem 'therubyracer', '~> 0.12.0', platforms: :ruby +gem 'jquery-rails', '~> 3.0.4' +gem 'turbolinks', '~> 2.2.0' +gem 'jquery-turbolinks' +gem 'jbuilder', '~> 1.5.3' +gem 'airbrake', '~> 3.1.15' +gem 'devise', '~> 3.2.2' +gem 'omniauth', '~> 1.1.4' +gem 'omniauth-github', github: 'alexandrz/omniauth-github', branch: 'provide_emails' +gem 'octokit', '~> 2.7.0' +gem 'sawyer', '~> 0.5.2' +gem 'twitter_bootstrap_form_for', github: 'stouset/twitter_bootstrap_form_for' +gem 'twitter-bootstrap-rails', github: 'seyhunak/twitter-bootstrap-rails', branch: 'bootstrap3' +# sigmike 'bootstrap_form' bugfix added in https://github.com/tip4commit/tip4commit/pull/74 +# has been merged upstream https://github.com/bootstrap-ruby/rails-bootstrap-forms/pull/76 +#gem 'bootstrap_form', github: 'sigmike/rails-bootstrap-forms', branch: 'removed_for_on_radio_label' +gem 'bootstrap_form', github: 'bootstrap-ruby/rails-bootstrap-forms' +gem 'sdoc', group: :doc, require: false +gem 'cancancan' +gem 'dusen' +gem 'render_csv' +gem 'demoji' + +gem "http_accept_language" +gem 'rails-i18n' +gem "i18n-js" +gem 'kaminari-i18n' +gem 'devise-i18n' + +group :development do + gem 'capistrano', '~> 3.0.1' + gem 'capistrano-rvm', '~> 0.1.0', github: 'capistrano/rvm' + gem 'capistrano-bundler', '>= 1.1.0' + gem 'capistrano-rails', '~> 1.1.0' + gem 'debugger', '~> 1.6.5' +end + +group :development, :test do + gem 'sqlite3', '~> 1.3.8' + gem 'factory_girl_rails', '~> 4.3.0' + gem 'rspec-rails', '~> 3.0.0.beta' +end + +group :test do + gem 'simplecov' + gem 'shoulda-matchers', '~> 2.5.0' + gem 'cucumber-rails', require: false + gem 'database_cleaner' +end + + + + + + + +# peer4commit + +source 'https://rubygems.org' + +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '4.0.2' + +# Databases +gem 'sqlite3', '~> 1.3.8' , group: :development +gem 'mysql2', group: :mysql +gem 'pg', group: :postgresql + +# Use SCSS for stylesheets +gem 'sass-rails', '~> 4.0.0' +gem 'haml-rails', '~> 0.5.3' +gem "less-rails", '~> 2.4.2' + +gem 'twitter-bootstrap-rails', github: 'seyhunak/twitter-bootstrap-rails', branch: 'bootstrap3' + +gem 'kaminari', '~> 0.15.0' + +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' + +# Use CoffeeScript for .js.coffee assets and views +gem 'coffee-rails', '~> 4.0.0' + +# See https://github.com/sstephenson/execjs#readme for more supported runtimes +gem 'therubyracer', '~> 0.12.0', platforms: :ruby + +# Use jquery as the JavaScript library +gem 'jquery-rails', '~> 3.0.4' + +# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks +gem 'turbolinks', '~> 2.2.0' + +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 1.5.3' + +group :doc do + # bundle exec rake doc:rails generates the API under doc/api. + gem 'sdoc', require: false +end + +gem 'devise', '~> 3.2.2' +gem 'omniauth', '~> 1.1.4' +gem 'omniauth-github', github: 'alexandrz/omniauth-github', branch: 'provide_emails' +gem 'cancancan' +gem 'twitter_bootstrap_form_for', github: 'stouset/twitter_bootstrap_form_for' + +gem 'octokit', '~> 2.7.0' + +# Use ActiveModel has_secure_password +# gem 'bcrypt-ruby', '~> 3.0.0' + +# Use unicorn as the app server +# gem 'unicorn' + +# Use debugger +# gem 'debugger', group: [:development, :test] + +group :development do + gem 'capistrano', '~> 3.0.1' + gem 'capistrano-rvm', '~> 0.1.0', github: 'capistrano/rvm' + gem 'capistrano-bundler', '>= 1.1.0' + gem 'capistrano-rails', '~> 1.1.0' + gem 'quiet_assets' +end + +gem 'airbrake', '~> 3.1.15' +gem 'httparty' +gem 'whenever' +gem 'rqrcode-rails3' +gem 'exception_notification' +gem 'rack-canonical-host' +gem 'bootstrap_form', github: 'bootstrap-ruby/rails-bootstrap-forms' +gem 'html_pipeline_rails' +gem 'rails_autolink' +gem 'redcarpet' +gem 'sanitize' +gem 'twitter-typeahead-rails' +gem 'commontator', '~> 4.6.0' +gem 'compass-rails' + +group :test do + gem 'cucumber-rails', :require => false + # database_cleaner is not required, but highly recommended + gem 'database_cleaner' + gem 'rspec-rails', '~> 3.0.0.beta' + gem 'factory_girl_rails', '~> 4.3.0' + gem 'poltergeist' + gem 'timecop' + gem 'capybara-screenshot' +end diff --git a/config/cross-fork-dev/config.yml.dev b/config/cross-fork-dev/config.yml.dev new file mode 100644 index 00000000..8a96d72c --- /dev/null +++ b/config/cross-fork-dev/config.yml.dev @@ -0,0 +1,116 @@ + +<% +# list local feature branches in their appropriate *_BRANCHES lists below +MY_BRANCHES = %w{master} +TIP4COMMIT_BRANCHES = %w{tip4commit-master tip4commit-new-feature} +PEER4COMMIT_BRANCHES = %w{peer4commit-master peer4commit-new-feature} +PRIME4COMMIT_BRANCHES = %w{prime4commit-master peer4commit-new-feature} +BRANCHES_LISTS_FILENAME = 'config/config.yml' # DEBUG + +BRANCH_NAME = `git rev-parse --abbrev-ref HEAD`.strip +IS_MYFORK = MY_BRANCHES.include? BRANCH_NAME +IS_TIP4COMMIT_FORK = TIP4COMMIT_BRANCHES.include? BRANCH_NAME +IS_PEER4COMMIT_FORK = PEER4COMMIT_BRANCHES.include? BRANCH_NAME +IS_PRIME4COMMIT_FORK = PRIME4COMMIT_BRANCHES.include? BRANCH_NAME +%> + + +<% if IS_MY_FORK %> +<% puts "no app config defined for local branch: '#{BRANCH_NAME}'" %> +<% elsif IS_TIP4COMMIT_FORK %> +github: + key: "111111111111" + secret: "111111111111" + auto_paginate: false + pages: 3 + project_pages: {} + +blockchain_info: + guid: "111111111111" + password: "111111111111" + callback_secret: "111111111111" + +tip: 0.01 +min_payout: 100000 +our_fee: 0.05 + +deposit_address: 1M4bS4gPyA6Kb8w7aXsgth9oUZWcRk73tQ + +address_versions: # 0/5 for bitcoin addresses, 111/196 for testnet, see chainparams.cpp + - 0 + - 5 + + +<% elsif IS_PEER4COMMIT_FORK %> +github: + key: "111111111111" + secret: "111111111111" + +daemon: + username: rpcuser + password: rpcpassword + host: localhost + port: 9904 + path: /path/to/ppcoin/src/ppcoind + +tip: 0.01 +min_payout: 1.0 # in PPC +our_fee: 0.05 +tipper_delay: "1.hour" + +address_versions: # 55/117 for peercoin, 111/196 for testnet, see base58.h + - 111 + - 196 + +# canonical_host: peer4commit.example.com # will redirect all other hostnames to this one + + +<% elsif IS_PRIME4COMMIT_FORK %> +github: + key: "111111111111" + secret: "111111111111" + +daemon: + username: rpcuser + password: rpcpassword + host: localhost + port: 9914 + path: /path/to/primecoin/src/primecoind + +tip: 0.01 +min_payout: 1.0 # in XPM +our_fee: 0.05 +tipper_delay: "1.hour" + +address_versions: # 23/83 for primecoin, 111/196 for testnet, see base58.h + - 111 + - 196 + +# canonical_host: prime4commit.example.com # will redirect all other hostnames to this one + + +<% else %> +<% puts "ERROR: config/config.yml - no app config defined for branch: '#{BRANCH_NAME}'" + + " - you must add it to one of the *_BRANCHES lists in #{BRANCHES_LISTS_FILENAME}" %> +<% end %> + + +devise: + secret: "111111111111" + +application: + secret: "111111111111" + +smtp_settings: + address: smtp.gmail.com + port: 587 + domain: example.com + user_name: example@example.com + password: MY_PASSWORD + authentication: plain + enable_starttls_auto: true + +# Uncomment to use airbrake/errbit +# airbrake: +# api_key: 111111111111 +# host: errbit.tip4commit.com diff --git a/config/cross-fork-dev/cross-fork-dev-REAMDE.md b/config/cross-fork-dev/cross-fork-dev-REAMDE.md new file mode 100644 index 00000000..4d44574c --- /dev/null +++ b/config/cross-fork-dev/cross-fork-dev-REAMDE.md @@ -0,0 +1,66 @@ +### cross-fork development + +the files in this directory exist to aid cross-fork development of the various tip4commit forks from within the same local clone - if you will be working on only one fork then use Gemfile, config/config.yml.sample, and config/database.yml.sample instead + +the various forks have drifted apart significantly and require different configuratons - these files will allow these all to be functional within in the same clone without manual config swapping - the only routine maintenance required is in adding new feature branches to the appropriate *_BRANCHES list in config.yml.dev and re-bundling when Gemfiles change + + +#### config/cross-fork-dev/Gemfile.dev + +Gemfile.dev is a concatenation of the Gemfiles from the tip4commit and peer4commit forks with some version conflicts resolved by favoring the more specific requirement + +this o/c is brittle and must be maintained and is not guaranteed 100% bug-free but has so far worked out well for development + + +#### config/cross-fork-dev/config.yml.dev + + config.yml.dev includes a separate configuration for each known tip4commit variant - switched per the current git branch + + config.yml.dev also defines which feature branches should share configurations - you will need to manually add each new branch to the appropriate *_BRANCHES list + + +#### config/cross-fork-dev/database.yml.dev + database.yml.dev also includes a separate configuration for each known tip4commit variant - switched per the current git branch (requires the *_BRANCHES list in config.yml.dev) + + +### setup + + * fork any of the tip4commit forks then clone your fork + * backup Gemfile then copy Gemfile.dev to the rails root dir +``` + cd RAILS_ROOT + mv Gemfile ./Gemfile.bak + cp config/cross-fork-dev/Gemfile.dev ./Gemfile +``` + * bundle then restore Gemfile +``` + bundle install --without production mysql postgresql + mv Gemfile.bak ./Gemfile +``` + * copy config.yml.dev and database.yml.dev to config +``` + cp config/cross-fork-dev/config.yml.dev config/config.yml + cp config/cross-fork-dev/database.yml.dev config/database.yml +``` + * customize config/config.yml and config/database.yml + * repeat the following flow for each fork including the one you forked from +``` + git remote add tip4commit https://github.com/tip4commit/tip4commit.git + git checkout -b tip4commit-master + git fetch tip4commit + git merge tip4commit/master +``` + * add each fork branch created above its corresponding *_BRANCHES list + + +### maintenance + * add new local feature branches in their appropriate *_BRANCHES lists + (e.g. to reduce ambiguity use your local master branch for experimentaion only) + * re-bundle as above when any of the forked Gemfiles change (updating and committing config/cross-fork-dev/Gemfile.dev if necessary) +``` + cd RAILS_ROOT + mv Gemfile ./Gemfile.bak + cp config/cross-fork-dev/Gemfile.dev ./Gemfile + bundle install --without production mysql postgresql + mv Gemfile.bak ./Gemfile +``` diff --git a/config/cross-fork-dev/database.yml.dev b/config/cross-fork-dev/database.yml.dev new file mode 100644 index 00000000..d22fc1f4 --- /dev/null +++ b/config/cross-fork-dev/database.yml.dev @@ -0,0 +1,45 @@ + +development: + adapter: sqlite3 + pool: 5 + timeout: 5000 +<% if IS_MY_FORK %> + database: db/my_development.sqlite3 +<% elsif IS_TIP4COMMIT_FORK %> + database: db/tip4commit_development.sqlite3 +<% elsif IS_PEER4COMMIT_FORK %> + database: db/peer4commit_development.sqlite3 +<% elsif IS_PRIME4COMMIT_FORK %> + database: db/prime4commit_development.sqlite3 +<% else %> +<% puts "ERROR: config/database.yml - no development db specified for branch: '#{branch_name}'" + + + " - you must add it to one of the *_BRANCHES lists in #{BRANCHES_LISTS_FILENAME}" %> +<% end %> + + +test: + adapter: sqlite3 + pool: 5 + timeout: 5000 +<% if IS_MY_FORK %> + database: db/my_test.sqlite3 +<% elsif IS_TIP4COMMIT_FORK %> + database: db/tip4commit_test.sqlite3 +<% elsif IS_PEER4COMMIT_FORK %> + database: db/peer4commit_test.sqlite3 +<% elsif IS_PRIME4COMMIT_FORK %> + database: db/prime4commit_test.sqlite3 +<% else %> +<% puts "ERROR: config/database.yml - no test db specified for branch: '#{branch_name}'" + + " - you must add it to one of the *_BRANCHES lists in #{BRANCHES_LISTS_FILENAME}" %> +<% end %> + + +production: + adapter: mysql2 + encoding: utf8 + database: tip4commit + username: root + password: + socket: /var/run/mysqld/mysqld.sock diff --git a/db/schema.rb b/db/schema.rb index 9e9da2e7..cbbbdc9d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -176,6 +176,7 @@ add_index "tipping_policies_texts", ["user_id"], name: "index_tipping_policies_texts_on_user_id" create_table "tips", force: true do |t| + t.integer "user_id" t.integer "amount", limit: 8 t.integer "distribution_id" t.datetime "created_at" @@ -187,7 +188,6 @@ t.string "comment" t.integer "reason_id" t.string "reason_type" - t.integer "user_id" end add_index "tips", ["distribution_id"], name: "index_tips_on_distribution_id" @@ -196,6 +196,7 @@ add_index "tips", ["user_id"], name: "index_tips_on_user_id" create_table "users", force: true do |t| + t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false t.string "reset_password_token" t.datetime "reset_password_sent_at" @@ -207,6 +208,7 @@ t.string "last_sign_in_ip" t.datetime "created_at" t.datetime "updated_at" + t.string "nickname" t.string "name" t.string "image" t.string "bitcoin_address" @@ -219,13 +221,12 @@ t.datetime "confirmed_at" t.datetime "confirmation_sent_at" t.string "unconfirmed_email" - t.string "email" - t.string "nickname" t.boolean "disabled", default: false t.string "identifier", null: false end add_index "users", ["disabled"], name: "index_users_on_disabled" + add_index "users", ["email"], name: "index_users_on_email", unique: true add_index "users", ["identifier"], name: "index_users_on_identifier", unique: true add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true