Legacy smiley/emoji support has been added

This commit is contained in:
Alexander Meindl 2017-04-27 16:53:08 +02:00
parent 22ac3b94bc
commit 5c3b18393f
38 changed files with 263 additions and 9 deletions

View File

@ -1,6 +1,11 @@
Changelog
=========
1.0.2
+++++
- Smiley/Emoji legacy support
1.0.1
+++++

View File

@ -1,4 +1,5 @@
gem 'deface'
gem 'gemoji', '~> 3.0.0'
group :test do
gem 'brakeman'

View File

@ -35,5 +35,11 @@
<p>
<%= content_tag(:label, l(:label_add_go_to_top)) %>
<%= check_box_tag 'settings[add_go_to_top]', 1, @settings[:add_go_to_top] %>
<em class="info"><%= t(:label_add_go_to_top_info) %></em>
<em class="info"><%= t(:add_go_to_top_info) %></em>
</p>
<p>
<%= content_tag(:label, l(:label_legacy_smiley_support)) %>
<%= check_box_tag 'settings[legacy_smiley_support]', 1, @settings[:legacy_smiley_support] %>
<em class="info"><%= t(:legacy_smiley_support_info_html) %></em>
</p>

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 874 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 759 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 925 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1000 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 862 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 790 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 869 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 820 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 856 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 863 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 830 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 890 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 911 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 806 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 832 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 808 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 795 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 840 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 850 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 899 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 933 B

View File

@ -18,7 +18,7 @@
}
.month-calendar {
display:inline-block;
display: inline-block;
}
.login-tweaks {
@ -27,3 +27,106 @@
max-width: 490px;
font-size: 95%;
}
/* Legacy smilie classes */
span.tweaks.smiley {
background-repeat: no-repeat;
display: inline-block;
width: 16px;
height: 16px;
}
span.tweaks.smiley-smiley {
background-image: url(../images/smileys/smiley.png);
}
span.tweaks.smiley-smiley2 {
background-image: url(../images/smileys/smiley2.png);
}
span.tweaks.smiley-laughing {
background-image: url(../images/smileys/smiley-grin.png);
}
span.tweaks.smiley-laughing2 {
background-image: url(../images/smileys/smiley-laughing2.png);
}
span.tweaks.smiley-crying {
background-image: url(../images/smileys/smiley-cry.png);
}
span.tweaks.smiley-sad {
background-image: url(../images/smileys/smiley-sad.png);
}
span.tweaks.smiley-wink {
background-image: url(../images/smileys/smiley-wink.png);
}
span.tweaks.smiley-cheeky {
background-image: url(../images/smileys/smiley-razz.png);
}
span.tweaks.smiley-shock {
background-image: url(../images/smileys/smiley-eek.png);
}
span.tweaks.smiley-annoyed {
background-image: url(../images/smileys/smiley-annoyed.png);
}
span.tweaks.smiley-confuse {
background-image: url(../images/smileys/smiley-confuse.png);
}
span.tweaks.smiley-straight {
background-image: url(../images/smileys/smiley-neutral.png);
}
span.tweaks.smiley-embarrassed {
background-image: url(../images/smileys/smiley-red.png);
}
span.tweaks.smiley-kiss {
background-image: url(../images/smileys/smiley-kiss.png);
}
span.tweaks.smiley-angel {
background-image: url(../images/smileys/smiley-angel.png);
}
span.tweaks.smiley-evil {
background-image: url(../images/smileys/smiley-evil.png);
}
span.tweaks.smiley-rock {
background-image: url(../images/smileys/smiley-cool.png);
}
span.tweaks.smiley-rose {
background-image: url(../images/smileys/rose.png);
width: 24px;
height: 24px;
}
span.tweaks.smiley-check {
background-image: url(../images/smileys/check.png);
}
span.tweaks.smiley-exclamation {
background-image: url(../images/smileys/exclamation-red-frame.png);
}
span.tweaks.smiley-question {
background-image: url(../images/smileys/question-frame.png);
}
span.tweaks.smiley-success {
background-image: url(../images/smileys/success-frame.png);
}
span.tweaks.smiley-failure {
background-image: url(../images/smileys/failure-frame.png);
}

View File

