0xblockhain is a Blockhain technology-focused community centered around link aggregation and discussion.
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 105 commits ahead, 53 commits behind lobsters:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.github
.vscode
app
bin
config
db
extras
lib
public
script
spec
vendor/assets
.gitignore
.rspec
.rubocop.yml
.ruby-version
.travis.yml
CONTRIBUTING.md
Gemfile
Gemfile.lock
LICENSE
LICENSE_LOBSTER
Procfile
README.md
Rakefile
config.ru

README.md

0xblockchain Rails Project Build Status

This is the source code of the site operating at https://0xblockchain.network. It is a Rails 5 codebase and uses a SQL (PostgreSQL in production) backend for the database.

While you are free to fork this code and modify it (according to the license) to run your own link aggregation website, this source code repository and bug tracker are only for the site operating at 0xblockchain.network. Please do not use the bug tracker for support related to operating your own site unless you are contributing code that will also benefit 0xblockchain.network.

The 0xblockchain site is based on awesome lobster site.

Contributing bugfixes and new features

Please see the CONTRIBUTING file.

Initial setup

Use the steps below for a local install.

  • Install Ruby 2.5.

  • Checkout the 0xblockhain git tree from Github

    $ git clone git://github.com/pyk/0xblockchain.git
    $ cd 0xblockhain
    0xblockhain$
  • Install Nodejs, needed (or other execjs) for uglifier

    Fedora: sudo yum install nodejs
    Ubuntu: sudo apt-get install nodejs
    OSX: brew install nodejs
  • Run Bundler to install/bundle gems needed by the project:

    0xblockchain$ bundle install --path vendor/bundle
  • Install postgresql locally using the following command:

    0xblockchain$ sudo apt install postgresql
  • Create role for your current user:

    0xblockchain$ sudo -u postgres createuser $(whoami) -s -P
  • Create .env.development inside root directory with the following content:

      DATABASE_URL="postgres://$(whoami):1234@localhost/0xblockchain_dev"
      DATABASE_TEST_URL="postgres://$(whoami):1234@localhost/0xblockchain_test"
      GITHUB_CLIENT_ID='UPDATE_HERE'
      GITHUB_CLIENT_SECRET='UPDATE_HERE'
  • Load the schema into the new database:

    bundle exec rake db:schema:load
  • If you have found a problem, run the following commands to debug the migrations:

    bin/rails db:environment:set RAILS_ENV=development
    bundle exec rake db:drop
    bundle exec rake db:create
    bundle exec rake db:migrate

then load the schema again.

  • Create a config/initializers/secret_token.rb file, using a randomly generated key from the output of bundle exec rake secret:

    0xblockhain::Application.config.secret_key_base = 'your random secret here'
  • Define your site's name and default domain, which are used in various places, in a config/initializers/production.rb or similar file:

    class << Rails.application
      def domain
          "example.com"
      end
    
      def name
          "Example News"
      end
    end
    
    Rails.application.routes.default_url_options[:host] = Rails.application.domain
  • Put your site's custom CSS in app/assets/stylesheets/local.

  • Seed the database to create the tags:

    bundle exec rake db:seed
  • Run the Rails server in development mode. You should be able to login to http://localhost:3000 with your new test user:

    0xblockhain$ bundle exec rails server
  • In production, set up crontab or another scheduler to run regular jobs:

    */5 * * * *  cd /path/to/0xblockhain && env RAILS_ENV=production sh -c 'bundle exec ruby script/mail_new_activity; bundle exec ruby script/post_to_twitter'
  • In production, see config/initializers/production.rb.sample for GitHub/Twitter integration help.

Administration

Basic moderation happens on-site, but most other administrative tasks require use of the rails console in production. Administrators can create and edit tags at /tags.

To grant admin access:

bundle exec rails console

Then find the user and grant the admin access:

user = User.find_by(username: "username")
user.is_admin = true
user.save!

Heroku

To deploy on heroku, follow this step by step.

First, login to your account:

heroku login

Then create application:

heroku create

Then deploy to heroku:

git push heroku master

Migrate and seed the database if there are any changes:

heroku run rake db:migate
heroku run rake db:seed

To perform administrative task, run:

heroku run rails console

To use multiple environment (staging and production) on heroku read the following guide.

To get the logs you can run the following command:

heroku logs --app APP_NAME

or to follow the logs:

heroku logs --app APP_NAME --tail

Testing

You need to install chromedriver.

In ubuntu, add the following to your .bashrc:

export PATH=$PATH:/usr/lib/chromium-browser/

Make sure you have restart your current shell session before run the tests:

exec $SHELL

Execute the following command to run the test:

# Precompile the assets
bundle exec rake assets:precompile
# Run all specs
bundle exec rspec
# Or individual spec
bundle exec rspec spec/controllers/sessions_controller_spec.rb