Permalink
Browse files

adopt handlebars_assets and hamlbars to render file items

  • Loading branch information...
shelling committed Dec 5, 2012
1 parent 7923ac4 commit 04c8ce2df2be59103bb71fe24fc1a739734322d6
View
@@ -1,14 +1,16 @@
source :rubygems
gem 'unicorn'
-gem 'sinatra'
+gem 'sinatra', :require => "sinatra/base"
gem 'sinatra-contrib', :require => "sinatra/contrib/all"
gem 'sequel'
gem 'mysql2'
gem 'activesupport', :require => "active_support/all"
gem 'uuid'
gem 'mogilefs-client', :require => "mogilefs"
gem 'sprockets', "~> 2.0"
+gem 'handlebars_assets'
+gem 'hamlbars'
gem 'haml', "~> 3.2.0.rc.1"
gem 'sass'
gem 'sprockets-sass'
View
@@ -13,9 +13,20 @@ GEM
fssm (>= 0.2.7)
sass (~> 3.1)
eventmachine (1.0.0)
+ execjs (1.4.0)
+ multi_json (~> 1.0)
fssm (0.2.9)
haml (3.2.0.rc.1)
tilt
+ hamlbars (1.1.0)
+ execjs (>= 1.2)
+ haml
+ sprockets
+ tilt
+ handlebars_assets (0.7.1)
+ execjs (>= 1.2.9)
+ sprockets (>= 2.0.3)
+ tilt
hike (1.2.1)
i18n (0.6.1)
kgio (2.7.4)
@@ -68,6 +79,8 @@ DEPENDENCIES
bootstrap-sass
compass
haml (~> 3.2.0.rc.1)
+ hamlbars
+ handlebars_assets
mogilefs-client
mysql2
sass
@@ -1,23 +1,9 @@
-var DropboxIO = {
- Model: {},
- Collection: {},
- View: {},
- Router: {},
- initialize: function() {
- }
-};
-
-DropboxIO.Model.File = Backbone.Model.extend({
- initialize: function() {
- },
-});
-
-DropboxIO.Collection.Files = Backbone.Collection.extend({
- initialize: function() {
- },
- model: DropboxIO.Model.File,
- url: "/file/list",
-});
+//=require handlebars.runtime
+//=require handlebars
+//=require dropboxio
+//=require_tree ./models
+//=require_tree ./collections
+//=require_tree ../templates
$(document).ready(function() {
@@ -32,7 +18,7 @@ $(document).ready(function() {
done: function(e, data) {
new DropboxIO.Collection.Files(data.result).each(function(file) {
$(".filelist").append(
- $("<li>").html(file.get("filename"))
+ DropboxIO.Template["file"](file.toJSON())
);
});
$(this).find(".fileupload-progress")
@@ -55,7 +41,7 @@ $(document).ready(function() {
success: function(self, response) {
self.each(function(file) {
$(".filelist").append(
- $("<li>").html(file.get("filename"))
+ DropboxIO.Template["file"](file.toJSON())
);
});
},
@@ -0,0 +1,6 @@
+DropboxIO.Collection.Files = Backbone.Collection.extend({
+ initialize: function() {
+ },
+ model: DropboxIO.Model.File,
+ url: "/file/list",
+});
@@ -0,0 +1,9 @@
+var DropboxIO = {
+ Model: {},
+ Collection: {},
+ View: {},
+ Router: {},
+ Template: {},
+ initialize: function() {
+ }
+};
@@ -0,0 +1,4 @@
+DropboxIO.Model.File = Backbone.Model.extend({
+ initialize: function() {
+ },
+});
@@ -0,0 +1 @@
+%li= "{{ filename }}"
View
@@ -4,8 +4,10 @@ require "environments"
map "/assets" do
environment = Sprockets::Environment.new
+ environment.append_path HandlebarsAssets.path
environment.append_path "assets/stylesheets"
environment.append_path "assets/javascripts"
+ environment.append_path "assets/templates"
run environment
end
View
@@ -17,6 +17,8 @@ class App < Sinatra::Base
Sequel::Model.plugin :timestamps, :update_on_create => true
Sequel::Model.plugin :validation_helpers
+ Hamlbars::Template.template_destination = "DropboxIO.Template"
+
enable :logging
helpers do

0 comments on commit 04c8ce2

Please sign in to comment.