smithycms 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.md +142 -0
- data/Rakefile +27 -0
- data/app/assets/images/smithy/logo.png +0 -0
- data/app/assets/images/smithy/logo2.png +0 -0
- data/app/assets/javascripts/smithy/application.js +13 -0
- data/app/assets/javascripts/smithy/assets.js.coffee +35 -0
- data/app/assets/javascripts/smithy/guides.js +23 -0
- data/app/assets/javascripts/smithy/jquery-ui.min.js +5 -0
- data/app/assets/javascripts/smithy/nested_forms.js +55 -0
- data/app/assets/javascripts/smithy/page_contents.js +4 -0
- data/app/assets/javascripts/smithy/pages.js +41 -0
- data/app/assets/javascripts/smithy/settings.js +0 -0
- data/app/assets/javascripts/smithy/templates.js +25 -0
- data/app/assets/stylesheets/smithy/application.css.scss +29 -0
- data/app/assets/stylesheets/smithy/assets.css.scss +3 -0
- data/app/assets/stylesheets/smithy/bootstrap_and_overrides.css.scss +12 -0
- data/app/assets/stylesheets/smithy/content_blocks.css.scss +2 -0
- data/app/assets/stylesheets/smithy/forms.css.scss +3 -0
- data/app/assets/stylesheets/smithy/guides.css.scss +5 -0
- data/app/assets/stylesheets/smithy/layout.css.scss +113 -0
- data/app/assets/stylesheets/smithy/pages.css.scss +35 -0
- data/app/assets/stylesheets/smithy/templates.css.scss +14 -0
- data/app/controllers/smithy/assets_controller.rb +50 -0
- data/app/controllers/smithy/base_controller.rb +14 -0
- data/app/controllers/smithy/caches_controller.rb +13 -0
- data/app/controllers/smithy/content_blocks_controller.rb +50 -0
- data/app/controllers/smithy/content_pieces_controller.rb +97 -0
- data/app/controllers/smithy/contents_controller.rb +41 -0
- data/app/controllers/smithy/guides_controller.rb +9 -0
- data/app/controllers/smithy/images_controller.rb +41 -0
- data/app/controllers/smithy/page_contents_controller.rb +90 -0
- data/app/controllers/smithy/pages_controller.rb +110 -0
- data/app/controllers/smithy/settings_controller.rb +46 -0
- data/app/controllers/smithy/sitemap_controller.rb +13 -0
- data/app/controllers/smithy/templates_controller.rb +79 -0
- data/app/helpers/smithy/application_helper.rb +36 -0
- data/app/helpers/smithy/assets_helper.rb +9 -0
- data/app/helpers/smithy/pages_helper.rb +12 -0
- data/app/helpers/smithy/settings_helper.rb +4 -0
- data/app/helpers/smithy/templates_helper.rb +4 -0
- data/app/helpers/smithy/upload_helper.rb +110 -0
- data/app/models/smithy/asset.rb +64 -0
- data/app/models/smithy/content.rb +35 -0
- data/app/models/smithy/content_block.rb +41 -0
- data/app/models/smithy/content_block_template.rb +26 -0
- data/app/models/smithy/image.rb +41 -0
- data/app/models/smithy/page.rb +94 -0
- data/app/models/smithy/page_content.rb +62 -0
- data/app/models/smithy/page_list.rb +61 -0
- data/app/models/smithy/page_proxy.rb +63 -0
- data/app/models/smithy/setting.rb +6 -0
- data/app/models/smithy/site.rb +30 -0
- data/app/models/smithy/template.rb +53 -0
- data/app/models/smithy/template_container.rb +16 -0
- data/app/views/layouts/smithy/application.html.erb +27 -0
- data/app/views/layouts/smithy/guides.html.erb +16 -0
- data/app/views/layouts/smithy/modal.html.erb +10 -0
- data/app/views/layouts/smithy/shared/_flash.html.erb +6 -0
- data/app/views/layouts/smithy/shared/_footer.html.erb +3 -0
- data/app/views/layouts/smithy/shared/_head.html.erb +8 -0
- data/app/views/layouts/smithy/shared/_nav.html.erb +37 -0
- data/app/views/layouts/smithy/shared/_tail.html.erb +4 -0
- data/app/views/layouts/smithy/wide.html.erb +24 -0
- data/app/views/smithy/assets/_asset.html.erb +10 -0
- data/app/views/smithy/assets/_form.html.erb +13 -0
- data/app/views/smithy/assets/_upload_form.html.erb +13 -0
- data/app/views/smithy/assets/create.js.erb +5 -0
- data/app/views/smithy/assets/edit.html.erb +5 -0
- data/app/views/smithy/assets/index.html.erb +13 -0
- data/app/views/smithy/assets/new.html.erb +13 -0
- data/app/views/smithy/caches/show.html.erb +8 -0
- data/app/views/smithy/content_blocks/_content_block.html.erb +1 -0
- data/app/views/smithy/content_blocks/_secondary_nav.html.erb +12 -0
- data/app/views/smithy/content_blocks/_template_fields.html.erb +19 -0
- data/app/views/smithy/content_blocks/edit.html.erb +31 -0
- data/app/views/smithy/content_blocks/index.html.erb +17 -0
- data/app/views/smithy/content_blocks/new.html.erb +12 -0
- data/app/views/smithy/content_pieces/edit.html.erb +13 -0
- data/app/views/smithy/content_pieces/index.html.erb +21 -0
- data/app/views/smithy/content_pieces/new.html.erb +1 -0
- data/app/views/smithy/contents/_form.html.erb +6 -0
- data/app/views/smithy/contents/_form_fields.html.erb +12 -0
- data/app/views/smithy/contents/edit.html.erb +3 -0
- data/app/views/smithy/contents/new.html.erb +3 -0
- data/app/views/smithy/guides/markdown.html.erb +150 -0
- data/app/views/smithy/images/_form.html.erb +6 -0
- data/app/views/smithy/images/_form_fields.html.erb +28 -0
- data/app/views/smithy/images/edit.html.erb +3 -0
- data/app/views/smithy/images/new.html.erb +3 -0
- data/app/views/smithy/page_contents/edit.html.erb +18 -0
- data/app/views/smithy/page_contents/new.html.erb +28 -0
- data/app/views/smithy/page_lists/_form_fields.html.erb +6 -0
- data/app/views/smithy/pages/_container.html.erb +24 -0
- data/app/views/smithy/pages/_form.html.erb +57 -0
- data/app/views/smithy/pages/_page.html.erb +6 -0
- data/app/views/smithy/pages/_page_nav.html.erb +6 -0
- data/app/views/smithy/pages/_page_related.html.erb +21 -0
- data/app/views/smithy/pages/_parent.html.erb +10 -0
- data/app/views/smithy/pages/_root.html.erb +5 -0
- data/app/views/smithy/pages/edit.html.erb +7 -0
- data/app/views/smithy/pages/index.html.erb +17 -0
- data/app/views/smithy/pages/new.html.erb +7 -0
- data/app/views/smithy/settings/_form.html.erb +7 -0
- data/app/views/smithy/settings/_setting.html.erb +6 -0
- data/app/views/smithy/settings/edit.html.erb +3 -0
- data/app/views/smithy/settings/index.html.erb +9 -0
- data/app/views/smithy/settings/new.html.erb +3 -0
- data/app/views/smithy/settings/show.html.erb +10 -0
- data/app/views/smithy/sitemap/show.xml.erb +10 -0
- data/app/views/smithy/templates/_secondary_nav.html.erb +21 -0
- data/app/views/smithy/templates/_template.html.erb +1 -0
- data/app/views/smithy/templates/edit.html.erb +36 -0
- data/app/views/smithy/templates/index.html.erb +17 -0
- data/app/views/smithy/templates/new.html.erb +13 -0
- data/config/initializers/aws.rb +5 -0
- data/config/initializers/dragonfly.rb +48 -0
- data/config/initializers/formtastic.rb +77 -0
- data/config/initializers/kaminari_config.rb +10 -0
- data/config/initializers/liquid.rb +2 -0
- data/config/routes.rb +38 -0
- data/db/migrate/20120911193140_create_smithy_templates.rb +11 -0
- data/db/migrate/20120911203618_create_smithy_settings.rb +10 -0
- data/db/migrate/20121018182146_create_smithy_pages.rb +27 -0
- data/db/migrate/20121019145543_create_smithy_template_containers.rb +11 -0
- data/db/migrate/20121019160426_create_smithy_page_contents.rb +21 -0
- data/db/migrate/20121024213357_create_smithy_content_blocks.rb +10 -0
- data/db/migrate/20121025011733_create_smithy_content_block_templates.rb +12 -0
- data/db/migrate/20121029175812_create_smithy_contents.rb +9 -0
- data/db/migrate/20121105222537_create_smithy_assets.rb +16 -0
- data/db/migrate/20121115215053_create_smithy_images.rb +15 -0
- data/db/migrate/20121127205022_add_external_link_to_smithy_pages.rb +5 -0
- data/db/migrate/20130115190505_add_markdown_content_to_smithy_contents.rb +5 -0
- data/db/migrate/20130123170918_set_defaults_for_show_in_navigation_and_cache_length.rb +6 -0
- data/db/migrate/20130311203806_create_smithy_page_lists.rb +15 -0
- data/db/migrate/20130312161116_remove_description_from_content_block.rb +5 -0
- data/db/migrate/20130326191051_add_html_attributes_to_images.rb +5 -0
- data/db/migrate/20131003210228_add_publishable_to_smithy_page_contents.rb +11 -0
- data/db/migrate/20131220160755_add_content_to_images.rb +5 -0
- data/db/migrate/20131223145710_add_position_to_smithy_template_containers.rb +5 -0
- data/lib/smithy/content_blocks/model.rb +16 -0
- data/lib/smithy/content_blocks/registry.rb +30 -0
- data/lib/smithy/content_blocks.rb +2 -0
- data/lib/smithy/content_pieces/base.rb +10 -0
- data/lib/smithy/content_pieces/registry.rb +39 -0
- data/lib/smithy/dependencies.rb +19 -0
- data/lib/smithy/dragonfly/asset_helper.rb +67 -0
- data/lib/smithy/dragonfly/remote_data_store.rb +33 -0
- data/lib/smithy/dragonfly.rb +30 -0
- data/lib/smithy/engine.rb +48 -0
- data/lib/smithy/formatter.rb +46 -0
- data/lib/smithy/liquid/database.rb +12 -0
- data/lib/smithy/liquid/drops/base.rb +16 -0
- data/lib/smithy/liquid/drops/page.rb +78 -0
- data/lib/smithy/liquid/filters/asset_tag.rb +33 -0
- data/lib/smithy/liquid/filters/resize.rb +12 -0
- data/lib/smithy/liquid/rendering.rb +50 -0
- data/lib/smithy/liquid/tags/asset.rb +54 -0
- data/lib/smithy/liquid/tags/csrf.rb +30 -0
- data/lib/smithy/liquid/tags/html.rb +61 -0
- data/lib/smithy/liquid/tags/nav.rb +76 -0
- data/lib/smithy/liquid.rb +8 -0
- data/lib/smithy/logger.rb +12 -0
- data/lib/smithy/version.rb +3 -0
- data/lib/smithy.rb +21 -0
- data/lib/smithycms.rb +1 -0
- data/lib/tasks/smithy_tasks.rake +4 -0
- data/lib/templates/erb/scaffold/_form.html.erb +11 -0
- metadata +871 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012-2013 Tim Glen
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
# Smithy CMS
|
2
|
+
|
3
|
+
[![Code Climate](https://codeclimate.com/github/sterrym/smithy.png)](https://codeclimate.com/github/sterrym/smithy)
|
4
|
+
|
5
|
+
## Templates & Includes
|
6
|
+
These are the building blocks of a page. All the markup is written using the Liquid templating engine. This allows anyone to be able to write templates without the dangers of exposing the whole stack to the template editor.
|
7
|
+
|
8
|
+
## Pages
|
9
|
+
On top of its own innate elements (title, permalink, etc), each page belongs to a template and through the template, has a set of available content containers. To each container, pieces of content can be added and organized via various "Content Blocks".
|
10
|
+
|
11
|
+
## Content Blocks
|
12
|
+
A "Content Block" is simply an ActiveRecord model with a Smithy inclusion (<code>include Smithy::ContentBlocks::Model</code>), a <code>_form_fields</code> partial (preferably utilizing formtastic) and it's own set of templates, managed within Smithy.
|
13
|
+
|
14
|
+
## Getting Started
|
15
|
+
To get started, add this to your Gemfile
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'smithy', :github => 'sterrym/smithy'
|
19
|
+
```
|
20
|
+
|
21
|
+
If you need basic authentication and don't want to integrate with existing auth in your system, add this to your Gemfile too:
|
22
|
+
gem 'smithy-auth', :github => 'sterrym/smithy-auth'
|
23
|
+
|
24
|
+
Installing the CMS is simple, you can just
|
25
|
+
|
26
|
+
```shell
|
27
|
+
bundle install
|
28
|
+
rake smithy:install:migrations
|
29
|
+
rake smithy_auth:install:migrations # (if you are using smithy-auth)
|
30
|
+
rake db:migrate
|
31
|
+
```
|
32
|
+
|
33
|
+
To your routes file, you need to mount Smithy - typically, this would be done at the root
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
mount Smithy::Engine => "/"
|
37
|
+
```
|
38
|
+
|
39
|
+
Now start up your server and go to http://localhost:nnnn/smithy
|
40
|
+
|
41
|
+
## Integrating with third-party authentication
|
42
|
+
|
43
|
+
Add this to your routes file (below the `mount Smithy::Engine` line). It will redirect smithy/login|logout (the built-in paths) to your existing authentication paths.
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
scope "/smithy" do
|
47
|
+
match "/login" => redirect("/your/login/path"), :as => :login
|
48
|
+
match '/logout' => redirect("/"), :as => :logout
|
49
|
+
end
|
50
|
+
```
|
51
|
+
|
52
|
+
Add the following to your application controller:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
def smithy_current_user
|
56
|
+
current_user # use whichever method name you have implemented to return the current_user
|
57
|
+
end
|
58
|
+
helper_method :smithy_current_user
|
59
|
+
```
|
60
|
+
|
61
|
+
If you wish for all of your users to have access to smithy, simply add this method to your user model:
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
def smithy_admin?
|
65
|
+
true
|
66
|
+
end
|
67
|
+
```
|
68
|
+
|
69
|
+
Alternatively, you can add a boolean field (via migration) named `smithy_admin` to your users table and manage the field with with your existing user management.
|
70
|
+
|
71
|
+
Restart your local server and you should be good to go.
|
72
|
+
|
73
|
+
### Templates
|
74
|
+
|
75
|
+
Create your first Template, naming it whatever you want ("Home" or "Default" or something equally original). In the content, add `{{ page.container.main_content }}`. In the background, this will auto-create a container that will be used by any page using your template. You can name your container whatever you would like: `{{ page.container.foo }}` works as well. After you have created new page containers, they will automatically show up on the Page edit screen and allow you to add content to the container.
|
76
|
+
|
77
|
+
If you want, you can create Includes. For instance, if you create an Include named "header", you can utilize it in your Template via `{% include 'header' %}`.
|
78
|
+
|
79
|
+
Note, you can also create stylesheet and javascript files, included in your templates via smithy_stylesheet_link_tag and smithy_javascript_include_tag. javascript_include_tag calls out directly to ActionView so you can also access files from your host application directly. Eg. `{% smithy_javascript_include_tag 'my_special_javascript' %}`
|
80
|
+
|
81
|
+
### Pages
|
82
|
+
|
83
|
+
Follow the "Manage Content" link in the header and create your first page. Add a Title ("Home" for instance), select your Template and save the page. The page will save and you will be on the Edit screen for your new page. You can see that your "Main Content" container is now available.
|
84
|
+
|
85
|
+
### Content Blocks
|
86
|
+
|
87
|
+
Smithy comes with some useful Content Blocks already created, though you may need to add them to your system: Content, Image, PageList. After adding a Content Block, you must also create at least one template for it before you can use it on a page. Once you have added a template, you can utilize that Content Block in any available Page container.
|
88
|
+
|
89
|
+
### Adding Custom Content Blocks
|
90
|
+
|
91
|
+
While Smithy has some default Content Blocks, you will often want to add your own structured content, allowing you to manage templates for more structured content. To add a custom Content Block, do the following:
|
92
|
+
|
93
|
+
1. create a new table & model or use an existing one from your app. This can be a single, stand-alone model or a model with associations, Smithy doesn't really care.
|
94
|
+
2. Add `include Smithy::ContentBlocks::Model` to the top of your model. This gives some extra functionality for Smithy.
|
95
|
+
2. Add a views/mymodel/_form_fields.html.erb to your app, replacing "mymodel" with your new model name. This is identical to adding your own view/partial for the model. An "f" variable is passed to the partial, which represents a formtastic form. While formtastic is outside the scope of this document (look it up!), you can also just create your form however you want though it will be way simpler to just use formtastic syntax!
|
96
|
+
3. Smithy will automatically look for your _form_fields.html.erb partial to manage the Content Block when adding Page Content to a page.
|
97
|
+
4. Register your Content Block by entering the Smithy admin, clicking on Content Blocks and adding a new Content Block with your new model name, creating a template for your new Content Block at the same time.
|
98
|
+
|
99
|
+
Your _form_fields.html.erb file could look something like this:
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
<%= f.inputs "Client Story" do %>
|
103
|
+
<%= f.input :client_name %>
|
104
|
+
<%= f.input :project_name %>
|
105
|
+
<%= f.input :content, :as => :text, :input_html => { :class => "span12" } %>
|
106
|
+
<% end %>
|
107
|
+
```
|
108
|
+
|
109
|
+
If you want to customize which columns are available to your liquid template, you can add a #to_liquid method to your model. Eg.:
|
110
|
+
|
111
|
+
```ruby
|
112
|
+
def to_liquid
|
113
|
+
{
|
114
|
+
'id' => self.id,
|
115
|
+
'client_name' => self.client_name,
|
116
|
+
'project_name' => self.project_name,
|
117
|
+
'content' => self.content,
|
118
|
+
'story_images' => self.images.map(&:to_liquid),
|
119
|
+
'formatted_content' => self.formatted_content
|
120
|
+
}
|
121
|
+
end
|
122
|
+
```
|
123
|
+
Using the above #to_liquid method, your template could look like this:
|
124
|
+
|
125
|
+
```html
|
126
|
+
<article class="client_story" id="client_story-{{ id }}">
|
127
|
+
<div class="content">
|
128
|
+
<h3>{{ client_name }}</h3>
|
129
|
+
{% unless project_name == blank %}<h4>{{ project_name }}</h4>{% endunless %}
|
130
|
+
{{ formatted_content }}
|
131
|
+
</div>
|
132
|
+
<div class="images">
|
133
|
+
<div class="cycle-slideshow">
|
134
|
+
{% for story_image in story_images %}
|
135
|
+
<img src="{{ story_image.thumbnail.url }}" alt="">
|
136
|
+
{% endfor %}
|
137
|
+
</div>
|
138
|
+
</div>
|
139
|
+
</article>
|
140
|
+
```
|
141
|
+
|
142
|
+
If you want to be able to represent your ContentBlock uniquely in different contexts, you can simply create more templates and choose which template to use in each context.
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'Smithy'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
Binary file
|
Binary file
|
@@ -0,0 +1,13 @@
|
|
1
|
+
//= require jquery
|
2
|
+
//= require jquery_ujs
|
3
|
+
//= require 'smithy/jquery-ui.min'
|
4
|
+
//= require jquery-fileupload/basic
|
5
|
+
//= require jquery-fileupload/vendor/tmpl
|
6
|
+
//= require bootstrap
|
7
|
+
//= require ace/ace
|
8
|
+
//= require ace/mode-css.js
|
9
|
+
//= require ace/mode-html.js
|
10
|
+
//= require ace/mode-javascript.js
|
11
|
+
//= require ace/mode-liquid.js
|
12
|
+
//= require ace/mode-markdown.js
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Place all the behaviors and hooks related to the matching controller here.
|
2
|
+
# All this logic will automatically be available in application.js.
|
3
|
+
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
4
|
+
jQuery ->
|
5
|
+
$('#fileupload').fileupload
|
6
|
+
add: (e, data) ->
|
7
|
+
types = /(\.|\/)(gif|jpe?g|png|pdf)$/i
|
8
|
+
file = data.files[0]
|
9
|
+
if types.test(file.type) || types.test(file.name)
|
10
|
+
data.context = $(tmpl("template-upload", file))
|
11
|
+
$('#fileupload').append(data.context)
|
12
|
+
data.submit()
|
13
|
+
else
|
14
|
+
alert("#{file.name} is not a gif, jpeg, png or pdf file")
|
15
|
+
|
16
|
+
progress: (e, data) ->
|
17
|
+
if data.context
|
18
|
+
progress = parseInt(data.loaded / data.total * 100, 10)
|
19
|
+
data.context.find('.bar').css('width', progress + '%')
|
20
|
+
|
21
|
+
done: (e, data) ->
|
22
|
+
file = data.files[0]
|
23
|
+
domain = $('#fileupload').attr('action')
|
24
|
+
path = $('#fileupload input[name=key]').val().replace('${filename}', file.name)
|
25
|
+
to = $('#fileupload').data('post') + ".js"
|
26
|
+
content = {}
|
27
|
+
content[$('#fileupload').data('as')] = domain + path
|
28
|
+
$.post(to, content)
|
29
|
+
|
30
|
+
data.context.remove() if data.context # remove progress bar
|
31
|
+
|
32
|
+
fail: (e, data) ->
|
33
|
+
alert("#{data.files[0].name} failed to upload.")
|
34
|
+
console.log("Upload failed:")
|
35
|
+
console.log(data)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
$('[data-toggle="remote-load"]').click(function(e) {
|
2
|
+
e.preventDefault();
|
3
|
+
var activator = this;
|
4
|
+
var remote = $(this).attr("href");
|
5
|
+
var target = $(this).attr("data-target");
|
6
|
+
if ($(target).filter(":empty").length > 0) {
|
7
|
+
$(target).hide();
|
8
|
+
$.ajax($(this).attr("href"), {
|
9
|
+
success: function(data) {
|
10
|
+
$(target).append($('<div data-type="remote-load"></div>').append(data));
|
11
|
+
$('[data-dismiss="remote-load"]', $(target)).on('click', function(e) {
|
12
|
+
e.preventDefault();
|
13
|
+
$(activator).click();
|
14
|
+
});
|
15
|
+
$(target).slideDown('slow');
|
16
|
+
}
|
17
|
+
});
|
18
|
+
} else if ($(target).filter(":hidden").length > 0) {
|
19
|
+
$(target).slideDown('slow');
|
20
|
+
} else if ($(target).filter(":visible").length > 0) {
|
21
|
+
$(target).slideUp('slow');
|
22
|
+
}
|
23
|
+
});
|