forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We can now use context_external_tools_helper to update lti links inside erbs Fixes PLAT-1242 Test Plan: Add an LTI tool using [this xml](https://gist.github.com/defektive/dbd182cb04500e236bde) or use [this url](https://gist.githubusercontent.com/defektive/dbd182cb04500e236bde/raw/4a7939ccb4eca7d604f35f6e593f6e05898682f5/canvas_icon_class-lti_test.xml) check the following cog menus for functioning LTI links - assignments - quizzes - modules - discussions Check the following right side menus for functioning LTI links - Course Home - Course Settings Change-Id: I75f6cf7c5b3e73b25f8bd6c20404e7379bc46ce6 Reviewed-on: https://gerrit.instructure.com/63620 Tested-by: Jenkins Reviewed-by: Nathan Mills <[email protected]> QA-Review: August Thornton <[email protected]> Product-Review: Brad Horrocks <[email protected]>
- Loading branch information
Brad Horrocks
committed
Sep 29, 2015
1 parent
ab3c67a
commit 18e5369
Showing
18 changed files
with
277 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
module ContextExternalToolsHelper | ||
def external_tools_menu_items(tools, options={}) | ||
markup = tools.map do |tool| | ||
external_tool_menu_item_tag(tool, options) | ||
end | ||
raw(markup.join('')) | ||
end | ||
|
||
def external_tool_menu_item_tag(tool, options={}) | ||
defaults = { | ||
show_icon: true, | ||
in_list: false, | ||
url_params: {} | ||
} | ||
|
||
options = defaults.merge(options) | ||
url_params = options.delete(:url_params) | ||
|
||
if tool.respond_to?(:extension_setting) | ||
tool = external_tool_display_hash(tool, options[:settings_key], url_params) | ||
elsif !url_params.empty? | ||
# url_params were supplied, but we aren't hitting the url helper | ||
# we need to make sure the tool url includes the url_params | ||
parsed = URI.parse(tool[:base_url]) | ||
parsed.query = Rack::Utils.parse_nested_query(parsed.query).merge(url_params).to_query | ||
tool[:base_url] = parsed.to_s | ||
end | ||
|
||
link_attrs = { | ||
href: tool[:base_url] | ||
} | ||
|
||
link_attrs[:class] = options[:link_class] if options[:link_class] | ||
link = content_tag(:a, link_attrs) do | ||
concat(render(partial: 'external_tools/helpers/icon', locals: {tool: tool})) if options[:show_icon] | ||
concat(tool[:title]) | ||
concat(external_tool_new_badge_tag) if tool[:is_new] | ||
end | ||
|
||
if options[:in_list] | ||
li_attrs = { | ||
role: "presentation", | ||
class: options[:settings_key] | ||
} | ||
link = content_tag(:li, li_attrs) { link } | ||
end | ||
|
||
raw(link) | ||
end | ||
|
||
def external_tool_new_badge_tag | ||
# <span class="badge new_badge pull-right"><%= t('links.new_badge', 'New') %></span> | ||
tag_attrs = { | ||
class: "badge new_badge pull-right" | ||
} | ||
|
||
content_tag(:span, tag_attrs) do | ||
t('New') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<% if tool[:canvas_icon_class] %> | ||
<i class="<%= tool[:canvas_icon_class] %>"></i> | ||
<% elsif tool[:icon_url] %> | ||
<img class="icon" alt="" src="<%= tool[:icon_url] %>" /> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.