Skip to content

Instantly share code, notes, and snippets.

View joeljunstrom's full-sized avatar
🥰

Joel Junström joeljunstrom

🥰
  • Stockholm, Sweden
View GitHub Profile
$.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')
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
# 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
# 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
$.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');
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
apps_controller:
def search
@query = params[:query]
@search = App.search(@query)
respond_with(@search)
end
app.rb:
class << self
# 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']+'%')}
require File.dirname(__FILE__) + '/../test_helper'
class MashAppTest < ActiveSupport::TestCase
context "A MashApp instance" do
setup do
@mash_app = Factory.create(:mash_app)
end
---
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