Skip to content
Snippets Groups Projects
Commit a34e7d4c authored by Arnaud Levy's avatar Arnaud Levy
Browse files

Merge branch 'master' of github.com:noesya/osuny

parents b418ce80 168c1323
No related branches found
No related tags found
No related merge requests found
......@@ -2,50 +2,63 @@
$(function () {
'use strict';
var configs = [];
configs['mini'] = {
toolbar: [
['font', ['bold', 'italic']],
['insert', ['link']],
['view', ['codeview']]
]
};
configs['default'] = {
popover: {
image: [
['remove', ['removeMedia']]
]
},
toolbar: [
['style', ['style']],
['font', ['bold', 'italic']],
['para', ['ul', 'ol']],
['table', ['table']],
['insert', ['link', 'picture', 'video']],
['view', ['codeview']]
],
styleTags: [
'p',
'blockquote',
'pre',
'h2',
'h3',
'h4'
],
followingToolbar: true,
callbacks: {
onImageUpload: function (files) {
var attachmentUpload = new SummernoteAttachmentUpload(this, files[0]);
attachmentUpload.start();
},
onMediaDelete: function (_, $editable) {
$.summernote.rails.cleanEmptyAttachments($editable);
},
onKeyup: function (e) {
var $editable = $(e.currentTarget);
if (e.keyCode === 8) {
$.summernote.rails.cleanEmptyAttachments($editable);
}
}
}
};
$.extend($.summernote.lang['en-US'].image, {
dragImageHere: 'Drag file here',
dropImage: 'Drop file'
});
$('[data-provider="summernote"]').each(function () {
$(this).summernote({
popover: {
image: [
['remove', ['removeMedia']]
]
},
toolbar: [
['style', ['style']],
['font', ['bold', 'italic']],
['para', ['ul', 'ol']],
['table', ['table']],
['insert', ['link', 'picture', 'video']],
['view', ['codeview']]
],
styleTags: [
'p',
'blockquote',
'pre',
'h2',
'h3',
'h4'
],
followingToolbar: true,
callbacks: {
onImageUpload: function (files) {
var attachmentUpload = new SummernoteAttachmentUpload(this, files[0]);
attachmentUpload.start();
},
onMediaDelete: function (_, $editable) {
$.summernote.rails.cleanEmptyAttachments($editable);
},
onKeyup: function (e) {
var $editable = $(e.currentTarget);
if (e.keyCode === 8) {
$.summernote.rails.cleanEmptyAttachments($editable);
}
}
}
});
var config = $(this).attr('data-summernote-config');
config = config || 'default';
$(this).summernote(configs[config]);
});
});
......@@ -120,10 +120,17 @@ class Communication::Website::Page < ApplicationRecord
end
def slug_unavailable?(slug)
self.class.unscoped
.where(communication_website_id: self.communication_website_id, slug: slug)
.where.not(id: self.id)
.exists?
[
website.index_for(:communication_posts).path,
website.index_for(:education_programs).path,
website.index_for(:persons).path,
website.index_for(:research_articles).path,
website.index_for(:research_volumes).path
].include?(slug) ||
self.class.unscoped
.where(communication_website_id: self.communication_website_id, slug: slug)
.where.not(id: self.id)
.exists?
end
def explicit_blob_ids
......
......@@ -2,6 +2,7 @@ module WithSlug
extend ActiveSupport::Concern
included do
validates :slug, presence: true
validate :slug_must_be_unique
validates :slug, format: { with: /\A[a-z0-9\-]+\z/, message: I18n.t('slug_error') }
......
......@@ -37,6 +37,7 @@ class Research::Journal::Article < ApplicationRecord
include WithGit
include WithBlobs
include WithPosition
include WithSlug
has_summernote :text
has_one_attached :pdf
......
......@@ -28,8 +28,9 @@
#
class Research::Journal::Volume < ApplicationRecord
include WithGit
include WithFeaturedImage
include WithBlobs
include WithFeaturedImage
include WithSlug
belongs_to :university
belongs_to :journal, foreign_key: :research_journal_id
......
......@@ -22,7 +22,12 @@
input_html: { name: 'communication_website_index_page[breadcrumb_title]' },
hint: t('simple_form.hints.communication_website_index_page.breadcrumb_title') %>
<%= f.input :description, input_html: { name: 'communication_website_index_page[description]' } %>
<%= f.input :header_text, as: :summernote, input_html: { name: 'communication_website_index_page[header_text]' } %>
<%= f.input :header_text,
as: :summernote,
input_html: {
name: 'communication_website_index_page[header_text]',
data: { 'summernote-config' => 'mini' }
} %>
<%= f.input :text, as: :summernote, input_html: { name: 'communication_website_index_page[text]' } %>
</div>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment