Leaflet and Ruby on Rails with Google tiles

By Blaine Hatab | July 10, 2014

This is the code for a screencast showing how to integrate Leaflet with Ruby on Rails using Google tiles.

github code: https://github.com/openmindedinnovations/leaflet_rails_google_screencast

leaflet: http://leafletjs.com

Google maps api: http://developers.google.com/maps

leaflet-google.js: http://gist.github.com/crofty/2197042

youtube link: www.youtube.com/watch?v=dxghnTqwnvo

Custom font icons for Ruby on Rails with Icomoon

By Blaine Hatab | July 10, 2014

This is a screencast showing how to integrate a custom font icon pack using icomoon into your Ruby on Rails application. It has a rake task that makes the process very simple.

Rails Icomoon Auto Upload Gist

require 'rake'

namespace :icons do

  desc "update the icon font files from a newly downloaded zip file"
  task :update, [:zipfile] => [:environment] do |t, args|
    begin
      # Set absolute zipfile path in ~/Downloads
      zipfile = File.join(ENV['HOME'], 'Downloads', args[:zipfile].shellescape)

      # Set some dir vars
      tmpdir = File.join(Rails.root, 'tmp', 'iconfont')
      vendorfontsdir = File.join(Rails.root, 'vendor', 'assets', 'fonts')
      vendorcssdir = File.join(Rails.root, 'vendor', 'assets', 'stylesheets')

      # Create the tmp folder for extracted zip
      unless File.directory? tmpdir
        system "mkdir #{tmpdir}"
      end

      # Unzip that motherfucker
      system "unzip -u #{zipfile} -d #{tmpdir}"

      # Copy the font files
      Dir.glob(File.join(tmpdir, 'fonts', '*')) do |file|
        puts "Copying #{file} to #{vendorfontsdir}"
        system "cp #{file} #{vendorfontsdir}"
      end

      # Copy the stylesheet
      puts 'Copying the stylesheet'
      stylesheet = File.join(vendorcssdir, 'icons.css.scss')
      system "cp #{File.join(tmpdir, 'style.css')} #{stylesheet}"

      # Replace the font urls in the stylesheet
      puts 'Updating font URLs in stylesheet'
      stylesheet_content = File.read(stylesheet)
      stylesheet_content.gsub!("url('fonts/", "font-url('")
      File.open(stylesheet, 'w') do |file|
        file.write(stylesheet_content)
      end

    ensure
      puts 'Deleting tmp folder'
      if File.directory? tmpdir
        system "rm -rf #{tmpdir}"
      end

    end
  end

end

Gist of rake task
https://gist.github.com/uxtronaut/a7c89f7dceee1e4b0f6f#file-icons-rake

Uxtronaut blog on icomoon/gist
http://uxtronaut.com/post/90179414626/rails-icomoon-rake-task

youtube link
https://www.youtube.com/watch?v=X5eT9YOS5S0

github before code
https://github.com/openmindedinnovations/icomoon_screencast_before

github after code
https://github.com/openmindedinnovations/icomoon_screencast_after