scrivito_tabbed_content_widget 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d17b4f613975dc845c11177697047c172f4d790f
4
+ data.tar.gz: 57aeaf70d74181c01c5ac2e54b162dc0d46af331
5
+ SHA512:
6
+ metadata.gz: 104f5470289a5f09a2073a9aa80473601e38c0171507b430351d1e7d7e92b8564dc20318b9942ddb02c26dbf945d487e79694f9e4177596366e560989e554214
7
+ data.tar.gz: 7a2ff1f72740501a894490749fb6add615b18a8a6a28a7c1127a129f7521ddae70edfa475a08184940c7a86ced3b804fe7a8ee2ad52ec278602bfbbf0f8c8fd9
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2014 YOURNAME
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,39 @@
1
+ # Scrivito Tabbed Content Widget
2
+
3
+ This Gem adds Tabbed Contents to your app. Fill the Gem with Tabs and fill each tab with a widget.
4
+
5
+
6
+ ## Prerequisites
7
+
8
+ Use Bootstrap in your Rails App. (Tested with Bootstrap 3.2)
9
+ Use Haml in your Rails App.
10
+
11
+
12
+ ## Installation
13
+
14
+ Add the gem to your Gemfile:
15
+
16
+ gem 'scrivito_tabbed_content_widget'
17
+
18
+ Run bundle:
19
+
20
+ $ bundle
21
+
22
+ (Currently you need to download the Gem's files from github and install it locally.)
23
+
24
+ Run
25
+
26
+ $ rake scrivito:migrate:install
27
+ $ rake scrivito:migrate
28
+
29
+ Switch to your Workspace 'rtc' and follow below Steps for Usage. If you are happy with the outcome run
30
+
31
+ $ rake scrivito:migrate:publish
32
+
33
+
34
+ ## Steps for Usage
35
+
36
+ - Insert the Widget 'Tabbed Content' somewhere in your content.
37
+ - Put some 'Tabbed Content Tab' widgets into it.
38
+ - For each of the Tabbed Content Tabs: set a headline and fill the content with any widget (text, images, whatever).
39
+
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'ScrivitoTabbedContentWidget'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+ Bundler::GemHelper.install_tasks
21
+
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,7 @@
1
+ $("#add_new_tab").bind("click", function(e) {
2
+ e.preventDefault();
3
+ $.get("/add_new_tab?obj=" + scrivito.obj.current_page.id() + "&widget=" + $(this).attr("widgetid"), function(data) {
4
+ location.reload();
5
+ });
6
+
7
+ });
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,2 @@
1
+ div.tabs-wrapper {padding-top: 30px;}
2
+ div.tab-content > div > div {margin-top: 0;}
@@ -0,0 +1,16 @@
1
+ module ScrivitoTabbedContentWidget
2
+
3
+ class TabbedContentWidgetController < CmsController
4
+
5
+ layout false
6
+
7
+ def add_new_tab
8
+ widget = Obj.find(params[:obj]).widget_from_pool(params[:widget])
9
+ widget.update(tabs: widget.tabs << TabbedContentTabWidget.new())
10
+ #TODO: check for success and return appropriate result
11
+ render "tabbed_content_widget/add_new_tab"
12
+ end
13
+
14
+ end
15
+
16
+ end
@@ -0,0 +1,11 @@
1
+ class TabbedContentTabWidget < Widget
2
+
3
+ def additional_classes
4
+ self.container.respond_to?("tabs") && self.container.tabs.first == self ? "active" : ""
5
+ end
6
+
7
+ def description_for_editor
8
+ "Tab"
9
+ end
10
+
11
+ end
@@ -0,0 +1,44 @@
1
+ class TabbedContentWidget < Widget
2
+
3
+ DEFAULT_TABS = 2
4
+
5
+ def self.valid_widget_classes_for(field_name)
6
+ # unfortunately this does not work with the current sdk, the valid_widget_classes_for method is for Objs only:
7
+ %w[TabbedContentTabWidget]
8
+ end
9
+
10
+ def description_for_editor
11
+ "Tabbed Content"
12
+ end
13
+
14
+ def tabs_with_default
15
+ _tabs = tabs.clone
16
+ missing_tabs.times do
17
+ _tabs << PlaceholderTabWidgetElement.new
18
+ end
19
+ _tabs
20
+ end
21
+
22
+ private
23
+
24
+ def missing_tabs
25
+ DEFAULT_TABS - tabs.size
26
+ end
27
+
28
+ class PlaceholderTabWidgetElement
29
+
30
+ def id
31
+ @id ||= SecureRandom.hex(2)
32
+ end
33
+
34
+ def headline
35
+ 'Widget Placeholder'
36
+ end
37
+
38
+ def content
39
+ []
40
+ end
41
+
42
+ end
43
+
44
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>ScrivitoTabbedContentWidget</title>
5
+ <%= stylesheet_link_tag "scrivito_tabbed_content_widget/application", media: "all" %>
6
+ <%= javascript_include_tag "scrivito_tabbed_content_widget/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,5 @@
1
+ .details-view
2
+ %h4
3
+ Tab Headline
4
+
5
+ = scrivito_tag(:p, widget, :headline)
@@ -0,0 +1,2 @@
1
+ = scrivito_tag(:div, widget, :content)
2
+
@@ -0,0 +1,10 @@
1
+ .editing-dialog-thumbnail
2
+ .visualization
3
+ %span.icon.editing-icon-text
4
+
5
+ .title
6
+ Tabbed Content Tab
7
+
8
+ .description
9
+ A single tab in Tabbed Content
10
+
@@ -0,0 +1,5 @@
1
+ %h4
2
+ Headlines
3
+
4
+ - widget.tabs.each do |tab|
5
+ = scrivito_tag(:div, tab, :headline)
@@ -0,0 +1,27 @@
1
+ .tabs-wrapper
2
+ = scrivito_tag(:div, widget, :tabs, style: 'display:none')
3
+
4
+ %ul.nav.nav-tabs
5
+ - widget.tabs.each_with_index do |tab, index|
6
+ - active_class = index == 0 ? 'active' : nil
7
+ %li{class: active_class}
8
+ = scrivito_tag(:a, tab, :headline, href: "##{tab.id}", 'data-toggle' => 'tab')
9
+
10
+ - if scrivito_in_editable_view?
11
+ %li.new_tab
12
+ %a{id: "add_new_tab", widgetid: widget.id, href: "#", style: "background-color: #439439; color: white;"}
13
+ New Tab
14
+
15
+ .tab-content
16
+ - widget.tabs.each_with_index do |tab, index|
17
+ - active_class = index == 0 ? 'active' : nil
18
+ -# still toying around with this a bit:
19
+ - if false
20
+ = scrivito_tag(:div, widget, tabs[index], class: "tab-pane fade in #{active_class}", id: tab.id)
21
+
22
+ .tab-pane.fade.in{id: tab.id, class: active_class}
23
+ = scrivito_tag(:div, tab, :content)
24
+
25
+ - if widget.tabs.blank?
26
+ = scrivito_tag(:div, widget, :tabs)
27
+
@@ -0,0 +1,10 @@
1
+ .editing-dialog-thumbnail
2
+ .visualization
3
+ %span.icon.editing-icon-plus
4
+
5
+ .title
6
+ Tabbed Content
7
+
8
+ .description
9
+ Widget for inserting content tabs
10
+
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ get '/add_new_tab', to: 'scrivito_tabbed_content_widget/tabbed_content_widget#add_new_tab'
3
+ end
@@ -0,0 +1,5 @@
1
+ module ScrivitoTabbedContentWidget
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace ScrivitoTabbedContentWidget
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module ScrivitoTabbedContentWidget
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ require "scrivito_tabbed_content_widget/engine"
2
+
3
+ module ScrivitoTabbedContentWidget
4
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :scrivito_tabbed_content_widget do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,20 @@
1
+ class CreateTabbedContentWidget < ::Scrivito::Migration
2
+ def up
3
+ Scrivito::ObjClass.create(
4
+ name: 'TabbedContentWidget',
5
+ is_binary: false,
6
+ attributes: [
7
+ {name: 'tabs', type: :widget},
8
+ ]
9
+ )
10
+ Scrivito::ObjClass.create(
11
+ name: 'TabbedContentTabWidget',
12
+ is_binary: false,
13
+ attributes: [
14
+ {name: 'headline', type: :string},
15
+ {name: 'content', type: :widget},
16
+ ]
17
+ )
18
+ end
19
+ end
20
+
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scrivito_tabbed_content_widget
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Scrivito
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: scrivito
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: haml
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: This Widget gives you tabbed content boxes that can be filled with widgets.
56
+ email:
57
+ - support@scrivito.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - MIT-LICENSE
63
+ - README.md
64
+ - Rakefile
65
+ - app/assets/javascripts/scrivito_tabbed_content_widget/application.js
66
+ - app/assets/javascripts/scrivito_tabbed_content_widget/editing.js
67
+ - app/assets/stylesheets/scrivito_tabbed_content_widget/application.css
68
+ - app/assets/stylesheets/scrivito_tabbed_content_widget/editing.css
69
+ - app/controllers/scrivito_tabbed_content_widget/tabbed_content_widget_controller.rb
70
+ - app/models/tabbed_content_tab_widget.rb
71
+ - app/models/tabbed_content_widget.rb
72
+ - app/views/layouts/scrivito_tabbed_content_widget/application.html.erb
73
+ - app/views/tabbed_content_tab_widget/details.html.haml
74
+ - app/views/tabbed_content_tab_widget/show.html.haml
75
+ - app/views/tabbed_content_tab_widget/thumbnail.html.haml
76
+ - app/views/tabbed_content_widget/add_new_tab.html.haml
77
+ - app/views/tabbed_content_widget/details.html.haml
78
+ - app/views/tabbed_content_widget/show.html.haml
79
+ - app/views/tabbed_content_widget/thumbnail.html.haml
80
+ - config/routes.rb
81
+ - lib/scrivito_tabbed_content_widget.rb
82
+ - lib/scrivito_tabbed_content_widget/engine.rb
83
+ - lib/scrivito_tabbed_content_widget/version.rb
84
+ - lib/tasks/scrivito_tabbed_content_widget_tasks.rake
85
+ - scrivito/migrate/0_create_tabbed_content_widget.rb
86
+ homepage: https://www.scrivito.com
87
+ licenses:
88
+ - MIT
89
+ metadata: {}
90
+ post_install_message:
91
+ rdoc_options: []
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 2.4.2
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: A Scrivito Widget for tabbed content.
110
+ test_files: []