sir-trevor-rails 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +58 -62
- data/README.md +12 -73
- data/app/views/sir-trevor/blocks/_list_block.html.erb +3 -0
- data/app/views/sir-trevor/blocks/_quote_block.html.erb +3 -3
- data/app/views/sir-trevor/blocks/_text_block.html.erb +2 -2
- data/app/views/sir-trevor/blocks/_tweet_block.html.erb +4 -4
- data/app/views/sir-trevor/blocks/_video_block.html.erb +5 -5
- data/config/initializers/validators.rb +4 -2
- data/lib/generators/sir_trevor/block/templates/_block.html.erb +2 -2
- data/lib/sir-trevor-rails.rb +7 -3
- data/lib/sir-trevor/helpers/form_builder.rb +2 -2
- data/lib/sir-trevor/helpers/form_helper.rb +12 -6
- data/lib/sir-trevor/helpers/view_helper.rb +41 -40
- data/lib/sir-trevor/version.rb +1 -1
- data/sir-trevor-rails.gemspec +6 -2
- metadata +35 -34
- data/Rakefile +0 -10
- data/app/assets/images/sir-trevor/icons/block_editor_blockquote.png +0 -0
- data/app/assets/images/sir-trevor/icons/block_editor_embed.png +0 -0
- data/app/assets/images/sir-trevor/icons/block_editor_image.png +0 -0
- data/app/assets/images/sir-trevor/icons/block_editor_list.png +0 -0
- data/app/assets/images/sir-trevor/icons/block_editor_text.png +0 -0
- data/app/assets/images/sir-trevor/icons/block_editor_tweet.png +0 -0
- data/app/assets/images/sir-trevor/icons/block_editor_video.png +0 -0
- data/app/assets/images/sir-trevor/icons/close.gif +0 -0
- data/app/assets/images/sir-trevor/icons/handle.gif +0 -0
- data/app/assets/images/sir-trevor/icons/new_image.png +0 -0
- data/app/assets/images/sir-trevor/icons/new_tweet.png +0 -0
- data/app/assets/images/sir-trevor/icons/new_video.png +0 -0
- data/app/assets/images/sir-trevor/icons/quote.png +0 -0
- data/app/assets/images/sir-trevor/placeholders/placeholder.jpg +0 -0
- data/app/assets/images/sir-trevor/placeholders/post_placeholder.jpg +0 -0
- data/app/assets/images/sir-trevor/placeholders/thumbnail_placeholder.jpg +0 -0
- data/app/assets/javascript/sir-trevor.js +0 -2
- data/app/assets/javascript/sir-trevor/libs/underscore.js +0 -32
- data/app/assets/javascript/sir-trevor/sir-trevor.js +0 -2349
- data/app/assets/stylesheets/sir-trevor.css +0 -4
- data/app/assets/stylesheets/sir-trevor/icons.css.erb +0 -47
- data/app/assets/stylesheets/sir-trevor/sir-trevor.css +0 -439
- data/app/views/sir-trevor/blocks/_gallery_block.html.erb +0 -6
- data/app/views/sir-trevor/blocks/_ul_block.html.erb +0 -3
- data/lib/generators/sir_trevor/block/block_generator.rb +0 -37
- data/lib/generators/sir_trevor/block/templates/_block.css.erb +0 -7
- data/lib/generators/sir_trevor/block/templates/_block.js +0 -122
- data/lib/generators/sir_trevor/block/templates/_block.png +0 -0
@@ -1,6 +0,0 @@
|
|
1
|
-
<% # Remember, a gallery is just an array of images ;-) %>
|
2
|
-
<div class="content-block gallery-block">
|
3
|
-
<% block.each do |image| %>
|
4
|
-
<%= render(:partial => "sir-trevor/blocks/image_block", :locals => {:block => image['data'], :image_type => image_type}, :formats => formats) if image.has_key?("data") && image['type'] == "image" %>
|
5
|
-
<% end %>
|
6
|
-
</div>
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'rails/generators'
|
2
|
-
|
3
|
-
module SirTrevor
|
4
|
-
module Generators
|
5
|
-
class BlockGenerator < Rails::Generators::NamedBase
|
6
|
-
|
7
|
-
def self.source_root
|
8
|
-
@source_root ||= File.join(File.dirname(__FILE__), 'templates')
|
9
|
-
end
|
10
|
-
|
11
|
-
def create_block
|
12
|
-
|
13
|
-
# Copy our PNG
|
14
|
-
copy_file "_block.png", "app/assets/images/sir-trevor/blocks/block_editor_#{name}.png"
|
15
|
-
|
16
|
-
# Copy the JS
|
17
|
-
copy_file "_block.js", "app/assets/javascripts/sir-trevor/blocks/#{name}.js"
|
18
|
-
|
19
|
-
gsub_file "app/assets/javascripts/sir-trevor/blocks/#{name}.js", /SirTrevor\.Blocks\.Name/, "SirTrevor.Blocks.#{name.capitalize}"
|
20
|
-
gsub_file "app/assets/javascripts/sir-trevor/blocks/#{name}.js", /title: ""/, "title: '#{name.capitalize}'"
|
21
|
-
gsub_file "app/assets/javascripts/sir-trevor/blocks/#{name}.js", /className: ""/, "className: '#{name.downcase}'"
|
22
|
-
|
23
|
-
# Copy the CSS
|
24
|
-
copy_file "_block.css.erb", "app/assets/stylesheets/sir-trevor/blocks/#{name}_block.css.erb"
|
25
|
-
gsub_file "app/assets/stylesheets/sir-trevor/blocks/#{name}_block.css.erb", /_block\.png/, "#{name}_block.png"
|
26
|
-
gsub_file "app/assets/stylesheets/sir-trevor/blocks/#{name}_block.css.erb", /a.new-/, "a.new-#{name}"
|
27
|
-
gsub_file "app/assets/stylesheets/sir-trevor/blocks/#{name}_block.css.erb", /\.-block/, ".#{name}-block"
|
28
|
-
|
29
|
-
# Copy the HTML
|
30
|
-
copy_file "_block.html.erb", "app/views/sir-trevor/blocks/_#{name}_block.html.erb"
|
31
|
-
gsub_file "app/views/sir-trevor/blocks/_#{name}_block.html.erb", /\s(-block)/, " #{name}-block"
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,122 +0,0 @@
|
|
1
|
-
SirTrevor.Blocks.Name = SirTrevor.Block.extend({
|
2
|
-
|
3
|
-
// String; the title displayed in the toolbar
|
4
|
-
title: "",
|
5
|
-
|
6
|
-
// String; the class name of the block type
|
7
|
-
className: "",
|
8
|
-
|
9
|
-
// Integer; the overall number of blocks of this type that can be added
|
10
|
-
limit: 0,
|
11
|
-
|
12
|
-
// Boolean; show this blockType of the toolbar
|
13
|
-
toolbarEnabled: true,
|
14
|
-
|
15
|
-
// Booleam; set this block up for drag and drop
|
16
|
-
// dropEnabled: true,
|
17
|
-
|
18
|
-
// String or Function; The HTML for the inner portion of the editor block
|
19
|
-
// In this example, the editorHTML is an editable input div (like we use for a TextBlock)
|
20
|
-
editorHTML: "<div></div>",
|
21
|
-
// editorHTML must return a string (if it's a function)
|
22
|
-
// editorHTML: function() {},
|
23
|
-
|
24
|
-
// String; The HTML for the dropzone
|
25
|
-
// Not required unless dropEnabled is true
|
26
|
-
dropzoneHTML: "<div class='dropzone'><p>Drop content here yo!</p></div>",
|
27
|
-
|
28
|
-
// Element shorthands
|
29
|
-
// --
|
30
|
-
// this.$el
|
31
|
-
// this.el
|
32
|
-
// this.$editor
|
33
|
-
// this.$dropzone
|
34
|
-
// this.$() (same as this.$el.find(''))
|
35
|
-
// this.$$() (same as this.$editor.find(''))
|
36
|
-
|
37
|
-
// Bound variables
|
38
|
-
// --
|
39
|
-
// this.instance (A SirTrevor.Editor instance)
|
40
|
-
|
41
|
-
// Helper methods
|
42
|
-
// --
|
43
|
-
// this.save()
|
44
|
-
// this.loading()
|
45
|
-
// this.ready()
|
46
|
-
// this.uploadAttachment(file, callback)
|
47
|
-
// this.remove()
|
48
|
-
|
49
|
-
// Function; provide a custom validator.
|
50
|
-
// By default, we use a validator that checks for a class of 'required' on each input.
|
51
|
-
// This function *MUST* return true or false (whether it's valid or not)
|
52
|
-
// validate: function(){
|
53
|
-
// return true;
|
54
|
-
// },
|
55
|
-
|
56
|
-
// Function; Executed on render of the block if some data is provided.
|
57
|
-
// LoadData gives us a means to convert JSON data into the editor dom
|
58
|
-
// In this example we convert the text from markdown to HTML and show it inside the element
|
59
|
-
// returns null
|
60
|
-
loadData: function(data){
|
61
|
-
// this.$('.text-block').html(this.instance._toHTML(data.text, this.type));
|
62
|
-
},
|
63
|
-
|
64
|
-
// Function; Executed on save of the block, once the block is validated
|
65
|
-
// toData expects a way for the block to be transformed from inputs into JSON data
|
66
|
-
// The default toData function provides a pretty comprehensive way of turning data into JSON
|
67
|
-
// In this example we take the text data and save it to the data object on the block
|
68
|
-
toData: function(){
|
69
|
-
// Grab the data from the block (it's always stored on the data attr)
|
70
|
-
var dataStruct = this.$el.data('block');
|
71
|
-
|
72
|
-
// Grab the content input
|
73
|
-
var content = this.$('.text-block').html();
|
74
|
-
|
75
|
-
if (content.length > 0) {
|
76
|
-
// Convert it to markdown and store under the 'text' object
|
77
|
-
dataStruct.data.text = this.instance._toMarkdown(content, this.type);
|
78
|
-
}
|
79
|
-
},
|
80
|
-
|
81
|
-
// Function; Executed once content has been dropped onto the dropzone of this block
|
82
|
-
// Only required if you have enabled dropping and have provided a dropzone for this block
|
83
|
-
// Always is passed the ev.transferData object from the drop
|
84
|
-
// Please see the image block (https://github.com/madebymany/sir-trevor-js/blob/master/src/blocks/image.js) for an example
|
85
|
-
//onDrop: function(transferData) {},
|
86
|
-
|
87
|
-
// Function; Executed once content has been pasted into the block or any input field with the class 'paste-block'
|
88
|
-
// The default onContentPasted function strips all the HTML from a text-block, as shown here.
|
89
|
-
//onContentPasted: function(ev) {
|
90
|
-
// Convert to markdown and then to HTML to strip all unwanted markup
|
91
|
-
// this.$('.text-block').html(this.instance._toHTML(this.instance._toMarkdown(textBlock.html(), this.type)));
|
92
|
-
//},
|
93
|
-
|
94
|
-
// Function; Hook executed at the end of the block rendering method.
|
95
|
-
// Useful for initialising extra pieces of UI or binding extra events.
|
96
|
-
// In this example we add an extra button, just because.
|
97
|
-
// onBlockRender: function() {
|
98
|
-
// this.$el.append($('<button>', {
|
99
|
-
// click: function() {
|
100
|
-
// alert('Yo dawg, you clicked my button');
|
101
|
-
// }
|
102
|
-
// }));
|
103
|
-
// },
|
104
|
-
|
105
|
-
// Function; Optional hook method executed before the rendering of a block
|
106
|
-
// Beware, $el and any shorthand element variables won't be setup here.
|
107
|
-
// beforeBlockRender: function() {},
|
108
|
-
|
109
|
-
// Function; Any extra markdown parsing can be defined in here.
|
110
|
-
// Executed on the _.toMarkdown function of a SirTrevor.Editor instance
|
111
|
-
// Returns; String (Required)
|
112
|
-
// toMarkdown: function(markdown) {
|
113
|
-
// return markdown.replace(/^(.+)$/mg,"> $1");
|
114
|
-
// },
|
115
|
-
|
116
|
-
// Function; Any extra HTML parsing can be defined in here.
|
117
|
-
// Executed on the _.toHTML function of a SirTrevor.Editor instance
|
118
|
-
// Returns; String (Required)
|
119
|
-
// toHTML: function(html) {
|
120
|
-
// return html;
|
121
|
-
// }
|
122
|
-
});
|
Binary file
|