pullentity-backbone 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.DS_Store +0 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +1 -0
- data/lib/pullentity/backbone/version.rb +5 -0
- data/lib/pullentity/backbone.rb +7 -0
- data/pullentity-backbone.gemspec +23 -0
- data/vendor/assets/.DS_Store +0 -0
- data/vendor/assets/javascripts/.DS_Store +0 -0
- data/vendor/assets/javascripts/backbone/.DS_Store +0 -0
- data/vendor/assets/javascripts/backbone/backbone.js +1571 -0
- data/vendor/assets/javascripts/backbone/underscore.js +1227 -0
- data/vendor/assets/javascripts/bootstrap.js +1964 -0
- data/vendor/assets/javascripts/bootstrap.min.js +6 -0
- data/vendor/assets/javascripts/handlebars.js +2278 -0
- data/vendor/assets/javascripts/pullentity-backbone/.DS_Store +0 -0
- data/vendor/assets/javascripts/pullentity-backbone/app/helpers/app_helper.js.coffee +13 -0
- data/vendor/assets/javascripts/pullentity-backbone/app/models/project.js.coffee +11 -0
- data/vendor/assets/javascripts/pullentity-backbone/app/models/section.js.coffee +13 -0
- data/vendor/assets/javascripts/pullentity-backbone/app/models/site.js.coffee +7 -0
- data/vendor/assets/javascripts/pullentity-backbone/app/routers/router.coffee +7 -0
- data/vendor/assets/javascripts/pullentity-backbone/app/site.js.coffee +42 -0
- data/vendor/assets/javascripts/pullentity-backbone/app/views/main.js.coffee +155 -0
- data/vendor/assets/javascripts/pullentity-backbone/application.js.coffee +8 -0
- data/vendor/assets/javascripts/pullentity.js +3 -0
- data/vendor/assets/stylesheets/.DS_Store +0 -0
- data/vendor/assets/stylesheets/bootstrap.css +4677 -0
- data/vendor/assets/stylesheets/bootstrap.min.css +9 -0
- data/vendor/assets/stylesheets/pullentity/themes/default.css.scss +0 -0
- data/vendor/assets/stylesheets/pullentity.css.scss.erb +0 -0
- metadata +116 -0
Binary file
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Handlebars.registerHelper 'SectionUrl', (section)->
|
2
|
+
"/#sections/#{section.id}"
|
3
|
+
|
4
|
+
Handlebars.registerHelper 'ProjectUrl', (project)->
|
5
|
+
"/#projects/#{project.id}"
|
6
|
+
|
7
|
+
Handlebars.registerHelper 'ProjectImg', (version)->
|
8
|
+
v = version ? version : "url"
|
9
|
+
return if _.isEmpty(@photos[0])
|
10
|
+
@photos[0].image.image[v].url
|
11
|
+
|
12
|
+
Handlebars.registerHelper 'PhotoImg', (version)->
|
13
|
+
@image.image[version].url
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class Pullentity.Models.Project extends Backbone.Model
|
2
|
+
|
3
|
+
class Pullentity.Collections.Projects extends Backbone.Collection
|
4
|
+
|
5
|
+
model: Pullentity.Models.Project
|
6
|
+
|
7
|
+
url : ()->
|
8
|
+
if @id
|
9
|
+
"#{Pullentity.Domain}.#{Pullentity.host}/api/v1/site/projects/#{@id}"
|
10
|
+
else
|
11
|
+
"#{Pullentity.Domain}.#{Pullentity.host}/api/v1/site/projects"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Pullentity.Models.Section extends Backbone.Model
|
2
|
+
|
3
|
+
|
4
|
+
class Pullentity.Collections.Sections extends Backbone.Collection
|
5
|
+
|
6
|
+
model: Pullentity.Models.Section
|
7
|
+
|
8
|
+
url : ()->
|
9
|
+
if @id
|
10
|
+
"#{Pullentity.Domain}.#{Pullentity.host}/api/v1/site/sections/#{@id}"
|
11
|
+
else
|
12
|
+
"#{Pullentity.Domain}.#{Pullentity.host}/api/v1/site/sections"
|
13
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#= require_self
|
2
|
+
#= require_tree ./helpers
|
3
|
+
# require_tree ../templates
|
4
|
+
#= require_tree ./models
|
5
|
+
#= require_tree ./views
|
6
|
+
#= require_tree ./routers
|
7
|
+
|
8
|
+
if _.isUndefined( window.console)
|
9
|
+
window.console =
|
10
|
+
log: ->
|
11
|
+
alert: ->
|
12
|
+
info: ->
|
13
|
+
|
14
|
+
|
15
|
+
console.log window.pullentity_domain
|
16
|
+
if _.isUndefined( window.pullentity_domain) or window.pullentity_domain == "http://"
|
17
|
+
alert("Please configure the domain name in pullentity.yml file \n Or run > pullentity setup your@email.com. in console")
|
18
|
+
false
|
19
|
+
|
20
|
+
window.Pullentity =
|
21
|
+
Domain: window.pullentity_domain
|
22
|
+
host: "pullentity.com" # "pullentity.dev:3000" #
|
23
|
+
Models: {}
|
24
|
+
Collections: {}
|
25
|
+
Routers: {}
|
26
|
+
Views: {
|
27
|
+
Commons: {}
|
28
|
+
}
|
29
|
+
|
30
|
+
Helpers:
|
31
|
+
BootstrapHelpers: {}
|
32
|
+
|
33
|
+
#if !Backbone.history.started
|
34
|
+
# Backbone.history.start()
|
35
|
+
# Backbone.history.started = true
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
@@ -0,0 +1,155 @@
|
|
1
|
+
class Pullentity.Views.Commons.Main extends Backbone.View
|
2
|
+
el: "body"
|
3
|
+
|
4
|
+
events:
|
5
|
+
"click": "hideSuggests"
|
6
|
+
|
7
|
+
initialize: ->
|
8
|
+
|
9
|
+
#console.info "pullentity LOADED!!!"
|
10
|
+
@site = new Pullentity.Models.Site(id: "michelsongs")
|
11
|
+
@site.on("change", @initModels )
|
12
|
+
@site.fetch()
|
13
|
+
|
14
|
+
initModels: ()=>
|
15
|
+
#console.log("init models")
|
16
|
+
@sections = new Pullentity.Collections.Sections(@site.get('sections'))
|
17
|
+
@projects = new Pullentity.Collections.Projects(@site.get('projects'))
|
18
|
+
#debugger
|
19
|
+
#console.log("Site Loaded!")
|
20
|
+
#console.log @sections
|
21
|
+
#console.log @projects
|
22
|
+
@setTitle()
|
23
|
+
|
24
|
+
@render()
|
25
|
+
|
26
|
+
@setupLinks()
|
27
|
+
|
28
|
+
# quizas cargar router acá
|
29
|
+
|
30
|
+
setTitle: ()=>
|
31
|
+
#console.log @site.get("name")
|
32
|
+
document.title = "#{@site.get("name")} pullentity site"
|
33
|
+
|
34
|
+
initRouter: ()=>
|
35
|
+
@app_router = new Pullentity.Routers.main
|
36
|
+
|
37
|
+
@app_router.on 'route:defaultRoute', (actions)=>
|
38
|
+
#console.log(actions) # See more at: http://backbonetutorials.com/what-is-a-router
|
39
|
+
#console.log("init routes")
|
40
|
+
@render_home_project()
|
41
|
+
|
42
|
+
@app_router.on 'route:getProject', (id)=>
|
43
|
+
#console.log("get project #{id}")
|
44
|
+
@find_project_by_id(id)
|
45
|
+
|
46
|
+
@app_router.on 'route:getSection', (id)=>
|
47
|
+
#console.log("get section #{id}")
|
48
|
+
@find_in_section(id)
|
49
|
+
|
50
|
+
Backbone.history.start(pushState: true)
|
51
|
+
|
52
|
+
render: ()=>
|
53
|
+
#console.info("should render layout")
|
54
|
+
source = $("#layout").html()
|
55
|
+
@theme_templates = $(".pullentity-themes")
|
56
|
+
@layout = Handlebars.compile(source)
|
57
|
+
#console.log(@site.attributes)
|
58
|
+
$("body").html(@layout(@site.attributes))
|
59
|
+
@initRouter()
|
60
|
+
|
61
|
+
render_home_project: ()=>
|
62
|
+
@current_project = @projects.findWhere({home: true })
|
63
|
+
@find_theme_for_project()
|
64
|
+
@render_project()
|
65
|
+
|
66
|
+
find_project_by_id: (id)=>
|
67
|
+
@current_project = @projects.findWhere({id: parseInt(id) })
|
68
|
+
@find_theme_for_project()
|
69
|
+
@render_project()
|
70
|
+
|
71
|
+
find_in_section: (id)=>
|
72
|
+
@current_section = @sections.findWhere({ id: parseInt(id) })
|
73
|
+
@render_project_or_list(id)
|
74
|
+
|
75
|
+
render_project_or_list: (id)=>
|
76
|
+
switch @current_section.get("list_or_project")
|
77
|
+
when "project" then @render_project_theme()
|
78
|
+
when "list" then @render_list()
|
79
|
+
|
80
|
+
render_project_theme: ()=>
|
81
|
+
@current_project = @projects.findWhere(section_id: @current_section.id )
|
82
|
+
@find_theme_for_project()
|
83
|
+
@render_project()
|
84
|
+
|
85
|
+
render_list: ()=>
|
86
|
+
|
87
|
+
#si tiene theme para la lista
|
88
|
+
if @theme_list = @current_section.get("theme_template")
|
89
|
+
@current_theme_obj = @find_theme_for_list()
|
90
|
+
else
|
91
|
+
@current_theme_obj = _.find @theme_templates, (num)=>
|
92
|
+
if $(num).attr("id") == "list"
|
93
|
+
num
|
94
|
+
|
95
|
+
@find_projects_for_list(@current_section)
|
96
|
+
@render_handlebars()
|
97
|
+
$("#content").html(@current_template({section: @current_section.attributes, projects: @list_projects }))
|
98
|
+
|
99
|
+
render_project: ()=>
|
100
|
+
@render_handlebars()
|
101
|
+
$("#content").html(@current_template(@current_project.attributes))
|
102
|
+
|
103
|
+
find_theme_for_project: ()=>
|
104
|
+
@current_theme_obj = _.find @theme_templates, (num)=>
|
105
|
+
if $(num).attr("id") == @current_project.get("theme_template").name
|
106
|
+
num
|
107
|
+
console.error "theme \"#{@current_project.get("theme_template").name}\" does not exist" unless @current_theme_obj
|
108
|
+
|
109
|
+
find_theme_for_list: ()=>
|
110
|
+
#console.log("list with theme!")
|
111
|
+
name = @current_section.get("theme_template").name
|
112
|
+
theme = _.find @theme_templates, (num)=>
|
113
|
+
if $(num).attr("id") == name
|
114
|
+
num
|
115
|
+
theme ? theme : @render_with_error(name)
|
116
|
+
|
117
|
+
find_projects_for_list: (section)=>
|
118
|
+
@list_projects = _.filter @projects.toJSON(), (num)=>
|
119
|
+
if num.section.public_url == section.get("public_url")
|
120
|
+
num
|
121
|
+
|
122
|
+
render_with_error: (name)=>
|
123
|
+
$("#content").html("<pre>Couldn´t find template #{name} in /source/views/themes</pre>")
|
124
|
+
console.warn "Couldn´t find projects in #{name} yet"
|
125
|
+
|
126
|
+
render_handlebars: ()=>
|
127
|
+
try
|
128
|
+
@current_template = Handlebars.compile($(@current_theme_obj).html())
|
129
|
+
catch e
|
130
|
+
#console.error "error while creating Handlebars script out of template for [", $(@current_theme_obj), e
|
131
|
+
throw e
|
132
|
+
|
133
|
+
setupLinks: ()=>
|
134
|
+
# Globally capture clicks. If they are internal and not in the pass
|
135
|
+
# through list, route them through Backbone's navigate method.
|
136
|
+
$(document).on "click", "a[href^='/']", (event) =>
|
137
|
+
|
138
|
+
href = $(event.currentTarget).attr('href')
|
139
|
+
|
140
|
+
# chain 'or's for other black list routes
|
141
|
+
passThrough = href.indexOf('sign_out') >= 0
|
142
|
+
|
143
|
+
# Allow shift+click for new tabs, etc.
|
144
|
+
if !passThrough && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey
|
145
|
+
event.preventDefault()
|
146
|
+
|
147
|
+
# Remove leading slashes and hash bangs (backward compatablility)
|
148
|
+
url = href.replace(/^\//,'').replace('\#\/','')
|
149
|
+
|
150
|
+
# Instruct Backbone to trigger routing events
|
151
|
+
@app_router.navigate url, { trigger: true }
|
152
|
+
|
153
|
+
return false
|
154
|
+
|
155
|
+
layout = new Pullentity.Views.Commons.Main
|
Binary file
|