Add more macro support: cryptocompare and tradingview
This commit is contained in:
parent
790a5ac489
commit
dd007bf24f
@ -4,6 +4,8 @@ Changelog
|
||||
1.0.3
|
||||
+++++
|
||||
|
||||
- TradingView macro support
|
||||
- CryptoCompare macro support
|
||||
- Reddit macro support
|
||||
- Twitter macro improved with prefix image
|
||||
|
||||
|
15
app/views/wiki/_cryptocompare.html.erb
Normal file
15
app/views/wiki/_cryptocompare.html.erb
Normal file
@ -0,0 +1,15 @@
|
||||
<script type="text/javascript">
|
||||
baseUrl = "https://widgets.cryptocompare.com/serve/v2/coin/chart";
|
||||
var scripts = document.getElementsByTagName("script");
|
||||
var embedder = scripts[ scripts.length - 1 ];
|
||||
(function (){
|
||||
var appName = encodeURIComponent(window.location.hostname);
|
||||
if(appName==""){appName="local";}
|
||||
var s = document.createElement("script");
|
||||
s.type = "text/javascript";
|
||||
s.async = true;
|
||||
var theUrl = '<%= raw url %>';
|
||||
s.src = theUrl + ( theUrl.indexOf("?") >= 0 ? "&" : "?") + "app=" + appName;
|
||||
embedder.parentNode.appendChild(s);
|
||||
})();
|
||||
</script>
|
6
app/views/wiki/_tradingview.html.erb
Normal file
6
app/views/wiki/_tradingview.html.erb
Normal file
@ -0,0 +1,6 @@
|
||||
<!-- TradingView Widget BEGIN -->
|
||||
<script type="text/javascript" src="https://d33t3vvu2t2yu5.cloudfront.net/tv.js"></script>
|
||||
<script type="text/javascript">
|
||||
new TradingView.widget(<%= raw options.to_json %>);
|
||||
</script>
|
||||
<!-- TradingView Widget END -->
|
@ -71,7 +71,7 @@ Features
|
||||
* welcome text for login page
|
||||
* global sidebar content support
|
||||
* set info message above new ticket (e.g. for guidelines)
|
||||
* Wiki macros for: date, Gihub gist, issues, members, projects slideshare, twitter, reddit, user, youtube and vimeo
|
||||
* Wiki macros for: date, Gihub gist, issues, members, projects slideshare, twitter, reddit, tradingview, cryptocompare, user, youtube and vimeo
|
||||
* option to remove "my page" from top menu
|
||||
* customize "Help" url in top menu
|
||||
* customize top menu items
|
||||
|
@ -6,16 +6,18 @@ These wiki macros are available with Redmine Tweaks plugins.
|
||||
If a parameter is in brackets, this parameter is optional.
|
||||
|
||||
.. include:: macros/calendar.rst
|
||||
.. include:: macros/cryptocompare.rst
|
||||
.. include:: macros/date.rst
|
||||
.. include:: macros/gist.rst
|
||||
.. include:: macros/issue.rst
|
||||
.. include:: macros/last_updated_by.rst
|
||||
.. include:: macros/last_updated_at.rst
|
||||
.. include:: macros/last_updated_by.rst
|
||||
.. include:: macros/members.rst
|
||||
.. include:: macros/projects.rst
|
||||
.. include:: macros/recently_updated.rst
|
||||
.. include:: macros/reddit.rst
|
||||
.. include:: macros/slideshare.rst
|
||||
.. include:: macros/tradingview.rst
|
||||
.. include:: macros/twitter.rst
|
||||
.. include:: macros/user.rst
|
||||
.. include:: macros/vimeo.rst
|
||||
|
39
docs/macros/cryptocompare.rst
Normal file
39
docs/macros/cryptocompare.rst
Normal file
@ -0,0 +1,39 @@
|
||||
CryptoCompare
|
||||
-------------
|
||||
|
||||
CryptoCompare wiki macro for Redmine.
|
||||
|
||||
See https://www.cryptocompare.com/dev/widget/wizard/ for more information.
|
||||
|
||||
.. function:: {{cryptocompare(options)}}
|
||||
|
||||
show CryptoCompare information
|
||||
|
||||
:param string fsym: default BTC
|
||||
:param string tsym: default EUR
|
||||
:param string fsyms: default BTC,ETH,LTC (if supported by widget type)
|
||||
:param string tsyms: default EUR,USD (if supported by widget type)
|
||||
:param string period:
|
||||
:param string type: widget type has to be one of
|
||||
- chart
|
||||
- news
|
||||
- list
|
||||
- titles
|
||||
- tabbed
|
||||
- header
|
||||
- header_v2
|
||||
- header_v3
|
||||
- summary
|
||||
- historical
|
||||
- converter
|
||||
- advanced
|
||||
|
||||
|
||||
Examples
|
||||
++++++++
|
||||
|
||||
Show ``header_v3`` widget type for crypto currencies ``BTC`` and ``ETH``
|
||||
|
||||
.. code-block:: smarty
|
||||
|
||||
{{cryptocompare(fsyms=BTC;ETH, type=header_v3)}}
|
@ -1,5 +1,5 @@
|
||||
Reddit
|
||||
-------
|
||||
------
|
||||
|
||||
Reddit wiki macro for Redmine.
|
||||
|
||||
|
34
docs/macros/tradingview.rst
Normal file
34
docs/macros/tradingview.rst
Normal file
@ -0,0 +1,34 @@
|
||||
TradingView
|
||||
-----------
|
||||
|
||||
TradingView wiki macro for Redmine.
|
||||
|
||||
See https://www.tradingview.com/widget/ for more information.
|
||||
|
||||
.. function:: {{tradingview(options)}}
|
||||
|
||||
show TradingView chart
|
||||
|
||||
:param int width: default 640
|
||||
:param int height: default 480
|
||||
:param string symbol: default NASDAQ:AAPL
|
||||
:param string interval: default W
|
||||
:param string timezone: default Europe/Berlin
|
||||
:param string theme: default White
|
||||
:param int style: default 2
|
||||
:param string locale: default de
|
||||
:param string toolbar_bg: default #f1f3f6
|
||||
:param bool enable_publishing: default false
|
||||
:param bool allow_symbol_change: default true
|
||||
:param bool hideideasbutton: default true
|
||||
|
||||
|
||||
|
||||
Examples
|
||||
++++++++
|
||||
|
||||
Show chart with symbol ``NASDAQ:AMZN`` and use English locale
|
||||
|
||||
.. code-block:: smarty
|
||||
|
||||
{{tradingview(symbol=NASDAQ:AMZN, locale: en)}}
|
@ -30,6 +30,7 @@ if ActiveRecord::Base.connection.table_exists?(:settings)
|
||||
|
||||
# Wiki macros
|
||||
require_dependency 'redmine_tweaks/wiki_macros/calendar'
|
||||
require_dependency 'redmine_tweaks/wiki_macros/cryptocompare'
|
||||
require_dependency 'redmine_tweaks/wiki_macros/date'
|
||||
require_dependency 'redmine_tweaks/wiki_macros/gist'
|
||||
require_dependency 'redmine_tweaks/wiki_macros/issue_macro'
|
||||
@ -40,6 +41,7 @@ if ActiveRecord::Base.connection.table_exists?(:settings)
|
||||
require_dependency 'redmine_tweaks/wiki_macros/recently_updated'
|
||||
require_dependency 'redmine_tweaks/wiki_macros/reddit'
|
||||
require_dependency 'redmine_tweaks/wiki_macros/slideshare'
|
||||
require_dependency 'redmine_tweaks/wiki_macros/tradingview'
|
||||
require_dependency 'redmine_tweaks/wiki_macros/twitter'
|
||||
require_dependency 'redmine_tweaks/wiki_macros/user_macro'
|
||||
require_dependency 'redmine_tweaks/wiki_macros/vimeo'
|
||||
|
96
lib/redmine_tweaks/wiki_macros/cryptocompare.rb
Normal file
96
lib/redmine_tweaks/wiki_macros/cryptocompare.rb
Normal file
@ -0,0 +1,96 @@
|
||||
# Redmine Tweaks plugin for Redmine
|
||||
# Copyright (C) 2013-2017 AlphaNodes GmbH
|
||||
|
||||
# see https://www.cryptocompare.com/dev/widget/wizard/
|
||||
|
||||
module RedmineTweaks
|
||||
module WikiMacros
|
||||
Redmine::WikiFormatting::Macros.register do
|
||||
desc <<-EOHELP
|
||||
Create CryptoCompare information.
|
||||
{{cryptocompare(options)}}
|
||||
see https://www.cryptocompare.com/dev/widget/wizard/
|
||||
EOHELP
|
||||
macro :cryptocompare do |_obj, args|
|
||||
raise 'The correct usage is {{cryptocompare(options)}}' if args.empty?
|
||||
args, options = extract_macro_options(args, :fsym, :fsyms, :tsym, :tsyms, :period, :type)
|
||||
|
||||
options[:fsym] = 'BTC' if options[:fsym].blank?
|
||||
options[:tsym] = 'EUR' if options[:tsym].blank?
|
||||
|
||||
if options[:type].blank?
|
||||
widget_type = 'chart'
|
||||
else
|
||||
widget_type = options[:type]
|
||||
options.delete(:type)
|
||||
end
|
||||
|
||||
base_url = 'https://widgets.cryptocompare.com/'
|
||||
|
||||
case widget_type
|
||||
when 'chart'
|
||||
url = base_url + 'serve/v2/coin/chart'
|
||||
when 'news'
|
||||
options[:feedType] = 'CoinTelegraph' if options[:feedType].blank?
|
||||
url = base_url + 'serve/v1/coin/feed'
|
||||
when 'list'
|
||||
options[:tsyms] = RedmineTweaks.crypto_default(options, :tsyms, 'EUR,USD')
|
||||
options.delete(:tsym)
|
||||
url = base_url + 'serve/v1/coin/list'
|
||||
when 'titles'
|
||||
options[:tsyms] = RedmineTweaks.crypto_default(options, :tsyms, 'EUR,USD')
|
||||
options.delete(:tsym)
|
||||
url = base_url + 'serve/v1/coin/tiles'
|
||||
when 'tabbed'
|
||||
options[:fsyms] = RedmineTweaks.crypto_default(options, :fsyms, 'BTC,ETH,LTC')
|
||||
options[:tsyms] = RedmineTweaks.crypto_default(options, :tsyms, 'EUR,USD')
|
||||
options.delete(:fsym)
|
||||
options.delete(:tsym)
|
||||
url = base_url + 'serve/v1/coin/multi'
|
||||
when 'header', 'header_v1'
|
||||
options[:tsyms] = RedmineTweaks.crypto_default(options, :tsyms, 'EUR,USD')
|
||||
options.delete(:tsym)
|
||||
url = base_url + 'serve/v1/coin/header'
|
||||
when 'header_v2'
|
||||
options[:fsyms] = RedmineTweaks.crypto_default(options, :fsyms, 'BTC,ETH,LTC')
|
||||
options[:tsyms] = RedmineTweaks.crypto_default(options, :tsyms, 'EUR,USD')
|
||||
options.delete(:fsym)
|
||||
options.delete(:tsym)
|
||||
url = base_url + 'serve/v2/coin/header'
|
||||
when 'header_v3'
|
||||
options[:fsyms] = RedmineTweaks.crypto_default(options, :fsyms, 'BTC,ETH,LTC')
|
||||
options[:tsyms] = RedmineTweaks.crypto_default(options, :tsyms, 'EUR')
|
||||
options.delete(:fsym)
|
||||
options.delete(:tsym)
|
||||
url = base_url + 'serve/v3/coin/header'
|
||||
when 'summary'
|
||||
options[:tsyms] = RedmineTweaks.crypto_default(options, :tsyms, 'EUR,USD')
|
||||
options.delete(:tsym)
|
||||
url = base_url + 'serve/v1/coin/summary'
|
||||
when 'historical'
|
||||
url = base_url + 'serve/v1/coin/histo_week'
|
||||
when 'converter'
|
||||
options[:tsyms] = RedmineTweaks.crypto_default(options, :tsyms, 'EUR,USD')
|
||||
options.delete(:tsym)
|
||||
url = base_url + 'serve/v1/coin/converter'
|
||||
when 'advanced'
|
||||
options[:tsyms] = RedmineTweaks.crypto_default(options, :tsyms, 'EUR,USD')
|
||||
options.delete(:tsym)
|
||||
url = base_url + 'serve/v3/coin/chart'
|
||||
else
|
||||
raise 'type is not supported'
|
||||
end
|
||||
|
||||
render partial: 'wiki/cryptocompare', locals: { url: url + '?' + options.map { |k, v| "#{k}=#{v}" }.join('&') }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.crypto_default(options, name, defaults)
|
||||
if options[name].blank?
|
||||
defaults
|
||||
else
|
||||
options[name].tr(';', ',')
|
||||
end
|
||||
end
|
||||
end
|
38
lib/redmine_tweaks/wiki_macros/tradingview.rb
Normal file
38
lib/redmine_tweaks/wiki_macros/tradingview.rb
Normal file
@ -0,0 +1,38 @@
|
||||
# Redmine Tweaks plugin for Redmine
|
||||
# Copyright (C) 2013-2017 AlphaNodes GmbH
|
||||
|
||||
# see https://www.tradingview.com/widget/
|
||||
|
||||
# Tradingview wiki macros
|
||||
module RedmineTweaks
|
||||
module WikiMacros
|
||||
Redmine::WikiFormatting::Macros.register do
|
||||
desc <<-EOHELP
|
||||
Creates Tradingview chart
|
||||
{{tradingview(options)}}
|
||||
see https://www.tradingview.com/widget/
|
||||
EOHELP
|
||||
macro :tradingview do |_obj, args|
|
||||
raise 'The correct usage is {{tradingview(options)}}' if args.empty?
|
||||
args, options = extract_macro_options(args, :width, :height, :symbol, :interval, :timezone,
|
||||
:theme, :style, :locale, :toolbar_bg, :enable_publishing,
|
||||
:allow_symbol_change, :hideideasbutton)
|
||||
|
||||
options[:width] = 640 if options[:width].blank?
|
||||
options[:height] = 480 if options[:height].blank?
|
||||
options[:symbol] = 'NASDAQ:AAPL' if options[:symbol].blank?
|
||||
options[:interval] = 'W' if options[:interval].blank?
|
||||
options[:timezone] = 'Europe/Berlin' if options[:timezone].blank?
|
||||
options[:theme] = 'White' if options[:theme].blank?
|
||||
options[:style] = 2 if options[:style].blank?
|
||||
options[:locale] = 'de' if options[:locale].blank?
|
||||
options[:toolbar_bg] = "#f1f3f6" if options[:toolbar_bg].blank?
|
||||
options[:enable_publishing] = false if options[:enable_publishing].blank?
|
||||
options[:allow_symbol_change] = true if options[:allow_symbol_change].blank?
|
||||
options[:hideideasbutton] = true if options[:hideideasbutton].blank?
|
||||
|
||||
render partial: 'wiki/tradingview', locals: { options: options }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user