tatemae / muck-engine

The heart of all that is muck

This URL has Read+Write access

name age message
file .gitignore Sat Nov 07 10:17:53 -0800 2009 fixed gem paths [jbasdf]
file MIT-LICENSE Thu Nov 05 16:57:52 -0800 2009 initial commit [jbasdf]
file README.rdoc Thu Nov 05 16:57:52 -0800 2009 initial commit [jbasdf]
file Rakefile Thu Nov 12 14:52:46 -0800 2009 Released new gem [jbasdf]
file VERSION Loading commit data...
directory app/
directory config/ Wed Nov 25 09:53:28 -0800 2009 added routes file [jbasdf]
directory db/ Thu Nov 05 16:57:52 -0800 2009 initial commit [jbasdf]
file install.rb Thu Nov 05 16:57:52 -0800 2009 initial commit [jbasdf]
directory lib/
directory locales/ Thu Nov 05 16:57:52 -0800 2009 initial commit [jbasdf]
file muck-engine.gemspec
directory public/
directory rails/ Tue Dec 15 14:40:56 -0800 2009 added populate methods [jbasdf]
directory rails_i18n/ Tue Dec 15 08:18:55 -0800 2009 fixed translation [jbasdf]
directory tasks/ Thu Nov 05 16:57:52 -0800 2009 initial commit [jbasdf]
directory test/ Mon Dec 21 10:34:21 -0800 2009 added icon related methods [jbasdf]
file uninstall.rb Thu Nov 05 16:57:52 -0800 2009 initial commit [jbasdf]
README.rdoc

MuckEngine

The muck engine is forms the basis for the muck framework and includes basic functionality utilized by the various muck engines.

The easiest way to get started with muck is to generate your application using a template:

  $ rails <your-app> -m http://github.com/jbasdf/rails-templates/raw/master/muck.rb

Add optional functionality with the following command:

  $ rake rails:template LOCATION=http://github.com/jbasdf/rails-templates/raw/master/mucktoo.rb

Installation

  sudo gem install mislav-will_paginate -s 'http://gems.github.com'

  sudo gem install muck-engine

Setup

Be sure to include the muck_engine tasks in your Rakefile:

  require 'muck_engine'
  require 'muck_engine/tasks'

Add a method to application_controller.rb that will determine which users have access to the admin section of the website

  # called by Admin::Muck::BaseController to check whether or not the
  # user should have access to the admin UI
  def admin_access_required
    access_denied unless admin?
  end

Muck provides a number of methods that can set the current locale. Add a before filter and method to application_controller.rb

  before_filter :set_locale

Add a set_locale method:

  def set_locale
    discover_locale
  end

The set_locale method can use discover_locale to try various methods of finding the proper locale or it can call any of the methods individually:

  def discover_locale
    I18n.locale = extract_locale_from_tld || extract_locale_from_subdomain || extract_locale_from_headers || extract_locale_from_user_selection || extract_locale_from_browser || I18n.default_locale
  end

Usage

  If your application includes a locale switching menu, you would then have something like this in it:
  link_to("Deutsch", "#{APP_CONFIG[:deutsch_website_url]}#{request.env['REQUEST_URI']}")

Localization

Muck Engine comes with translations from the rails-i18n repository (github.com/svenfuchs/rails-i18n)

Layout

The muck template will build your basic application and construct all the needed files and configuration.

If you build your own layout be sure to include the following script in your layout or the javascript in the system won’t work:

  <script type="text/javascript" language="JavaScript">
    <%= yield :javascript %>
  </script>

You can customize your email template by overriding the existing layouts. Simply add email_default.text.html.erb and email_default.text.plain.erb views/layouts. This will build templates for html and plain text emails. For an example of each look at the views/layouts directory in this project.

iPhone

To add detection for the iPhone just add this to the top of your controller:

  before_filter :adjust_format_for_iphone

CSS

The css provided by the muck engine comes from blueprint: www.blueprintcss.org/

We’ve also included a liquid version: www.ixda.org/discuss.php?post=23298&search=blueprint

And icons: www.ajaxbestiary.com/Labs/SilkSprite/

Javascript

The muck engine uses jRails and thus jQuery for javascript: ennerchi.com/projects/jrails

Other Javascript libraries.

Muck engine installs the following javascript libraries: jGrowl - www.stanlemon.net/projects/jgrowl.html fancybox - fancy.klade.lv/home easing - gsgd.co.uk/sandbox/jquery/easing/ fancyzoom - orderedlist.com/articles/fancyzoom-meet-jquery

Rake tasks

The muck engine comes with an abundance of rake tasks mostly meant for development of muck engines. If you want to use these tasks be sure that you first do a sudo install muck-engine. Next define the muck gems you are using in a file RAILS_ROOT/lib/tasks/muck.rake. Here’s an example taken from the muck project:

  require 'rake'
  begin
    require 'git'
  rescue LoadError
    puts "git gem not installed.  If git functionality is required run 'sudo gem install git'"
  end
  require 'fileutils'

  namespace :muck do

    def muck_gems
      ['cms-lite', 'disguise', 'uploader', 'muck-solr', 'muck-raker', 'muck-engine',
      'muck-users', 'muck-activities', 'muck-comments', 'muck-profiles', 'muck-friends',
      'muck-contents', 'muck-blogs', 'muck-shares'] #'muck-invites'
    end

    desc 'Translate muck and all themes from English into all languages supported by Google'
    task :translate => :environment do
      puts 'translating muck'
      system("babelphish -o -y #{RAILS_ROOT}/config/locales/en.yml")
      theme_path = File.join(RAILS_ROOT, 'themes')
      Dir.glob("#{theme_path}/*").each do |next_file|
        if File.directory?(next_file)
          file = File.join(next_file, 'locales', 'en.yml')
          system("babelphish -o -y #{file}")
        end
      end
    end

    desc "Translate all muck related projects and gems"
    task :translate_all do
      Rake::Task[ "muck:translate" ].execute
      Rake::Task[ "muck:translate_gems" ].execute
      puts 'finished translations'
    end

    desc "Gets everything ready for a release. Translates muck + gems, release gems, commits gems translates muck, writes versions into muck and then commits muck.  This takes a while"
    task :prepare_release do
      # Rake::Task[ "muck:commit_gems" ].execute
      # Rake::Task[ "muck:pull_gems" ].execute
      Rake::Task[ "muck:translate_all" ].execute
      Rake::Task[ "muck:release_gems" ].execute
      Rake::Task[ "muck:commit_gems" ].execute
      Rake::Task[ "muck:push_gems" ].execute
      Rake::Task[ "muck:versions" ].execute
      # Commit and push muck
      git_commit("#{projects_path}/muck", "Updated gem versions")
      git_pull("#{projects_path}/muck")
      git_push("#{projects_path}/muck")
      puts "Don't forget to install the new gems on the server"
    end

  end

Copyright © 2009 Tatemai, released under the MIT license