Skip to content

Hosting Your Own Ohai on Heroku

giffc edited this page May 24, 2012 · 1 revision

"Ohai it's me" runs on Heroku. For free!

Clone the ohai_its_me repository

  • From terminal, navigate to the directory where you store your webapp projects and clone the repo:
cd /my/projects
git clone [email protected]:giffc/ohai_its_me.git

(Or you could fork the project first and clone that repo instead.)

Customizing Design

You can put in your name and a new header image by editing app/views/shared/_about_header.html.erb. The default header image is 440px x 150px. There are two examples in public/images: temp_img.jpg (taken by Chris Carella) and temp_img2.jpg (taken by Giff Constable).

On fonts: the current repo points to Typekit, which will break on your version. You can switch to font-face if you want to host your own fonts, replace the Typekit javascript with your own, or switch to google webfonts. The typekit javascript is in app/views/shared/_webfont_script.html.erb. You will also want to update screen.css.scss with your new font choices.

Create a Heroku account and app

  1. Sign up if you haven't yet: http://www.heroku.com/
  2. Install the heroku toolbelt: https://toolbelt.herokuapp.com/
  3. Create a new app. From the terminal:
heroku login
cd /my/projects/ohai_its_me
heroku create --stack cedar
  1. Point your custom domain to your heroku app: https://devcenter.heroku.com/articles/custom-domains

Create and save app API keys

You don't have to use all the apps. Just set up the apps you want. If you have an app already registered to use on localhost or another domain, you'll have to register a new app for heroku b/c it's on a new domain.

heroku config:add TWITTER_KEY="Consumer key value"
heroku config:add TWITTER_SECRET="Consumer secret value"
heroku config:add INSTAGRAM_KEY="Client id value"
heroku config:add INSTAGRAM_SECRET="Client secret value"
heroku config:add TUMBLR_KEY="OAuth Consumer Key value"
heroku config:add TUMBLR_SECRET="Secret Key value"
heroku config:add FOURSQUARE_KEY="Client ID value"
heroku config:add FOURSQUARE_SECRET="Client ID value"
heroku config:add LASTFM_KEY="API Key value"
heroku config:add LASTFM_SECRET="secret value"

Create an Embedly key

Unlike apps above, you can use the same embed.ly key on multiple sites. Just watch out b/c you have to pay once you're over 10,000 requests/month.

  1. Create a free embed.ly account if you don't have one https://app.embed.ly/pricing/free
  2. Save your key on Heroku:
heroku config:add EMBEDLY_KEY="your embedly key"

Push your code to Heroku

git push heroku master

Create your user

heroku run rake db:setup
heroku run console
>> u = User.create(:username => 'yourusername', :email => '[email protected]', :name => 'yourname', :password => 'yourpassword', :password_confirmation => 'yourpassword')
>> u.description = "/images/temp_img.jpg" # Or put a new image in public/images and change to that filename
>> u.save

Login and authorize your apps

  1. Visit http://yourdomain.com/signin
  2. Signin with the username and password you chose above
  3. Go to http://yourdomain.com/accounts
  4. You should see all the services you registered earlier. If you don't see them, make sure you saved the keys on heroku!
  5. Click the buttons to add and authorize accounts

Import data

Adding an account doesn't import any data for you. To get data on the site, run:

$ heroku run console
>> User.first.linked_accounts.each{|a| a.import}

To get the full backlog (this can take a while!!!), run:

$ heroku run console
>> User.first.linked_accounts.each{|a| begin a.import_backlog; rescue; end}

Create a scheduler task to import data periodically

Heroku Scheduler will fire up a worker to import data. It works a lot like cron, but counts toward your dyno-hours so keep an eye on it. Running once an hour should be fine for most people.

  1. Install the addon:
heroku addons:add scheduler:standard
  1. Open the scheduler:
heroku addons:open scheduler
  1. On the dashboard, click add job. Set the job to run once an hour. The job is:
rake import_data
  1. Run it from the web to confirm it works.

Enjoy

Check out your site!

Updating

Want to change your profile image? Here's how!

  1. Add a new file to public/images
  2. Push it to heroku
git commit -am "new image"
git push heroku master
  1. Update your user record in the db:
u = User.first
u.description = "/images/new_file_name.png"
u.save
  1. Check it out!