pageflow-external-links 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +19 -0
- data/.jshintignore +1 -0
- data/.jshintrc +22 -0
- data/Gemfile +10 -0
- data/README.md +49 -0
- data/Rakefile +7 -0
- data/app/assets/images/pageflow/external_links_pictogram.png +0 -0
- data/app/assets/images/pageflow/external_links_pictogram_small.png +0 -0
- data/app/assets/images/pageflow/ov-external_links.png +0 -0
- data/app/assets/javascript/pageflow/external_links.js +4 -0
- data/app/assets/javascript/pageflow/external_links/editor.js +12 -0
- data/app/assets/javascript/pageflow/external_links/editor/collections/site_references_collection.js +11 -0
- data/app/assets/javascript/pageflow/external_links/editor/collections/sites_collection.js +22 -0
- data/app/assets/javascript/pageflow/external_links/editor/config.js +17 -0
- data/app/assets/javascript/pageflow/external_links/editor/controllers/sidebar_controller.js +34 -0
- data/app/assets/javascript/pageflow/external_links/editor/models/configuration_mixin.js +38 -0
- data/app/assets/javascript/pageflow/external_links/editor/models/site.js +25 -0
- data/app/assets/javascript/pageflow/external_links/editor/models/site_file_selection_handler.js +13 -0
- data/app/assets/javascript/pageflow/external_links/editor/models/site_reference.js +7 -0
- data/app/assets/javascript/pageflow/external_links/editor/models/site_selection_handler.js +7 -0
- data/app/assets/javascript/pageflow/external_links/editor/routers/sidebar_router.js +8 -0
- data/app/assets/javascript/pageflow/external_links/editor/templates/edit_site.jst.ejs +10 -0
- data/app/assets/javascript/pageflow/external_links/editor/templates/embedded/list_item.jst.ejs +5 -0
- data/app/assets/javascript/pageflow/external_links/editor/templates/inputs/site_reference.jst.ejs +7 -0
- data/app/assets/javascript/pageflow/external_links/editor/templates/site_item.jst.ejs +6 -0
- data/app/assets/javascript/pageflow/external_links/editor/templates/site_reference_item.jst.ejs +6 -0
- data/app/assets/javascript/pageflow/external_links/editor/templates/sites.jst.ejs +1 -0
- data/app/assets/javascript/pageflow/external_links/editor/templates/sites_blank_slate.jst.ejs +1 -0
- data/app/assets/javascript/pageflow/external_links/editor/views/configuration_editor.js +23 -0
- data/app/assets/javascript/pageflow/external_links/editor/views/edit_site_view.js +69 -0
- data/app/assets/javascript/pageflow/external_links/editor/views/embedded/list_embedded_view.js +22 -0
- data/app/assets/javascript/pageflow/external_links/editor/views/embedded/list_item_embedded_view.js +56 -0
- data/app/assets/javascript/pageflow/external_links/editor/views/inputs/site_reference_input_view.js +31 -0
- data/app/assets/javascript/pageflow/external_links/editor/views/site_item_view.js +44 -0
- data/app/assets/javascript/pageflow/external_links/editor/views/site_reference_item_view.js +32 -0
- data/app/assets/javascript/pageflow/external_links/editor/views/sites_view.js +35 -0
- data/app/assets/javascript/pageflow/external_links/page_type.js +141 -0
- data/app/assets/stylesheets/pageflow/external_links.css.scss +175 -0
- data/app/assets/stylesheets/pageflow/external_links/editor.css.scss +97 -0
- data/app/controllers/pageflow/external_links/sites_controller.rb +40 -0
- data/app/helpers/pageflow/external_links/sites_helper.rb +9 -0
- data/app/models/pageflow/external_links/site.rb +7 -0
- data/app/views/pageflow/external_links/page.html +34 -0
- data/app/views/pageflow/external_links/sites/_site.html.erb +10 -0
- data/config/locales/de.yml +21 -0
- data/config/routes.rb +5 -0
- data/db/migrate/20140616153235_create_pageflow_external_links_sites.rb +16 -0
- data/lib/pageflow-external-links.rb +6 -0
- data/lib/pageflow/external_links/engine.rb +18 -0
- data/lib/pageflow/external_links/page_type.rb +15 -0
- data/pageflow-external-links.gemspec +27 -0
- metadata +193 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MzY5MDM5ZmNhYzQyOTU4NjY5NzdkNjBhYTBjODQ2M2ZmYWRiZDNkZA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YzBjZmE0NjcyMGMwOWNlN2E5ZDEwODlmY2FiOWYzOWI0MmFhZTFiZA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YjU3NDk3MGE5NGQzNDBlZTQzMWI0MjIzNjYyZGJjZWZlMGZlYWM0YTI0MjI2
|
10
|
+
MTlkM2U1M2NlMjU1NjY4NmIxODdhNzBiMzI4Y2JmYmNkZGVjZTBjODk1MDI4
|
11
|
+
Y2MzYzM3YzE2ZjU4ZjhhODZjNGVjYzBjMTQwOTczYTJjOWM3NTE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NTY1ODlmYzgzNDZmYTNlMTY1OGNkYWMyZjhhNzkyMGFiMDA3Nzg1YmIyOTBh
|
14
|
+
YjA0MmI4ZTJiMjMwMDU2MWJlNTQ2N2NkNjkzMjQ5ZDkxMTc1ZDcxODlhNTc0
|
15
|
+
N2FhNTQzMjY0OGRmNWY1OTliOTJhNDRiYzJjZDliMDE3NDAwOTU=
|
data/.gitignore
ADDED
data/.jshintignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
vendor/assets/javascripts/**
|
data/.jshintrc
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
{
|
2
|
+
"browser": true,
|
3
|
+
"undef": true,
|
4
|
+
"immed": true,
|
5
|
+
"trailing": true,
|
6
|
+
"globals": {
|
7
|
+
"jQuery": true,
|
8
|
+
"$": true,
|
9
|
+
"Backbone": true,
|
10
|
+
"Cocktail": true,
|
11
|
+
"_": true,
|
12
|
+
"vjs": true,
|
13
|
+
"Audio5js": true,
|
14
|
+
"I18n": true,
|
15
|
+
|
16
|
+
"pageflow": true,
|
17
|
+
"editor": true,
|
18
|
+
|
19
|
+
"confirm": true,
|
20
|
+
"alert": true
|
21
|
+
}
|
22
|
+
}
|
data/Gemfile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in chart.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
# Rails 4 compat
|
7
|
+
gem 'activeadmin', :git => 'https://github.com/codevise/active_admin.git', :branch => 'rails4'
|
8
|
+
gem 'ransack'
|
9
|
+
gem 'inherited_resources', '1.4.1'
|
10
|
+
gem 'formtastic', '2.3.0.rc2'
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Pageflow External Links
|
2
|
+
|
3
|
+
Page type to display links to external pages.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's `Gemfile`:
|
8
|
+
|
9
|
+
gem 'pageflow-external-links'
|
10
|
+
|
11
|
+
Register the page type inside the configure block in `config/initializers/pageflow.rb`
|
12
|
+
|
13
|
+
Pageflow.configure do |config|
|
14
|
+
config.register_page_type(Pageflow::ExternalLinks::PageType.new)
|
15
|
+
end
|
16
|
+
|
17
|
+
Include javascripts and stylesheets:
|
18
|
+
|
19
|
+
# app/assets/javascripts/pageflow/application.js
|
20
|
+
//= require pageflow/external_links
|
21
|
+
|
22
|
+
# app/assets/javascripts/pageflow/editor.js
|
23
|
+
//= require pageflow/external_links/editor
|
24
|
+
|
25
|
+
# app/assets/stylesheets/pageflow/application.scss.css
|
26
|
+
@import "pageflow/external_links";
|
27
|
+
|
28
|
+
# app/assets/stylesheets/pageflow/editor.scss.css
|
29
|
+
@import "pageflow/external_links/editor";
|
30
|
+
|
31
|
+
Mount the routes in `config/routes.rb`:
|
32
|
+
|
33
|
+
authenticated do
|
34
|
+
mount Pageflow::ExternalLinks::Engine, :at => '/external_links'
|
35
|
+
end
|
36
|
+
|
37
|
+
Install dependencies:
|
38
|
+
|
39
|
+
bundle install
|
40
|
+
|
41
|
+
Copy migrations of pageflow-external-links into your project:
|
42
|
+
|
43
|
+
bundle exec rake pageflow_external_links:install:migrations
|
44
|
+
|
45
|
+
Migrate the database:
|
46
|
+
|
47
|
+
bundle exec rake db:migrate
|
48
|
+
|
49
|
+
Restart the application server.
|
data/Rakefile
ADDED
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,12 @@
|
|
1
|
+
//= require_self
|
2
|
+
|
3
|
+
//= require_tree ./editor/models
|
4
|
+
//= require_tree ./editor/collections
|
5
|
+
//= require_tree ./editor/routers
|
6
|
+
//= require_tree ./editor/controllers
|
7
|
+
//= require_tree ./editor/templates
|
8
|
+
//= require_tree ./editor/views
|
9
|
+
|
10
|
+
//= require ./editor/config
|
11
|
+
|
12
|
+
pageflow.externalLinks = pageflow.externalLinks || {};
|
@@ -0,0 +1,22 @@
|
|
1
|
+
pageflow.externalLinks.SitesCollection = Backbone.Collection.extend({
|
2
|
+
model: pageflow.externalLinks.Site,
|
3
|
+
|
4
|
+
url: function() {
|
5
|
+
return '/external_links/entries/' + pageflow.entry.get('id') + '/sites';
|
6
|
+
},
|
7
|
+
|
8
|
+
getByPermaId: function(permaId) {
|
9
|
+
return this.findWhere({perma_id: permaId});
|
10
|
+
},
|
11
|
+
|
12
|
+
ensureFetched: function(callback) {
|
13
|
+
var collection = this;
|
14
|
+
|
15
|
+
this.fetchedPromise = this.fetchedPromise || new $.Deferred(function(deferred) {
|
16
|
+
collection.once('sync', deferred.resolve);
|
17
|
+
collection.fetch();
|
18
|
+
}).promise();
|
19
|
+
|
20
|
+
return this.fetchedPromise;
|
21
|
+
}
|
22
|
+
});
|
@@ -0,0 +1,17 @@
|
|
1
|
+
pageflow.editor.registerPageConfigurationMixin(pageflow.externalLinks.pageConfigurationMixin);
|
2
|
+
|
3
|
+
pageflow.editor.registerSideBarRouting({
|
4
|
+
router: pageflow.externalLinks.SidebarRouter,
|
5
|
+
controller: pageflow.externalLinks.SidebarController
|
6
|
+
});
|
7
|
+
|
8
|
+
pageflow.editor.registerFileSelectionHandler('externalLinks.site', pageflow.externalLinks.SiteFileSelectionHandler);
|
9
|
+
|
10
|
+
pageflow.editor.registerMainMenuItem({
|
11
|
+
translationKey: 'pageflow.external_links.manage_sites',
|
12
|
+
path: '/external_links/sites'
|
13
|
+
});
|
14
|
+
|
15
|
+
pageflow.editor.addInitializer(function() {
|
16
|
+
pageflow.externalLinks.sites = new pageflow.externalLinks.SitesCollection();
|
17
|
+
});
|
@@ -0,0 +1,34 @@
|
|
1
|
+
pageflow.externalLinks.SidebarController = Backbone.Marionette.Controller.extend({
|
2
|
+
initialize: function(options) {
|
3
|
+
this.region = options.region;
|
4
|
+
},
|
5
|
+
|
6
|
+
sites: function(pageId) {
|
7
|
+
var page = pageflow.pages.get(pageId);
|
8
|
+
var referer = page ? '/pages/' + page.id + '/links ' : '/';
|
9
|
+
|
10
|
+
this.region.show(new pageflow.BackButtonDecoratorView({
|
11
|
+
referer: referer,
|
12
|
+
view: new pageflow.externalLinks.SitesView({
|
13
|
+
selectionHandler: page && new pageflow.externalLinks.SiteSelectionHandler({
|
14
|
+
page: page
|
15
|
+
}),
|
16
|
+
page: page,
|
17
|
+
referer: referer
|
18
|
+
})
|
19
|
+
}));
|
20
|
+
},
|
21
|
+
|
22
|
+
site: function(id, pageId, returnTo) {
|
23
|
+
var page = pageflow.pages.get(pageId);
|
24
|
+
var region = this.region;
|
25
|
+
|
26
|
+
pageflow.externalLinks.sites.ensureFetched().then(function() {
|
27
|
+
region.show(new pageflow.externalLinks.EditSiteView({
|
28
|
+
model: pageflow.externalLinks.sites.get(id),
|
29
|
+
page: page,
|
30
|
+
returnTo: returnTo
|
31
|
+
}));
|
32
|
+
});
|
33
|
+
}
|
34
|
+
});
|
@@ -0,0 +1,38 @@
|
|
1
|
+
pageflow.externalLinks.pageConfigurationMixin = {
|
2
|
+
externalSiteReferences: function() {
|
3
|
+
var configuration = this;
|
4
|
+
|
5
|
+
this._externalSiteReferences = this._externalSiteReferences || create();
|
6
|
+
return this._externalSiteReferences;
|
7
|
+
|
8
|
+
function create() {
|
9
|
+
var collection = new pageflow.externalLinks.SiteReferencesCollection();
|
10
|
+
|
11
|
+
pageflow.externalLinks.sites.ensureFetched().then(function() {
|
12
|
+
collection.add(siteReferenceAttributes());
|
13
|
+
|
14
|
+
configuration.listenTo(collection, 'add remove sort', function() {
|
15
|
+
configuration.set('linked_external_site_perma_ids', _.map(collection.pluck('site'), function(site) {
|
16
|
+
return site.get('perma_id');
|
17
|
+
}));
|
18
|
+
});
|
19
|
+
});
|
20
|
+
|
21
|
+
return collection;
|
22
|
+
}
|
23
|
+
|
24
|
+
function siteReferenceAttributes() {
|
25
|
+
return _.compact(_.map(referencedSitePermaIds(), function(permaId) {
|
26
|
+
var site = pageflow.externalLinks.sites.getByPermaId(permaId);
|
27
|
+
|
28
|
+
return site && {
|
29
|
+
site: site
|
30
|
+
};
|
31
|
+
}));
|
32
|
+
}
|
33
|
+
|
34
|
+
function referencedSitePermaIds() {
|
35
|
+
return configuration.get('linked_external_site_perma_ids') || [];
|
36
|
+
}
|
37
|
+
}
|
38
|
+
};
|
@@ -0,0 +1,25 @@
|
|
1
|
+
pageflow.externalLinks.Site = Backbone.Model.extend({
|
2
|
+
modelName: 'site',
|
3
|
+
paramRoot: 'site',
|
4
|
+
i18nKey: 'site',
|
5
|
+
|
6
|
+
mixins: [pageflow.failureTracking, pageflow.transientReferences],
|
7
|
+
|
8
|
+
defaults: {
|
9
|
+
'open_in_new_tab': true
|
10
|
+
},
|
11
|
+
|
12
|
+
initialize: function(attributes, options) {
|
13
|
+
this.listenTo(this, 'change', function() {
|
14
|
+
this.save();
|
15
|
+
});
|
16
|
+
},
|
17
|
+
|
18
|
+
urlRoot: function() {
|
19
|
+
return this.isNew() ? this.collection.url() : '/external_links/sites';
|
20
|
+
},
|
21
|
+
|
22
|
+
getThumbnail: function() {
|
23
|
+
return this.getReference('thumbnail', pageflow.imageFiles);
|
24
|
+
}
|
25
|
+
});
|
data/app/assets/javascript/pageflow/external_links/editor/models/site_file_selection_handler.js
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
pageflow.externalLinks.SiteFileSelectionHandler = function(options) {
|
2
|
+
this.call = function(file) {
|
3
|
+
pageflow.externalLinks.sites.ensureFetched().then(function() {
|
4
|
+
var site = pageflow.externalLinks.sites.get(options.id);
|
5
|
+
site.setReference(options.attributeName, file);
|
6
|
+
});
|
7
|
+
};
|
8
|
+
|
9
|
+
this.getReferer = function() {
|
10
|
+
var query = (options.pageId && options.returnTo) ? '/?page=' + options.pageId + '&return_to=' + options.returnTo : '';
|
11
|
+
return '/external_links/sites/' + options.id + query;
|
12
|
+
};
|
13
|
+
};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
pageflow.externalLinks.SidebarRouter = Backbone.Marionette.AppRouter.extend({
|
2
|
+
appRoutes: {
|
3
|
+
'external_links/sites': 'sites',
|
4
|
+
'external_links/sites?page=:page_id': 'sites',
|
5
|
+
'external_links/sites/:id': 'site',
|
6
|
+
'external_links/sites/:id/?page=:page_id&return_to=:return_to': 'site',
|
7
|
+
}
|
8
|
+
});
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<a class="back">Externe Verweise</a>
|
2
|
+
<a class="destroy">Löschen</a>
|
3
|
+
|
4
|
+
<div class="failure">
|
5
|
+
<p>Beim Speichern des externen Verweises ist ein Problem aufgetreten.</p>
|
6
|
+
<p class="message"></p>
|
7
|
+
<a class="retry" href="">Erneut versuchen</a>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<div class="form_container"></div>
|
@@ -0,0 +1 @@
|
|
1
|
+
<a class="add" href="">Hinzufügen</a>
|
@@ -0,0 +1 @@
|
|
1
|
+
<li class="blank_slate">Es wurden noch keine Seiten erstellt.<li>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
pageflow.ConfigurationEditorView.register('external_links', {
|
2
|
+
configure: function() {
|
3
|
+
this.tab('general', function() {
|
4
|
+
this.group('general');
|
5
|
+
});
|
6
|
+
|
7
|
+
this.tab('files', function() {
|
8
|
+
this.input('background_image_id', pageflow.FileInputView, {collection: pageflow.imageFiles});
|
9
|
+
this.input('thumbnail_image_id', pageflow.FileInputView, {
|
10
|
+
collection: pageflow.imageFiles,
|
11
|
+
imagePositioning: false
|
12
|
+
});
|
13
|
+
});
|
14
|
+
|
15
|
+
this.tab('links', function() {
|
16
|
+
this.input('linked_external_site_perma_ids', pageflow.externalLinks.SiteReferenceInputView);
|
17
|
+
});
|
18
|
+
|
19
|
+
this.tab('options', function() {
|
20
|
+
this.group('options');
|
21
|
+
});
|
22
|
+
}
|
23
|
+
});
|
@@ -0,0 +1,69 @@
|
|
1
|
+
pageflow.externalLinks.EditSiteView = Backbone.Marionette.Layout.extend({
|
2
|
+
template: 'pageflow/external_links/editor/templates/edit_site',
|
3
|
+
className: 'edit_external_site',
|
4
|
+
|
5
|
+
mixins: [pageflow.failureIndicatingView],
|
6
|
+
|
7
|
+
regions: {
|
8
|
+
formContainer: '.form_container'
|
9
|
+
},
|
10
|
+
|
11
|
+
ui: {
|
12
|
+
backButton: 'a.back'
|
13
|
+
},
|
14
|
+
|
15
|
+
events: {
|
16
|
+
'click a.back': 'goBack',
|
17
|
+
'click a.destroy': 'destroy',
|
18
|
+
},
|
19
|
+
|
20
|
+
onRender: function() {
|
21
|
+
var options = this.options;
|
22
|
+
var configurationEditor = new pageflow.ConfigurationEditorView({
|
23
|
+
model: this.model
|
24
|
+
});
|
25
|
+
|
26
|
+
configurationEditor.tab('general', function() {
|
27
|
+
this.input('url', pageflow.TextInputView, {
|
28
|
+
required: true
|
29
|
+
});
|
30
|
+
this.input('open_in_new_tab', pageflow.CheckBoxInputView);
|
31
|
+
this.input('thumbnail', pageflow.FileInputView, {
|
32
|
+
collection: pageflow.imageFiles,
|
33
|
+
fileSelectionHandler: 'externalLinks.site',
|
34
|
+
fileSelectionHandlerOptions: {
|
35
|
+
pageId: options.page && options.page.id,
|
36
|
+
returnTo: options.returnTo
|
37
|
+
},
|
38
|
+
imagePositioning: false
|
39
|
+
});
|
40
|
+
this.input('title', pageflow.TextInputView, {
|
41
|
+
required: true
|
42
|
+
});
|
43
|
+
this.input('description', pageflow.TextAreaInputView, {size: 'short'});
|
44
|
+
});
|
45
|
+
|
46
|
+
if (this.options.returnTo === 'page' && this.options.page) {
|
47
|
+
this.ui.backButton.text('Zurück');
|
48
|
+
}
|
49
|
+
|
50
|
+
this.formContainer.show(configurationEditor);
|
51
|
+
},
|
52
|
+
|
53
|
+
destroy: function() {
|
54
|
+
if (confirm("Externen Verweis wirklich löschen?\n\nAlle Benutzungen dieses Verweises auf Seiten werden ebenfalls entfernt. Dieser Schritt kann nicht rückgängig gemacht werden.")) {
|
55
|
+
this.model.destroy();
|
56
|
+
this.goBack();
|
57
|
+
}
|
58
|
+
},
|
59
|
+
|
60
|
+
goBack: function() {
|
61
|
+
if (this.options.returnTo === 'page' && this.options.page) {
|
62
|
+
pageflow.editor.navigate('/pages/' + this.options.page.id + '/links', {trigger: true});
|
63
|
+
}
|
64
|
+
else {
|
65
|
+
var query = this.options.page ? '?page=' + this.options.page.id : '';
|
66
|
+
pageflow.editor.navigate('/external_links/sites' + query, {trigger: true});
|
67
|
+
}
|
68
|
+
}
|
69
|
+
});
|