@ -29,7 +29,7 @@ de:
global_wiki_header_info: 'Hier kann ein projektübergreifender Wiki Header hinterlegt werden. Wird über "Wiki Extensions" ein projektspezifischer Header angelegt, wird dieser immer vorzugsweise vor dem projektübergreifenden Header verwendet.'
global_wiki_sidebar_info: 'Hier kann für die Wiki Sidebar ein projektübergreifender Text hinterlegt werden. Diese Sidebar wird nur auf den Wiki Seiten angezeigt und kann z.B. für Makros wie "Zuletzt geänderte Seiten" verwendet werden. Wird eine projektspezifische Sidebar angelegt (über eine Wiki Seite), dann wird diese anstelle der projektübergreifenden Sidebar angezeigt.'
label_account_login: "Text für Anmeldeseite"
label_add_go_to_top_info: 'Bei langen Seiten ist es hilfreich, wenn ein Link zur Verfügung steht, mit dem man zum Seitenanfang springen kann.'
add_go_to_top_info: 'Bei langen Seiten ist es hilfreich, wenn ein Link zur Verfügung steht, mit dem man zum Seitenanfang springen kann.'
label_add_go_to_top: '"Nach oben" Link hinzufügen'
label_content_plural: Inhalte
label_custom_help_url: "URL zur Hilfeseite"
@ -95,3 +95,5 @@ de:
wiki_pdf_header_info: Dieser Textblock wir auf der ersten Seite vor dem eigentlichen Inhalt der Wiki Seite in der PDF Ansicht angezeigt. Die Makros sind hier nur eingeschränkt einsetzbar.
wiki_pdf_remove_attachments_info: Wenn aktiv, werden die an der Wiki Seite angehängten Dateien nicht in der PDF Ansicht angezeigt.
wiki_pdf_remove_title_info: Wenn aktiv, wird der Wiki Titel nicht in der PDF Ansicht angezeigt.
label_legacy_smiley_support: Smiley/Emoji Support
legacy_smiley_support_info_html: 'Smileys und Emoji Symbole konvertieren. Diese Option sollte nur aktiviert werden, wenn der Code für Smileys oder Emoji manuell eingetragen wird (z.B. :kiss:). Wenn Unicode-Emoji eingesetzt werden sollte diese Option deaktiviert bleiben. Siehe <a href="http://caniemoji.com/" target="_blank">http://caniemoji.com/</a> für Emoji-Browser Support. Im <a href="https://www.webpagefx.com/tools/emoji-cheat-sheet/" target="_blank">Emoji cheat sheet</a> können die zur Verfügung stehenden Emoji-Codes eingesetzt werden. Der <strong>Anwendungsserver muss neu gestartet werden</strong>, damit diese Einstellung aktiv wird.'

View File

@ -29,7 +29,7 @@ en:
global_wiki_header_info: 'Enter a project wide wiki header here. In case a project specific wiki header is used by "Wiki Extensions", this will be preferably displayed instead.'
global_wiki_sidebar_info: 'Enter a project wide available text message for your wiki sidebar, here. This sidebar text will be displayed at the wiki pages only. Use this space for Macros like "Last changed pages" for example. In case a project specific sidebar is used (wiki page), this will be preferably displayed in the sidebar instead.'
label_account_login: "Text for login page"
label_add_go_to_top_info: 'If you have a lot of long pages, it is helpful to add a jump to top link.'
add_go_to_top_info: 'If you have a lot of long pages, it is helpful to add a jump to top link.'
label_add_go_to_top: 'Add "Go to top" link'
label_content_plural: Contents
label_custom_help_url: "Custom Help URL"
@ -95,3 +95,5 @@ en:
wiki_pdf_header_info: This text block will be displayed on the first page before the regular Wiki content in the PDF view. Macro use is very restricted, here.
wiki_pdf_remove_attachments_info: When active the attached Wiki files will not be displayed in PDF view.
wiki_pdf_remove_title_info: When active the Wiki title info will not be displayed in PDF view.
label_legacy_smiley_support: Legacy smiley/emoji support
legacy_smiley_support_info_html: 'Convert Smileys and Emoji symbols. Activate this option only if Smileys or Emoji are manually typed in by the use of code (e.g. :kiss:). If you use Unicode-Emoji this option should be deactivated. For more info on Emoji-Browser support read <a href="http://caniemoji.com/" target="_blank">http://caniemoji.com/</a>. Have a look at <a href="https://www.webpagefx.com/tools/emoji-cheat-sheet/" target="_blank">Emoji cheat sheet</a> for available Emoji-Codes you can use. <strong>Restart the application server</strong>, in order to activate the settings.'

View File

