[★] Cleaned up the Makefile and got the source code inline builder working.

This commit is contained in:
Elf M. Sternberg 2016-02-13 12:39:14 -08:00
parent 5d8009bf31
commit 1c89e0bc2d
4 changed files with 70 additions and 1 deletions

View File

@ -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

View File

@ -25,6 +25,11 @@
(defn home []
(send-from-directory "static" "index.html")))
(with-decorator
(.route app "/oh/hours/<start:start>")
(print start)
(jsonify { start: start }))
;(with-decorator
; (.route app "/")
; (defn hello []

12
source/index.coffee Normal file
View File

@ -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)

46
source/officehours.coffee Normal file
View File

@ -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')))