scrivito_twitter_widget 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da7a727b3bb201088478a43c97b449ba5ad6bd2d
4
- data.tar.gz: e87cc84db6f20f1273053451a0d585003cc71f74
3
+ metadata.gz: cf79930c0d8d7523eb95f6cba60fe214268c5ddc
4
+ data.tar.gz: e21d77ee1415b3ed9434d7ae83cd1b84392f0329
5
5
  SHA512:
6
- metadata.gz: d39113d12e3b6517b97344411e5df60afea02a153f23883d2c9f0c59e90554f40e7d60e578d105d6b1e647b2d268ab46b3fdfe30c2b9e7bcd43a2e3333921524
7
- data.tar.gz: 0963310cdd2e5924c62184aa5217ffa03d280d2dfd8acbfae1d2c4211d99f2405f90a73fa64a35f588962fec1ee25824cbaa263b59ed6a60f9c925ad557e4ac5
6
+ metadata.gz: 2d79e8d8796118a2ef10f6c0f1870db5bafaafe21319534d929a9688a1a3c2a60758c8627a387ca672a72a33dd8610c8841c8450d74146861c06a5ca5fd0623c
7
+ data.tar.gz: 437a0be062e5b700be390b55d2b6d0d841479f4c90f34ef697b2735b6579848b5c58bf84d5e2c53ee68d4fadcc145a8df0e26c64daff86d17405d6c8c263924f
data/README.md CHANGED
@@ -24,7 +24,15 @@ en:
24
24
  description: Add tweets to the Page
25
25
  details:
26
26
  type: Type
27
- tweet_id: Id for Tweet
27
+ tweet_id: Id for tweet or twittername for timeline
28
28
  create: Create a new Timline
29
29
  no_tweet_id: No id is present. Insert one in details view.
