[★] Serving up the require.js stuff properly, now getting transactions.
This commit is contained in:
parent
1c89e0bc2d
commit
07ae886569
12
Makefile
12
Makefile
|
@ -1,4 +1,12 @@
|
||||||
all: static/index.html static/index.js static/officehours.js
|
SOURCES = source/*.coffee source/*.haml main.hy
|
||||||
|
|
||||||
|
all: static/index.html static/index.js static/officehours.js main.py
|
||||||
|
|
||||||
|
# Needed because Flask's "debugger" setting doesn't grok
|
||||||
|
# Hy directly. Nuisance!
|
||||||
|
|
||||||
|
main.py:
|
||||||
|
hy2py main.hy > main.py
|
||||||
|
|
||||||
static/%.html: source/%.haml
|
static/%.html: source/%.haml
|
||||||
haml --unix-newlines --no-escape-attrs --double-quote-attributes $< > $@
|
haml --unix-newlines --no-escape-attrs --double-quote-attributes $< > $@
|
||||||
|
@ -9,4 +17,6 @@ static/%.js: source/%.coffee
|
||||||
clean:
|
clean:
|
||||||
rm static/*.html static/*.js
|
rm static/*.html static/*.js
|
||||||
|
|
||||||
|
watch:
|
||||||
|
while inotifywait $(SOURCES); do clear ; make all ; done
|
||||||
|
|
||||||
|
|
25
main.hy
25
main.hy
|
@ -26,9 +26,30 @@
|
||||||
(send-from-directory "static" "index.html")))
|
(send-from-directory "static" "index.html")))
|
||||||
|
|
||||||
(with-decorator
|
(with-decorator
|
||||||
(.route app "/oh/hours/<start:start>")
|
(.route app "/index.js")
|
||||||
|
(defn index []
|
||||||
|
(send-from-directory "static" "index.js")))
|
||||||
|
|
||||||
|
(with-decorator
|
||||||
|
(.route app "/officehours.js")
|
||||||
|
(defn officehours []
|
||||||
|
(send-from-directory "static" "officehours.js")))
|
||||||
|
|
||||||
|
(with-decorator
|
||||||
|
(.route app "/lib/<path:path>")
|
||||||
|
(defn lib [path]
|
||||||
|
(send-from-directory "static/lib" path)))
|
||||||
|
|
||||||
|
(with-decorator
|
||||||
|
(.route app "/oh/hours/<path:start>")
|
||||||
|
(defn defhours [start]
|
||||||
|
(jsonify { "start" start })))
|
||||||
|
|
||||||
|
(with-decorator
|
||||||
|
(.route app "/oh/hours/<path:start>")
|
||||||
|
(defn hours [start]
|
||||||
(print start)
|
(print start)
|
||||||
(jsonify { start: start }))
|
(jsonify { "start" start })))
|
||||||
|
|
||||||
;(with-decorator
|
;(with-decorator
|
||||||
; (.route app "/")
|
; (.route app "/")
|
||||||
|
|
|
@ -4,9 +4,12 @@ require.config
|
||||||
'jquery': './lib/jquery.min'
|
'jquery': './lib/jquery.min'
|
||||||
'backbone': './lib/backbone-min'
|
'backbone': './lib/backbone-min'
|
||||||
'json2': './lib/json2'
|
'json2': './lib/json2'
|
||||||
|
'domReady': './lib/domReady'
|
||||||
shim:
|
shim:
|
||||||
|
json2:
|
||||||
|
exports: 'JSON'
|
||||||
'backbone': ['json2']
|
'backbone': ['json2']
|
||||||
|
|
||||||
require ['backbone', 'json2'], () ->
|
require ['backbone', 'json2'], () ->
|
||||||
require ['officehours'], (start) ->
|
require ['officehours', 'domReady'], (start, ready) ->
|
||||||
$(start)
|
ready(start)
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
%head
|
%head
|
||||||
%title Appointment Calendar
|
%title Appointment Calendar
|
||||||
%link{:href => "/static/officehours.css", :rel => "stylesheet", :type => "text/css"}
|
%link{:href => "/static/officehours.css", :rel => "stylesheet", :type => "text/css"}
|
||||||
%script{:src => "static/officehours.js"}
|
%script{:src => "static/lib/require.js"}
|
||||||
|
%script{:src => "static/index.js"}
|
||||||
|
|
||||||
%body
|
%body
|
||||||
.container
|
.container
|
||||||
|
|
|
@ -10,13 +10,13 @@ define [
|
||||||
diff = d.getDate() - day + (if day == 0 then -6 else 1)
|
diff = d.getDate() - day + (if day == 0 then -6 else 1)
|
||||||
new Date d.setDate diff
|
new Date d.setDate diff
|
||||||
|
|
||||||
class Officehours
|
class OfficeHours extends Backbone.Model
|
||||||
start: null,
|
start: null,
|
||||||
|
|
||||||
url: ->
|
url: ->
|
||||||
if start isintanceof Date then "/oh/hours/#{urlEncode start}" else "/oh/hours/"
|
if @start instanceof Date then "/oh/hours/#{encodeURIComponent @start}" else "/oh/hours/"
|
||||||
|
|
||||||
initialize:
|
initialize: (model, option) ->
|
||||||
@start = monday(new Date)
|
@start = monday(new Date)
|
||||||
|
|
||||||
# This is going to go with the Google idea of a view and overlays:
|
# This is going to go with the Google idea of a view and overlays:
|
||||||
|
@ -25,22 +25,20 @@ define [
|
||||||
|
|
||||||
class Appointments extends Backbone.View
|
class Appointments extends Backbone.View
|
||||||
|
|
||||||
class OfficeHours extends Backbone.View
|
class OfficeHoursView extends Backbone.View
|
||||||
|
|
||||||
class DayView extends Backbone.View
|
class DayView extends Backbone.View
|
||||||
|
|
||||||
|
|
||||||
class CalendarView extends Backbone.View
|
class CalendarView extends Backbone.View
|
||||||
className 'calendar'
|
className: 'calendar'
|
||||||
|
|
||||||
|
events:
|
||||||
events
|
|
||||||
'click .forward': "nextWeek"
|
'click .forward': "nextWeek"
|
||||||
'click .backward': "lastWeek"
|
'click .backward': "lastWeek"
|
||||||
|
|
||||||
initialize: (options) ->
|
initialize: (options) ->
|
||||||
|
|
||||||
|
|
||||||
->
|
->
|
||||||
officehours = new OfficeHours
|
officehours = new OfficeHours()
|
||||||
$.when(officehours.fetch()).then(console.log(officehours.get('start')))
|
$.when(officehours.fetch()).then(console.log(officehours))
|
||||||
|
|
Loading…
Reference in New Issue