@ -29,7 +29,7 @@ ja:
global_wiki_header_info: 'プロジェクトのWikiヘッダーをここで入力する。「Wiki Extensions」等のプロジェクト特有のWikiヘッダーが使用されている場合、こちらの文章が優先的に表示されます。'
global_wiki_sidebar_info: 'プロジェクト全体のWikiサイドバーで使用される文章を入力する。このサイドバー文章は、Wikiページのみに表示されます。例えば、「直近変更されたページ」等のマクロで使う事をお勧めします。もしプロジェクト特有のサイドバーが使用されている場合でも、こちらの文章がサイドバーで優先的に表示されます。'
label_account_login: "ログイン画面の文章"
label_add_go_to_top_info: '長いページが多い場合、「トップへ」のリンクは役立ちます。'
add_go_to_top_info: '長いページが多い場合、「トップへ」のリンクは役立ちます。'
label_add_go_to_top: '「トップへ」リンクを追加する'
label_content_plural: Contents
label_custom_help_url: "カスタムヘルプURL"
@ -95,3 +95,5 @@ ja:
wiki_pdf_header_info: This text block will be displayed on the first page before the regular Wiki content in the PDF view. Macro use is very restricted, here.
wiki_pdf_remove_attachments_info: When active the attached Wiki files will not be displayed in PDF view.
wiki_pdf_remove_title_info: When active the Wiki title info will not be displayed in PDF view.
label_legacy_smiley_support: Legacy smiley/emoji support
legacy_smiley_support_info_html: 'Convert Smileys and Emoji symbols. Activate this option only if Smileys or Emoji are manually typed in by the use of code (e.g. :kiss:). If you use Unicode-Emoji this option should be deactivated. For more info on Emoji-Browser support read <a href="http://caniemoji.com/" target="_blank">http://caniemoji.com/</a>. Have a look at <a href="https://www.webpagefx.com/tools/emoji-cheat-sheet/" target="_blank">Emoji cheat sheet</a> for available Emoji-Codes you can use. <strong>Restart the application server</strong>, in order to activate the settings.'

View File

@ -28,9 +28,9 @@ copyright = u'2013-2017, AlphaNodes GmbH'
author = u'Alexander Meindl'
# The short X.Y version.
version = u'1.0.0'
version = u'1.0.2'
# The full version, including alpha/beta/rc tags.
release = u'1.0.0'
release = u'1.0.2'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.

View File

@ -49,6 +49,9 @@ Install ``redmine_tweaks`` plugin for `Redmine`_.
$ cd $REDMINE_ROOT
$ git clone git://github.com/alphanodes/redmine_tweaks.git plugins/redmine_tweaks
$ bundle install --without development test
$
$ # if you want to use smiley/emoji legacy support, run:
$ bundle exec gemoji extract public/images/emoji
Restart your application server (apache with passenger, nginx with passenger, unicorn, puma, etc.) and ``redmine_tweaks`` is ready to use.
@ -69,6 +72,7 @@ Features
* customize top menu items
* disable (hide) modules for projects
* open external urls in new window
* smiley/emoji legacy support
* anonymize referrer for external urls
* Hide role in project memberbox
* Configurable issue rules

View File

@ -17,8 +17,11 @@ And the following options can be edited by users with administratios righst in t
* Add "Go to top" link. If you have a lot of long pages, it is enabling users to easily return to the top of a page.
* Change the option for ``External urls`` into default behaviour, open in new window or open with NoReferrer.
* Activate the ``Smileys and Emoji symbols support`` if you want to use the manual smiley code (e.g. ``:kiss:``). This option is deactivated in the standard setting. If you already use a plugin that supports Smileys and Emojis this option should stay deactivated. For more info on Emoji-Browser support read <a href="http://caniemoji.com/" target="_blank">http://caniemoji.com/</a>. Have a look at <a href="https://www.webpagefx.com/tools/emoji-cheat-sheet/" target="_blank">Emoji cheat sheet</a> for available Emoji-Codes.
.. note:: Please restart the application server, if you make changes to the external urls settings.
.. note:: Please restart the application server, if you make changes to the external urls settings as well as if you activate the Smileys and Emoji symbol support.
.. note:: You can use the following manual smiley codes: :), =), :D, =D, :'(, :(, ;), :P, :O, :/, :S, :|, :X, :*, O:), >:), B), (!), (?), (v), (x), (/) and @}->-
Overview page section
---------------------

View File

@ -8,7 +8,7 @@ Redmine::Plugin.register :redmine_tweaks do
name 'Tweaks'
author 'AlphaNodes GmbH'
description 'Wiki and content extensions'
version '1.0.1'
version '1.0.2'
author_url 'https://alphanodes.com/'
url 'https://github.com/alphanodes/redmine_tweaks'
@ -29,6 +29,7 @@ Redmine::Plugin.register :redmine_tweaks do
issue_auto_assign_role: '',
issue_auto_assign_status: '',
issue_auto_assign: 0,
legacy_smiley_support: 0,
new_ticket_message: 'Don\'t forget to define acceptance criteria!',
overview_bottom: '',
overview_right: '',

View File

