Skip to content

Instantly share code, notes, and snippets.

View boxxxie's full-sized avatar
👙
disrupting absurdism

Paul Iannazzo boxxxie

👙
disrupting absurdism
View GitHub Profile
(ns touchViews.core
(:use clojure.pprint)
(:require [com.ashafa.clutch :as db])
(:require [com.ashafa.clutch.utils :as utils])
(:require [com.ashafa.clutch.http-client :as http])
(:require [clojure.contrib.json :as json])
(:require [clojure.walk :as walk])
(:require [clojure.contrib.string :as str])
(:use [clojure.pprint])
(:gen-class
(defproject touchViews "1.0.0-SNAPSHOT"
:description "touch views in the DB forever via futures"
:dependencies [[org.clojure/clojure "1.2.1"]
[org.clojars.jhowarth/clojure-contrib "1.2.0-RC3"]
[com.ashafa/clutch "0.2.4"]]
:dev-dependencies [[swank-clojure "1.4.0-SNAPSHOT"]])
(ns touchViews.core
...
(:gen-class
:methods [#^{:static true}
[initViews [] void]
]))
...
(defn -initViews []
function object2array(obj,prefix){
var keys = _.keys(obj);
var vals = _.values(obj);
var firstStep = _(_.zip(keys,vals)).chain()
.map(function(keyVal){
var key = keyVal[0];
var val = keyVal[1];
return {name: applyPrefix(key,prefix), value:val};
})
.value();
$(html).find('.checkAlltimes').first()
.toggle(function() {
$(this).prop('checked', 'checked');
$(this).parents('li').find('.startTime, .endTime')
.each(function(){
$(this).parent().hide();
});
}, function() {
$(this).prop('checked', false);
$(this).parentsUntil('select').find(".startTime, .endTime")
var Donut = Backbone.Model.extend({});
var Donuts = Backbone.Collection.extend({
model : Donut,
url : "/donuts"
});
var bostonCream = new Donut({
name : "Bostan Cream",
cream_filled : true
/* i'm expecting the url() is http://localhost:5984/campaigns/AllDayAlltime but it comes out as http://localhost:5984/campaigns */
function doc_setup(){
var Campaign = Backbone.Model.extend({
urlRoot:"http://localhost:5984/campaigns"
});
var AllDayAlltime = new Campaign({url:"AllDayAlltime"});
console.log(AllDayAlltime.url());
};
//my models exist in this url
"http://localhost:5984/campaigns/[model id]"
//to get the list of my models i need to use this url
"http://localhost:5984/campaigns/_all_docs"
//how do i handle this in backbone?
var Campaign = Backbone.Model.extend(
{
idAttribute: "_id",
urlRoot:"http://localhost:5984/campaigns"
});
var Campaigns = Backbone.Collection.extend(
{
model: Campaign,
url:"http://localhost:5984/campaigns/_all_docs",
parse: function(response) {
/*
>>> campaignList.at(0).fetch()
GET http://localhost:5984/campaigns/_all_docs/AllCanadaAllTerminal
I want this to happen
GET http://localhost:5984/campaigns/AllCanadaAllTerminal
*/
var Campaign = Backbone.Model.extend(
{