Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simple application which using backbone.offline
- Loading branch information
0 parents
commit 7c60084
Showing
66 changed files
with
1,047 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Ignore bundler config | ||
/.bundle | ||
|
||
# Ignore local database configuration | ||
/config/database.yml | ||
|
||
# Ignore all logfiles and tempfiles | ||
/log/*.log | ||
/tmp | ||
|
||
# OS X specific file | ||
.DS_Store | ||
|
||
# Ignore sprockets generated files | ||
public/assets/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--colour --format documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'rails', '3.2.2' | ||
|
||
gem 'pg' | ||
|
||
# Gems used only for assets and not required | ||
# in production environments by default. | ||
group :assets do | ||
gem 'sass-rails', '~> 3.2.3' | ||
gem 'coffee-rails', '~> 3.2.1' | ||
gem 'uglifier', '>= 1.0.3' | ||
gem 'zurb-foundation' | ||
gem 'jquery-rails' | ||
gem 'rails-backbone' | ||
gem 'eco' | ||
end | ||
|
||
gem 'rspec-rails', groups: [:development, :test] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
actionmailer (3.2.2) | ||
actionpack (= 3.2.2) | ||
mail (~> 2.4.0) | ||
actionpack (3.2.2) | ||
activemodel (= 3.2.2) | ||
activesupport (= 3.2.2) | ||
builder (~> 3.0.0) | ||
erubis (~> 2.7.0) | ||
journey (~> 1.0.1) | ||
rack (~> 1.4.0) | ||
rack-cache (~> 1.1) | ||
rack-test (~> 0.6.1) | ||
sprockets (~> 2.1.2) | ||
activemodel (3.2.2) | ||
activesupport (= 3.2.2) | ||
builder (~> 3.0.0) | ||
activerecord (3.2.2) | ||
activemodel (= 3.2.2) | ||
activesupport (= 3.2.2) | ||
arel (~> 3.0.2) | ||
tzinfo (~> 0.3.29) | ||
activeresource (3.2.2) | ||
activemodel (= 3.2.2) | ||
activesupport (= 3.2.2) | ||
activesupport (3.2.2) | ||
i18n (~> 0.6) | ||
multi_json (~> 1.0) | ||
arel (3.0.2) | ||
builder (3.0.0) | ||
coffee-rails (3.2.2) | ||
coffee-script (>= 2.2.0) | ||
railties (~> 3.2.0) | ||
coffee-script (2.2.0) | ||
coffee-script-source | ||
execjs | ||
coffee-script-source (1.2.0) | ||
diff-lcs (1.1.3) | ||
eco (1.0.0) | ||
coffee-script | ||
eco-source | ||
execjs | ||
eco-source (1.1.0.rc.1) | ||
ejs (1.0.0) | ||
erubis (2.7.0) | ||
execjs (1.3.0) | ||
multi_json (~> 1.0) | ||
hike (1.2.1) | ||
i18n (0.6.0) | ||
journey (1.0.3) | ||
jquery-rails (2.0.1) | ||
railties (>= 3.2.0, < 5.0) | ||
thor (~> 0.14) | ||
json (1.6.5) | ||
mail (2.4.1) | ||
i18n (>= 0.4.0) | ||
mime-types (~> 1.16) | ||
treetop (~> 1.4.8) | ||
mime-types (1.17.2) | ||
multi_json (1.1.0) | ||
pg (0.13.2) | ||
polyglot (0.3.3) | ||
rack (1.4.1) | ||
rack-cache (1.1) | ||
rack (>= 0.4) | ||
rack-ssl (1.3.2) | ||
rack | ||
rack-test (0.6.1) | ||
rack (>= 1.0) | ||
rails (3.2.2) | ||
actionmailer (= 3.2.2) | ||
actionpack (= 3.2.2) | ||
activerecord (= 3.2.2) | ||
activeresource (= 3.2.2) | ||
activesupport (= 3.2.2) | ||
bundler (~> 1.0) | ||
railties (= 3.2.2) | ||
rails-backbone (0.7.0) | ||
coffee-script (~> 2.2.0) | ||
ejs (~> 1.0.0) | ||
railties (>= 3.1.0) | ||
railties (3.2.2) | ||
actionpack (= 3.2.2) | ||
activesupport (= 3.2.2) | ||
rack-ssl (~> 1.3.2) | ||
rake (>= 0.8.7) | ||
rdoc (~> 3.4) | ||
thor (~> 0.14.6) | ||
rake (0.9.2.2) | ||
rdoc (3.12) | ||
json (~> 1.4) | ||
rspec (2.8.0) | ||
rspec-core (~> 2.8.0) | ||
rspec-expectations (~> 2.8.0) | ||
rspec-mocks (~> 2.8.0) | ||
rspec-core (2.8.0) | ||
rspec-expectations (2.8.0) | ||
diff-lcs (~> 1.1.2) | ||
rspec-mocks (2.8.0) | ||
rspec-rails (2.8.1) | ||
actionpack (>= 3.0) | ||
activesupport (>= 3.0) | ||
railties (>= 3.0) | ||
rspec (~> 2.8.0) | ||
sass (3.1.15) | ||
sass-rails (3.2.4) | ||
railties (~> 3.2.0) | ||
sass (>= 3.1.10) | ||
tilt (~> 1.3) | ||
sprockets (2.1.2) | ||
hike (~> 1.2) | ||
rack (~> 1.0) | ||
tilt (~> 1.1, != 1.3.0) | ||
thor (0.14.6) | ||
tilt (1.3.3) | ||
treetop (1.4.10) | ||
polyglot | ||
polyglot (>= 0.3.1) | ||
tzinfo (0.3.31) | ||
uglifier (1.2.3) | ||
execjs (>= 0.3.0) | ||
multi_json (>= 1.0.2) | ||
zurb-foundation (2.2.0.1) | ||
jquery-rails (>= 1.0) | ||
rails (~> 3.1) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
coffee-rails (~> 3.2.1) | ||
eco | ||
jquery-rails | ||
pg | ||
rails (= 3.2.2) | ||
rails-backbone | ||
rspec-rails | ||
sass-rails (~> 3.2.3) | ||
uglifier (>= 1.0.3) | ||
zurb-foundation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Simple web-application for your dreams |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env rake | ||
# Add your own tasks in files placed in lib/tasks ending in .rake, | ||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. | ||
|
||
require File.expand_path('../config/application', __FILE__) | ||
|
||
Dreamer::Application.load_tasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# This is a manifest file that'll be compiled into application.js, which will include all the files | ||
# listed below. | ||
# | ||
# Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, | ||
# or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. | ||
# | ||
# It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the | ||
# the compiled file. | ||
# | ||
# WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD | ||
# GO AFTER THE REQUIRES BELOW. | ||
# | ||
#= require jquery | ||
#= require jquery_ujs | ||
#= require underscore | ||
#= require backbone | ||
#= require backbone.offline | ||
# | ||
#= require dreamer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class App.Collections.Dreams extends Backbone.Collection | ||
model: App.Models.Dream | ||
url: '/api/dreams' | ||
|
||
initialize: -> | ||
@storage = new Storage('dreams', this) | ||
|
||
comparator: (idea) -> | ||
(new Date(idea.get 'created_at')).getTime() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#= require_self | ||
#= require_tree ../templates | ||
#= require_tree ./models | ||
#= require_tree ./collections | ||
#= require_tree ./views | ||
|
||
window.l = (value) -> console.log(value) | ||
|
||
window.keys = | ||
backspace: 8 | ||
enter: 13 | ||
left: 37 | ||
up: 38 | ||
right: 39 | ||
down: 40 | ||
|
||
window.App = | ||
Models: {} | ||
Collections: {} | ||
Views: {} | ||
Utils: {} | ||
|
||
init: (options) -> | ||
App.dreams = new App.Collections.Dreams() | ||
App.dreams.fetch() | ||
|
||
indexView = new App.Views.DreamsIndex() | ||
$('#content').append indexView.render().el | ||
|
||
countView = new App.Views.DreamsCount() | ||
$('#content').append countView.render().el | ||
|
||
$ -> | ||
App.init() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
class App.Models.Dream extends Backbone.Model |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class App.Views.DreamsCount extends Backbone.View | ||
template: JST['dreams/count'] | ||
className: 'three columns' | ||
id: 'count' | ||
|
||
events: | ||
'click .full': 'fullSync' | ||
'click .part': 'incrementalSync' | ||
|
||
initialize: -> | ||
App.dreams.on('reset add destroy', this.render) | ||
|
||
render: => | ||
$(this.el).html @template count: App.dreams.length | ||
return this | ||
|
||
fullSync: (event) -> | ||
App.dreams.storage.fullSync() | ||
return false | ||
|
||
incrementalSync: (event) -> | ||
App.dreams.storage.incrementalSync() | ||
return false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
class App.Views.DreamsItem extends Backbone.View | ||
template: JST['dreams/dream'] | ||
className: 'panel dream' | ||
|
||
events: | ||
'click': 'select' | ||
'keydown': 'keydown' | ||
'focusout p': 'save' | ||
|
||
initialize: (options) -> | ||
{@parent} = options | ||
@model.on('change', this.render) | ||
@model.on('destroy', => $(@el).remove()) | ||
|
||
render: => | ||
$(@el).html @template(@model.toJSON()) | ||
$(@el).attr('id', @model.id) | ||
@oldValue = @model.get('name') | ||
@needSync = false | ||
|
||
return this | ||
|
||
select: (event) => | ||
@parent.deactivateDream() | ||
@parent.activeDreamId = @model.id | ||
|
||
$(@el).addClass('active') | ||
this.$('p').attr('contenteditable', 'true') | ||
this.$('p').focus() | ||
|
||
keydown: (event) -> | ||
startPosition = document.getSelection().baseOffset | ||
value = this.$('p').html() | ||
totalPosition = value.length | ||
|
||
switch event.keyCode | ||
when keys.left then return @parent.up() if startPosition is 0 | ||
when keys.right then return @parent.down() if startPosition is totalPosition | ||
when keys.enter then return @parent.down() | ||
when keys.backspace then return this.destroy() if value is '<br>' or event.ctrlKey | ||
|
||
save: (event) -> | ||
newValue = this.$('p').html() | ||
|
||
if newValue isnt @oldValue and newValue isnt '<br>' | ||
@needSync = true | ||
@oldValue = newValue | ||
@model.save name: newValue | ||
|
||
destroy: -> | ||
@parent.up() | ||
@model.destroy() | ||
this.remove() | ||
|
||
return false |
Oops, something went wrong.