@ -11,6 +11,17 @@ if ActiveRecord::Base.connection.table_exists?(:settings)
require_dependency 'redmine_tweaks/patches/wiki_controller_patch'
require_dependency 'redmine_tweaks/patches/wiki_pdf_helper_patch'
Rails.configuration.assets.paths << Emoji.images_path
# Send Emoji Patches to all wiki formatters available to be able to switch formatter without app restart
Redmine::WikiFormatting.format_names.each do |format|
case format
when 'markdown'
require_dependency 'redmine_tweaks/patches/formatter_markdown_patch'
when 'textile'
require_dependency 'redmine_tweaks/patches/formatter_textile_patch'
end
end
# Global helpers for Tweaks
require_dependency 'redmine_tweaks/helpers'

View File

@ -0,0 +1,64 @@
# Redmine Tweaks plugin for Redmine
# Copyright (C) 2013-2017 AlphaNodes GmbH
module RedmineTweaks
module Formatter
SMILEYS = {
'smiley' => ':-?\)', # :)
'smiley2' => '=-?\)', # =)
'laughing' => ':-?D', # :D
'laughing2' => '[=]-?D', # =D
'crying' => '[=:][\'*]\(', # :'(
'sad' => '[=:]-?\(', # :(
'wink' => ';-?[)D]', # ;)
'cheeky' => '[=:]-?[Ppb]', # :P
'shock' => '[=:]-?[Oo0]', # :O
'annoyed' => '[=:]-?[\\/]', # :/
'confuse' => '[=:]-?S', # :S
'straight' => '[=:]-?[\|\]]', # :|
'embarrassed' => '[=:]-?[Xx]', # :X
'kiss' => '[=:]-?\*', # :*
'angel' => '[Oo][=:]-?\)', # O:)
'evil' => '>[=:;]-?[)(]', # >:)
'rock' => 'B-?\)', # B)
'rose' => '@[)\}][-\\/\',;()>\}]*', # @}->-
'exclamation' => '[\[(]![\])]', # (!)
'question' => '[\[(]\?[\])]', # (?)
'check' => '[\[(]\\/[\])]', # (/)
'success' => '[\[(]v[\])]', # (v)
'failure' => '[\[(]x[\])]' # (x)
}.freeze
def inline_smileys(text)
SMILEYS.each do |name, regexp|
text.gsub!(%r{(\s|^)(!)?(#{regexp})(?=\W|$)}m) do |match|
leading, esc, smiley = $1, $2, $3
if esc.nil?
leading + "<span class=\"tweaks smiley smiley-#{name}\" title=\"#{smiley}\"></span>"
else
leading + smiley
end
end
end
end
def inline_emojify(text)
text.gsub!(/:([\w+-]+):/) do |match|
emoji = Emoji.find_by_alias($1)
if emoji.present?
%(<img title=":#{$1}:" src="#{inline_emojify_image_path(emoji.image_filename)}" style="vertical-align:middle" width="20" height="20" />)
else
match
end
end
text
end
def inline_emojify_image_path(image_filename)
path = Setting.protocol + '://' + Setting.host_name
# TODO: use relative path, if not for mailer
# path = '/' + Rails.public_path.relative_path_from Rails.root.join('public')
"#{path}/images/emoji/" + image_filename
end
end
end

View File

@ -0,0 +1,27 @@
# Redmine Tweaks plugin for Redmine
# Copyright (C) 2013-2017 AlphaNodes GmbH
module RedmineTweaks
module Patches
module FormatterMarkdownPatch
def self.included(base)
base.class_eval do
base.send(:include, RedmineTweaks::Formatter)
# Add a postprocess hook to redcarpet's html formatter
def postprocess(text)
if RedmineTweaks.settings[:legacy_smiley_support].to_i == 1
inline_emojify(text)
else
text
end
end
end
end
end
end
end
unless Redmine::WikiFormatting::Markdown::HTML.included_modules.include? RedmineTweaks::Patches::FormatterMarkdownPatch
Redmine::WikiFormatting::Markdown::HTML.send(:include, RedmineTweaks::Patches::FormatterMarkdownPatch)
end

View File

@ -0,0 +1,23 @@
# Redmine Tweaks plugin for Redmine
# Copyright (C) 2013-2017 AlphaNodes GmbH
module RedmineTweaks
module Patches
module FormatterTextilePatch
def self.included(base)
base.class_eval do
base.send(:include, RedmineTweaks::Formatter)
# Add :inline_emojify to list of textile functions
if Setting.plugin_redmine_tweaks[:legacy_smiley_support].to_i == 1
Redmine::WikiFormatting::Textile::Formatter::RULES << :inline_emojify
Redmine::WikiFormatting::Textile::Formatter::RULES << :inline_smileys
end
end
end
end
end
end
unless Redmine::WikiFormatting::Textile::Formatter.included_modules.include? RedmineTweaks::Patches::FormatterTextilePatch
Redmine::WikiFormatting::Textile::Formatter.send(:include, RedmineTweaks::Patches::FormatterTextilePatch)
end