30
+ timeline: Timeline
31
+ chrome: Toggle design elements
32
+ height: Height
33
+ limit: Tweet limit
34
+ conversation: Show conversation
35
+ cards: Show images, videos, text by twitter cards
36
+ align: Alignment
37
+ theme: Theme
30
38
  ```
@@ -30,12 +30,32 @@ window.twttr = (function(d, s, id) {
30
30
  var type = $(elem).data('type');
31
31
 
32
32
  $(elem).html('');
33
- if(type == "video") {
34
- twttr.widgets.createVideo(id, elem)
35
- } else if(type == "timeline") {
36
- twttr.widgets.createTimeline(id, elem)
33
+ if(type == "timeline") {
34
+ var sourceType = $(elem).data('source-type');
35
+
36
+ var options = {
37
+ sourceType: sourceType,
38
+ };
39
+
40
+ var key = 'screenName';
41
+ key = sourceType == 'collection' ? 'id' : key
42
+ key = sourceType == 'widget' ? 'widgetId' : key
43
+
44
+ options[key] = id;
45
+ twttr.widgets.createTimeline(options,
46
+ elem,
47
+ {
48
+ chrome: $(elem).data('chrome'),
49
+ height: $(elem).data('height'),
50
+ tweetLimit: $(elem).data('limit')
51
+ })
37
52
  } else {
38
- twttr.widgets.createTweet(id, elem)
53
+ twttr.widgets.createTweet(id, elem, {
54
+ conversation: $(elem).data('conversation'),
55
+ cards: $(elem).data('cards'),
56
+ align: $(elem).data('align'),
57
+ theme: $(elem).data('theme')
58
+ })
39
59
  }
40
60
  });
41
61
  }
@@ -1,4 +1,37 @@
1
1
  class TwitterWidget < Widget
2
2
  attribute :tweet_id, :string
3
- attribute :type, :enum, values: ['tweet', 'timeline', 'video'], default: 'tweet'
3
+ attribute :type, :enum, values: ['tweet', 'timeline'], default: 'tweet'
4
+
5
+ attribute :conversation, :enum, values: ['none', 'all'], default: 'all'
6
+ attribute :cards, :enum, values: ['hidden', 'visible']
7
+ attribute :align, :enum, values: ['left', 'center', 'right'], default: 'left'
8
+ attribute :theme, :enum, values: ['dark','light'], default: 'light'
9
+
10
+ attribute :chrome, :multienum, values: ['noheader', 'nofooter', 'noborders', 'transparent', 'noscrollbar']
11
+ attribute :height, :integer, default: 600
12
+ attribute :limit, :integer, default: 7
13
+ attribute :source_type, :enum, values: ['profile','likes','collection','widget'], default: 'profile'
14
+
15
+ def data_attributes
16
+ data = {
17
+ id: tweet_id,
18
+ type: type
19
+ }
20
+
21
+ if type == 'timeline'
22
+ data[:chrome] = (chrome || []).join(',')
23
+ data[:height] = height || 600
24
+ data[:limit] = limit || 7
25
+ data[:source_type] = source_type || 'profile'
26
+ end
27
+
28
+ if type == 'tweet'
29
+ data[:conversation] = conversation || 'all'
30
+ data[:cards] = cards
31
+ data[:align] = align
32
+ data[:theme] = theme || 'light'
33
+ end
34
+
35
+ return data
36
+ end
4
37
  end
@@ -2,12 +2,60 @@
2
2
  <%= scrivito_toggle_button_editor widget, :type %>
3
3
  <% end %>
4
4
 
5
- <%= scrivito_details_for t('scrivito_timeline_widget.details.tweet_id', default: 'Id for tweet') do %>
5
+ <%= scrivito_details_for t('scrivito_timeline_widget.details.tweet_id', default: 'Id for tweet or twittername for timeline') do %>
6
6
  <%= scrivito_tag :div, widget, :tweet_id %>
7
7
  <% end %>
8
8
 
9
- <div class="alert alert-info">
10
- <a href="https://twitter.com/settings/widgets/new" target="_blank">
11
- <%= t('scrivito_timeline_widget.details.create', default: 'Create a new Timline.') %>
12
- </a>
13
- </div>
9
+ <%= scrivito_details_for t('scrivito_timeline_widget.details.tweet', default: 'Tweet') do %>
10
+ <%= scrivito_details_for t('scrivito_timeline_widget.details.conversation', default: 'Show conversation') do %>
11
+ <%= scrivito_tag :div, widget, :conversation %>
12
+ <% end %>
13
+
14
+ <%= scrivito_details_for t('scrivito_timeline_widget.details.cards', default: 'Show images, videos, text by twitter cards') do %>
15
+ <%= scrivito_tag :div, widget, :cards %>
16
+ <% end %>
17
+
18
+ <%= scrivito_details_for t('scrivito_timeline_widget.details.theme', default: 'Theme') do %>
19
+ <%= scrivito_tag :div, widget, :theme %>
20
+ <% end %>
21
+
22
+ <%= scrivito_details_for t('scrivito_timeline_widget.details.align', default: 'Alignment') do %>
23
+ <%= scrivito_tag :div, widget, :align %>
24
+ <% end %>
25
+ <% end %>
26
+
27
+ <%= scrivito_details_for t('scrivito_timeline_widget.details.timeline', default: 'Timeline') do %>
28
+ <%= scrivito_details_for t('scrivito_timeline_widget.details.limit', default: 'Tweet limit') do %>
29
+ <%= scrivito_tag :div, widget, :source_type %>
30
+ <div class="alert alert-info">
31
+ <p>For type profile or likes you have to use a twitter username e.g. scrivito.</p>
32
+ <p>For type widget or collection you have to use the id of it.</p>
33
+ <p>You can create a new widget at the twitter <a href="https://twitter.com/settings/widgets" target="_blank">preference page</a> when you are logged in.</p>
34
+ </div>
35
+ <% end %>
36
+
37
+ <%= scrivito_details_for t('scrivito_timeline_widget.details.chrome', default: 'Toggle design elements') do %>
38
+ <%= scrivito_tag :div, widget, :chrome %>
39
+ <% end %>
40
+
41
+ <%= scrivito_details_for t('scrivito_timeline_widget.details.height', default: 'Height') do %>
42
+ <%= scrivito_tag :div, widget, :height, {data: {
43
+ scrivito_editors_min: 0,
44
+ scrivito_editors_max: 2000,
45
+ scrivito_editors_step: 10,
46
+ scrivito_editors_allow_delete: false,
47
+ }
48
+ } %>
49
+ <% end %>
50
+
51
+ <%= scrivito_details_for t('scrivito_timeline_widget.details.limit', default: 'Tweet limit') do %>
52
+ <%= scrivito_tag :div, widget, :limit, {data: {
53
+ scrivito_editors_min: 1,
54
+ scrivito_editors_max: 20,
55
+ scrivito_editors_step: 1,
56
+ scrivito_editors_allow_delete: false,
57
+ }
58
+ } %>
59
+ <% end %>
60
+ <% end %>
61
+
@@ -1,5 +1,5 @@
1
1
  <% if widget.tweet_id.present? %>
2
- <div class="tweet_by_id" data-id="<%= widget.tweet_id %>" data-type="<%= widget.type %>"></div>
2
+ <%= content_tag :div, '', data: widget.data_attributes, class: 'tweet_by_id' %>
3
3
  <% else %>
4
4
  <div class="alert alert-info">
5
5
  <%= t('scrivito_twitter_widget.details.no_tweet_id', default: 'No id is present. Insert one in details view.') %>
@@ -1,3 +1,3 @@
1
1
  module ScrivitoTwitterWidget
2
- VERSION = "0.0.5"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrivito_twitter_widget
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scrivito
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-02 00:00:00.000000000 Z
11
+ date: 2017-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: scrivito
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  version: '0'
65
65
  requirements: []
66
66
  rubyforge_project:
67
- rubygems_version: 2.4.5
67
+ rubygems_version: 2.5.1
68
68
  signing_key:
69
69
  specification_version: 4
70
70
  summary: A widget for scrivito to create a twitter stream.