lalala 4.1.0.dev.356 → 4.1.0.dev.358

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5dc5c7be7022b894342a8e47bce019f73b28b7d
4
- data.tar.gz: a53b3f153cae2ce00620281926847322afe68369
3
+ metadata.gz: 9b2dedae2f70f1a01c5af634dc2d3b089d0d8066
4
+ data.tar.gz: be5e2c3e79c90a2eb31b31425e2c10109c904588
5
5
  SHA512:
6
- metadata.gz: 9e0859cd6db3795674676be4030bc0268dde52665b44e36c79d01ad19b136e21e73bbcd8f651e7b1713546068d456d9f5e3ea6b8e587abec534cc15624853490
7
- data.tar.gz: 4d364f1c841c1836d7c81734a075a8599f03d1b1020b48f53a6d850320f996005213e4791c3b949f54cd4e774f3c82fbaa7e6d9cfde1333495e6482383d8da7e
6
+ metadata.gz: fbe8bbbe66ce8f78dc223495368e28e517bd453efa11482153b6adfbbe7c38d5cee643389106add897561db37e49c7424234f32c436187cb334b47417b3db56f
7
+ data.tar.gz: 80182d09b7ec601c5ac803d58a636ed4fb5de4f7a9b9ab4477dfbd5a64fed81202cd4b24a3615a8f0efadfb7c858b85f9164cbfba9bf371ab17c72535628ef74
@@ -89,10 +89,9 @@ function load_cheatsheat(options) {
89
89
  function add_image_click_handler(e) {
90
90
  var ms, overlay;
91
91
 
92
- ms = new MediaSelector();
93
- ms.$markitup_container = $(e.currentTarget).closest(".markItUpContainer");
94
- ms.set_elements();
95
- ms.save_cursor_position();
92
+ ms = new MediaSelector(
93
+ $(e.currentTarget).closest(".markItUpContainer")
94
+ );
96
95
 
97
96
  overlay = Overlay.get_instance();
98
97
  overlay.append_content(ms.$el);
@@ -1,15 +1,20 @@
1
1
  var Overlay = require("./overlay");
2
2
 
3
3
 
4
- function MediaSelector() {
4
+ function MediaSelector($markitup_container) {
5
+ this.$markitup_container = $markitup_container;
5
6
  this.$el = $('<div class="mod-media-selector" />');
7
+ this.set_elements();
6
8
 
7
9
  // settings
8
10
  this.settings = {
9
11
  selected_class: "selected",
10
- selected_data: "SELF"
12
+ selected_data: "SELF",
13
+ editor: {}
11
14
  };
12
15
 
16
+ this.gather_editor_settings();
17
+
13
18
  // data
14
19
  this.selected_ids = [];
15
20
  this.last_rendered_data = [];
@@ -17,6 +22,7 @@ function MediaSelector() {
17
22
  // exec
18
23
  this.collect_data_and_render();
19
24
  this.bind_events();
25
+ this.save_cursor_position();
20
26
  }
21
27
 
22
28
 
@@ -25,6 +31,25 @@ MediaSelector.prototype.set_elements = function() {
25
31
  };
26
32
 
27
33
 
34
+ MediaSelector.prototype.gather_editor_settings = function() {
35
+ var attr = this.$textarea.get(0).attributes;
36
+ attr = Array.prototype.slice.call(attr, 0);
37
+
38
+ for (var i=0, j=attr.length; i<j; ++i) {
39
+ var name = attr[i].name;
40
+ var value = attr[i].value;
41
+
42
+ if (name.match(/^editor\-/)) {
43
+ name = name.replace(/^editor\-/, "").replace(/\-/g, "_");
44
+ value = (value && value.toString().length > 0 ? value : true);
45
+ value = (value === "1" ? true : (value === "0" ? false : value));
46
+
47
+ this.settings.editor[name] = value;
48
+ }
49
+ }
50
+ };
51
+
52
+
28
53
 
29
54
  //
30
55
  // Data & Render
@@ -47,7 +72,9 @@ MediaSelector.prototype.collect_data_and_render = function() {
47
72
  this.render(data);
48
73
 
49
74
  // versions
50
- this.setup_version_option();
75
+ if (!this.settings.editor.disable_versions_option) {
76
+ this.setup_version_option();
77
+ }
51
78
  };
52
79
 
53
80
 
@@ -193,14 +220,16 @@ MediaSelector.prototype.unselect_asset = function($asset) {
193
220
 
194
221
  MediaSelector.prototype.add_selected_to_editor_textarea = function() {
195
222
  var selected = this.selected_ids;
196
- var version = this.$el.find(".options .version select option:selected").val() || "original";
223
+ var version = this.$el.find(".options .version select option:selected").val();
197
224
  var markdown = "";
198
225
 
199
226
  var old_textarea_text, new_textarea_text;
200
227
 
201
228
  // build markdown text
202
229
  for (var i=0, j=selected.length; i<j; ++i) {
203
- markdown = markdown + "![](asset://" + selected[i] + "/" + version + ")";
230
+ markdown = markdown + "![](asset://" + selected[i];
231
+ if (version) markdown = markdown + "/" + version;
232
+ markdown = markdown + ")";
204
233
  }
205
234
 
206
235
  // add to textarea
@@ -0,0 +1,28 @@
1
+ class Lalala::Markdown::Handlers::LazyAsset < Lalala::Markdown::Handlers::Base
2
+
3
+ def initialize(options={})
4
+ @options = options
5
+ end
6
+
7
+ def image(url, alt=nil, title=nil)
8
+ unless %r|^asset[:]//(.+)$| === url
9
+ return ""
10
+ end
11
+
12
+ id_with_version = $1.split("/")
13
+ id = id_with_version[0]
14
+ version = id_with_version[1] || "original"
15
+
16
+ # build url
17
+ url = "//" + File.join(
18
+ "c." + Haraway.configuration.endpoint,
19
+ id,
20
+ version.to_s)
21
+
22
+ # build img element
23
+ <<-EOS
24
+ <img class="js-lazy" data-src="#{url}" alt="#{alt}" title="#{title}" />
25
+ EOS
26
+ end
27
+
28
+ end
@@ -2,10 +2,18 @@ module Lalala::Markdown::InputHelper
2
2
  extend ActiveSupport::Concern
3
3
 
4
4
  def input(method, options = {})
5
+ if @object.respond_to?("#{method}_html")
6
+ options = options.dup.clone
5
7
 
6
- if ( @object.respond_to?("#{method}_html") )
7
8
  input_html = options[:input_html] || {}
8
9
  input_html[:class] = [input_html[:class], 'markdown'].flatten.compact.join(" ")
10
+
11
+ editor_options = options[:editor_options] || {}
12
+ editor_options.each do |k, v|
13
+ v = if v === true then "1" elsif v === false then "0" end
14
+ input_html["editor-#{k.to_s.gsub("_", "-")}"] = v
15
+ end
16
+
9
17
  options[:input_html] = input_html
10
18
  end
11
19
 
@@ -9,6 +9,7 @@ class Lalala::Markdown
9
9
  module Handlers
10
10
  require 'lalala/markdown/handlers/base'
11
11
  require 'lalala/markdown/handlers/asset'
12
+ require 'lalala/markdown/handlers/lazy_asset'
12
13
  require 'lalala/markdown/handlers/vimeo'
13
14
  require 'lalala/markdown/handlers/youtube'
14
15
  end
@@ -1,6 +1,6 @@
1
1
  module Lalala
2
2
  VERSION = "4.1.0"
3
- BUILD = "356"
3
+ BUILD = "358"
4
4
 
5
5
  if BUILD != ("{{BUILD_NUMBER" + "}}") # prevent sed replacement (see script/ci)
6
6
  BUILD_VERSION = "#{VERSION}.dev.#{BUILD}"
@@ -10,10 +10,14 @@ ActiveAdmin.register Article do
10
10
  form do |f|
11
11
  f.inputs do
12
12
  f.input :title
13
- f.input :body
13
+
14
+ f.input :body, editor_options: {
15
+ disable_versions_option: true
16
+ }
17
+
14
18
  f.input :tags
15
19
  f.input :category, as: :select, collection: %w(A B C)
16
- f.input :url, input_html: { placeholder: 'http://', class: 'js-prepend-placeholder' }
20
+ f.input :url, input_html: { placeholder: 'http://', class: 'js-prepend-placeholder' }
17
21
  f.input :price, input_html: { placeholder: '€', class: 'js-append-placeholder' }
18
22
  f.input :poster_image, as: :single_file
19
23
 
@@ -4,9 +4,6 @@ class Article < ActiveRecord::Base
4
4
  # Translations
5
5
  translates :title, :body
6
6
 
7
- # Markdown
8
- markdown :body
9
-
10
7
  # Assets
11
8
  has_one_asset :poster_image, "images"
12
9
  has_many_assets :images, "images"
@@ -60,10 +60,10 @@ ActiveRecord::Schema.define(:version => 20140926152646) do
60
60
  add_index "article_translations", ["locale"], :name => "index_article_translations_on_locale"
61
61
 
62
62
  create_table "articles", :force => true do |t|
63
+ t.text "haraway_metadata"
63
64
  t.datetime "created_at", :null => false
64
65
  t.datetime "updated_at", :null => false
65
66
  t.string "category"
66
- t.text "haraway_metadata"
67
67
  t.string "url"
68
68
  t.string "price"
69
69
  end
@@ -75,25 +75,6 @@ ActiveRecord::Schema.define(:version => 20140926152646) do
75
75
 
76
76
  add_index "articles_tags", ["article_id", "tag_id"], :name => "index_articles_tags_on_article_id_and_tag_id", :unique => true
77
77
 
78
- create_table "asset_translations", :force => true do |t|
79
- t.string "locale"
80
- t.integer "asset_id"
81
- t.string "title"
82
- t.text "caption"
83
- end
84
-
85
- create_table "assets", :force => true do |t|
86
- t.string "asset"
87
- t.string "type"
88
- t.integer "asset_owner_id"
89
- t.string "asset_owner_type"
90
- t.string "asset_owner_section"
91
- t.datetime "created_at", :null => false
92
- t.datetime "updated_at", :null => false
93
- end
94
-
95
- add_index "assets", ["asset_owner_id", "asset_owner_type", "asset_owner_section"], :name => "asset_owner_idx"
96
-
97
78
  create_table "page_hierarchies", :id => false, :force => true do |t|
98
79
  t.integer "ancestor_id", :null => false
99
80
  t.integer "descendant_id", :null => false
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lalala
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0.dev.356
4
+ version: 4.1.0.dev.358
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Menke
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2014-10-01 00:00:00.000000000 Z
16
+ date: 2014-10-24 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: activeadmin
@@ -1453,6 +1453,7 @@ files:
1453
1453
  - lib/lalala/markdown/active_model.rb
1454
1454
  - lib/lalala/markdown/handlers/asset.rb
1455
1455
  - lib/lalala/markdown/handlers/base.rb
1456
+ - lib/lalala/markdown/handlers/lazy_asset.rb
1456
1457
  - lib/lalala/markdown/handlers/vimeo.rb
1457
1458
  - lib/lalala/markdown/handlers/youtube.rb
1458
1459
  - lib/lalala/markdown/html_renderer.rb