This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn.tagList = function() { | |
return this.each(function() { | |
var $orginal = $(this), | |
$input = $('<input type="text">'), | |
$button = $('<button class="add_tag">Add</button>'), | |
$tag_list = $('<ul class="tags" />'), | |
$suggestions = $orginal.parents('form').find('div.popular.tags'), | |
current_value = $orginal.val(); | |
$orginal.parent() | |
.addClass('taggings') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AutoCompleteController < ActionController::Metal | |
def search_queries | |
sql = "SELECT name FROM tags WHERE name #{like_operator} #{quote(params['q']+'%')} LIMIT 10" | |
render ActiveRecord::Base.connection.select_values(sql).to_json | |
end | |
def tags | |
sql = "SELECT value | |
FROM search_queries |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Setting for open or closed tags by default | |
# Rails Core seems to think XHTML is cool, hard coded defaults and all | |
module ActionView::Helpers | |
module TagHelper | |
mattr_accessor :default_tags_to_open | |
self.default_tags_to_open = false | |
def tag(name, options = nil, open = ActionView::Helpers::TagHelper.default_tags_to_open, escape = true) | |
"<#{name}#{tag_options(options, escape) if options}#{open ? ">" : " />"}".html_safe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Setting for open or closed tags by default | |
module ActionView::Helpers | |
module TagHelper | |
mattr_accessor :default_tags_to_open | |
self.default_tags_to_open = false | |
def tag(name, options = nil, open = ActionView::Helpers::TagHelper.default_tags_to_open, escape = true) | |
"<#{name}#{tag_options(options, escape) if options}#{open ? ">" : " />"}".html_safe | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn.appForm = function() { | |
return this.each(function() { | |
var $search = $('<input type="search">'), | |
$button = $('<button>Search</button>'), | |
$result_container = $('<div id="app_search_result" />'), | |
$app_list = $('#apps'); | |
var $app_form = $(this).after($search, $button, $result_container).detach(); | |
$search.data('search_context', 'local'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var $search = $('<input type="search">'), | |
$button = $('<button>Search</button>'), | |
$result_container = $('<div id="app_search_result" />'), | |
$app_list = $('#apps'); | |
var $app_form = $(this).after($search, $button, $result_container).detach(); | |
$search.data('search_context', 'local'); | |
$search |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apps_controller: | |
def search | |
@query = params[:query] | |
@search = App.search(@query) | |
respond_with(@search) | |
end | |
app.rb: | |
class << self |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Allow the metal piece to run in isolation | |
require File.expand_path('../../../config/environment', __FILE__) unless defined?(Rails) | |
class AutoComplete | |
def self.call(env) | |
if env["PATH_INFO"] =~ /^\/auto_complete\/tags/ | |
params = Rack::Request.new(env).params | |
sql = "SELECT name | |
FROM tags | |
WHERE name LIKE #{ActiveRecord::Base.connection.quote(params['q']+'%')} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.dirname(__FILE__) + '/../test_helper' | |
class MashAppTest < ActiveSupport::TestCase | |
context "A MashApp instance" do | |
setup do | |
@mash_app = Factory.create(:mash_app) | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
cwd: /home/unicef/staging/current | |
port: "9070" | |
user: unicef | |
group: mongrel | |
environment: staging | |
address: 127.0.0.1 | |
pid_file: log/mongrel.pid | |
servers: 2 |