From 1c89e0bc2db075660672586a09dd3a0f026a9c7e Mon Sep 17 00:00:00 2001 From: "Elf M. Sternberg" Date: Sat, 13 Feb 2016 12:39:14 -0800 Subject: [PATCH] =?UTF-8?q?[=E2=98=85]=20Cleaned=20up=20the=20Makefile=20a?= =?UTF-8?q?nd=20got=20the=20source=20code=20inline=20builder=20working.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 8 ++++++- main.hy | 5 +++++ source/index.coffee | 12 ++++++++++ source/officehours.coffee | 46 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 source/index.coffee create mode 100644 source/officehours.coffee diff --git a/Makefile b/Makefile index f45569e..ad3e844 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,12 @@ - +all: static/index.html static/index.js static/officehours.js static/%.html: source/%.haml haml --unix-newlines --no-escape-attrs --double-quote-attributes $< > $@ +static/%.js: source/%.coffee + coffee --compile -o $(dir $@) $< + +clean: + rm static/*.html static/*.js + diff --git a/main.hy b/main.hy index 1e2470c..9a858a4 100644 --- a/main.hy +++ b/main.hy @@ -25,6 +25,11 @@ (defn home [] (send-from-directory "static" "index.html"))) +(with-decorator + (.route app "/oh/hours/") + (print start) + (jsonify { start: start })) + ;(with-decorator ; (.route app "/") ; (defn hello [] diff --git a/source/index.coffee b/source/index.coffee new file mode 100644 index 0000000..1ed018c --- /dev/null +++ b/source/index.coffee @@ -0,0 +1,12 @@ +require.config + paths: + 'underscore': './lib/lodash' + 'jquery': './lib/jquery.min' + 'backbone': './lib/backbone-min' + 'json2': './lib/json2' + shim: + 'backbone': ['json2'] + +require ['backbone', 'json2'], () -> + require ['officehours'], (start) -> + $(start) diff --git a/source/officehours.coffee b/source/officehours.coffee new file mode 100644 index 0000000..f774af6 --- /dev/null +++ b/source/officehours.coffee @@ -0,0 +1,46 @@ +define [ + 'jquery', + 'underscore' + 'backbone' +], ($, _, Backbone) -> + + monday = (d) -> + d = new Date d + day = d.getDay() + diff = d.getDate() - day + (if day == 0 then -6 else 1) + new Date d.setDate diff + + class Officehours + start: null, + + url: -> + if start isintanceof Date then "/oh/hours/#{urlEncode start}" else "/oh/hours/" + + initialize: + @start = monday(new Date) + + # This is going to go with the Google idea of a view and overlays: + # given a parent object, and precise definitions of the base + # Calendar, OfficeHours and Appointments views, draw + + class Appointments extends Backbone.View + + class OfficeHours extends Backbone.View + + class DayView extends Backbone.View + + + class CalendarView extends Backbone.View + className 'calendar' + + + events + 'click .forward': "nextWeek" + 'click .backward': "lastWeek" + + initialize: (options) -> + + + -> + officehours = new OfficeHours + $.when(officehours.fetch()).then(console.log(officehours.get('start')))