Diff
Modified: branches/galaxy-integration/Gemfile (2964 => 2965)
--- branches/galaxy-integration/Gemfile 2012-03-07 10:25:57 UTC (rev 2964)
+++ branches/galaxy-integration/Gemfile 2012-03-07 10:28:15 UTC (rev 2965)
@@ -15,4 +15,5 @@
gem "marc", "~> 0.4.1"
gem "ruby-hmac", "~> 0.4.0"
gem "passenger", "~> 2.2.15"
+gem "htmlentities", "~> 4.3.1"
Modified: branches/galaxy-integration/Rakefile (2964 => 2965)
--- branches/galaxy-integration/Rakefile 2012-03-07 10:25:57 UTC (rev 2964)
+++ branches/galaxy-integration/Rakefile 2012-03-07 10:28:15 UTC (rev 2965)
@@ -174,3 +174,21 @@
end
end
+desc 'Get workflow components'
+task "myexp:workflow:components" do
+ require File.dirname(__FILE__) + '/config/environment'
+
+ ids = ENV['ID'].split(",").map do |str| str.to_i end
+
+ doc = LibXML::XML::Document.new
+ doc.root = LibXML::XML::Node.new("results")
+
+ ids.each do |id|
+ components = Workflow::Version.find(id).components
+ components['workflow-version'] = id.to_s
+ doc.root << components
+ end
+
+ puts doc.to_s
+end
+
Modified: branches/galaxy-integration/app/views/contributions/_in_packs_box.rhtml (2964 => 2965)
--- branches/galaxy-integration/app/views/contributions/_in_packs_box.rhtml 2012-03-07 10:25:57 UTC (rev 2964)
+++ branches/galaxy-integration/app/views/contributions/_in_packs_box.rhtml 2012-03-07 10:28:15 UTC (rev 2965)
@@ -34,13 +34,16 @@
<div class="fold" id="add_to_pack_fold">
<div class="foldTitle">Add to your Pack</div>
<div class="foldContent" style="display: none;">
- <% form_remote_tag :url ="" quick_add_pack_url(potential_packs.first),
- :method => :post,
- :loading => "$('pack_add_spinner').show();",
- :complete => "$('pack_add_spinner').hide();",
- :id => "add_to_pack_form" do %>
+ <% form_tag quick_add_pack_url(potential_packs.first),
+ { : "new Ajax.Request(this.action, " +
+ "{asynchronous:true, evalScripts:true, method:'post', "+
+ "onComplete:function(request){$('pack_add_spinner').hide();},"+
+ "onLoading:function(request){$('pack_add_spinner').show();}," +
+ "parameters:Form.serialize(this)});return false;",
+ :method => :post,
+ :id => "add_to_pack_form" } do %>
<p>
- <select style="width: 99%" = $(this).options[this.selectedIndex].value; return false">
+ <select id="add_to_pack_selector" style="width: 99%" = $(this).options[this.selectedIndex].value; return false">
<% potential_packs.each do |p| -%>
<option value="<%= quick_add_pack_url(p) -%>">
<%= h(p.title) -%>
Modified: branches/galaxy-integration/app/views/contributions/_sharing_form.rhtml (2964 => 2965)
--- branches/galaxy-integration/app/views/contributions/_sharing_form.rhtml 2012-03-07 10:25:57 UTC (rev 2964)
+++ branches/galaxy-integration/app/views/contributions/_sharing_form.rhtml 2012-03-07 10:28:15 UTC (rev 2965)
@@ -193,28 +193,32 @@
function toggle_layout_option(id, enable) {
var option = $$('select#layout option[value=' + id + ']').first();
- //If a "share with group" box is unticked, and that group's layout is selected, go to default.
- if(!enable){
- if($('layout').selectedIndex == option.index){
- $('layout').selectedIndex = 0;
+ if(option != null) {
+ //If a "share with group" box is unticked, and that group's layout is selected, go to default.
+ if(!enable){
+ if($('layout').selectedIndex == option.index){
+ $('layout').selectedIndex = 0;
+ }
}
- }
- //Disable/enable option in dropdown menu
- option.disabled = !enable;
+ //Disable/enable option in dropdown menu
+ option.disabled = !enable;
- //If all options except "default" are disabled, hide the layout option box
- if($$('select#layout option[disabled]').size() == ($$('select#layout option').size() - 1)) {
- $('layout_options_box').hide();
+ //If all options except "default" are disabled, hide the layout option box
+ if($$('select#layout option[disabled]').size() == ($$('select#layout option').size() - 1)) {
+ $('layout_options_box').hide();
+ }
+ else {
+ $('layout_options_box').show();
+ }
}
- else {
- $('layout_options_box').show();
- }
}
//Initial state
- $$('input.group_sharing').each (function (box) {
- toggle_layout_option(box.value, box.checked);
+ document.observe("dom:loaded", function() {
+ $$('input.group_sharing').each (function (box) {
+ toggle_layout_option(box.value, box.checked);
+ });
});
</script>
Modified: branches/galaxy-integration/config/tables.xml
(Binary files differ)
Modified: branches/galaxy-integration/lib/rest.rb (2964 => 2965)
--- branches/galaxy-integration/lib/rest.rb 2012-03-07 10:25:57 UTC (rev 2964)
+++ branches/galaxy-integration/lib/rest.rb 2012-03-07 10:28:15 UTC (rev 2965)
@@ -15,7 +15,7 @@
TABLES = parse_excel_2003_xml(File.read('config/tables.xml'),
{ 'Model' => { :indices => [ 'REST Entity' ],
- :lists => [ 'REST Attribute', 'Encoding', 'Accessor',
+ :lists => [ 'REST Attribute', 'Encoding', 'HTML', 'Accessor',
'Create', 'Read', 'Update', 'Read by default',
'List Element Name', 'List Element Accessor',
'Example', 'Versioned', 'Key type',
@@ -168,6 +168,8 @@
accessor = model_data['Accessor'][i]
+ accessor = "#{accessor}_plaintext" if query["show-plaintext"] == "yes" && model_data['HTML'][i] == "yes"
+
text = ''
attrs = {}
@@ -208,31 +210,31 @@
item_uri = rest_resource_uri(item)
list_element_accessor = model_data['List Element Accessor'][i]
- list_element_text = list_element_accessor ? eval("item.#{model_data['List Element Accessor'][i]}") : item
+ list_element_item = list_element_accessor ? eval("item.#{model_data['List Element Accessor'][i]}") : item
- if list_element_text
- if list_element_text.instance_of?(String)
+ if list_element_item
+ if list_element_item.instance_of?(String)
el = LibXML::XML::Node.new(model_data['List Element Name'][i])
- item_attrs['resource'] = item_uri if item_uri
- item_attrs['uri'] = rest_access_uri(item)
+ item_attrs['resource'] = item_uri if item_uri && query["show-resource"] != "no"
+ item_attrs['uri'] = rest_access_uri(item) if query["show-uri"] != "no"
item_attrs.each do |key,value|
el[key] = value
end
- el << list_element_text.to_s if list_element_text
+ el << list_element_item.to_s if list_element_item
list_element << el
else
- el = rest_get_request_aux(item, user, { "id" => item.id.to_s }, list_item_select_elements)
+ el = rest_get_request_aux(list_element_item, user, query.merge({ "id" => list_element_item.id.to_s }), list_item_select_elements)
if model_data['List Element Name'][i]
el.name = model_data['List Element Name'][i]
end
if list_item_select_elements.nil? || list_item_select_elements.empty?
- el << item.label if item.respond_to?(:label)
+ el << list_element_item.label if list_element_item.respond_to?(:label)
end
list_element << el
@@ -272,8 +274,8 @@
if item != nil
resource_uri = rest_resource_uri(item)
- el['resource'] = resource_uri if resource_uri
- el['uri'] = rest_access_uri(item)
+ el['resource'] = resource_uri if resource_uri && query["show-resource"] != "no"
+ el['uri'] = rest_access_uri(item) if query["show-uri"] != "no"
el << item.label if item.respond_to?(:label) && item.label
end
@@ -338,9 +340,9 @@
resource = rest_resource_uri(ob)
version = ob.current_version.to_s if ob.respond_to?('versions')
- entity['uri' ] = uri if uri
- entity['resource'] = resource if resource
- entity['version' ] = version if version
+ entity['uri' ] = uri if uri && query["show-uri"] != "no"
+ entity['resource'] = resource if resource && query["show-resource"] != "no"
+ entity['version' ] = version if version && query["show-version"] != "no"
TABLES['Model'][:data][rest_entity]['REST Attribute'].each do |rest_attribute|
data = "" user, rest_entity, rest_attribute, query, elements)
@@ -785,9 +787,9 @@
resource_uri = rest_resource_uri(ob)
- el['resource'] = resource_uri if resource_uri
- el['uri' ] = rest_access_uri(ob)
- el['version' ] = ob.current_version.to_s if ob.respond_to?('current_version')
+ el['resource'] = resource_uri if resource_uri && query["show-resource"] != "no"
+ el['uri' ] = rest_access_uri(ob) if query["show-uri"] != "no"
+ el['version' ] = ob.current_version.to_s if ob.respond_to?('current_version') && query["show-version"] != "no"
el << rest_object_label_text(ob) if !skip_text
Modified: branches/galaxy-integration/vendor/plugins/white_list_formatted_content/init.rb (2964 => 2965)
--- branches/galaxy-integration/vendor/plugins/white_list_formatted_content/init.rb 2012-03-07 10:25:57 UTC (rev 2964)
+++ branches/galaxy-integration/vendor/plugins/white_list_formatted_content/init.rb 2012-03-07 10:28:15 UTC (rev 2965)
@@ -1,3 +1,5 @@
+require 'htmlentities'
+
ActiveRecord::Base.class_eval do
include ActionView::Helpers::TagHelper, ActionView::Helpers::TextHelper, WhiteListHelper, ActionView::Helpers::UrlHelper
def self.format_attribute(attr_name)
@@ -5,6 +7,41 @@
define_method(:body) { read_attribute attr_name }
define_method(:body_html) { read_attribute "#{attr_name}_html" }
define_method(:body_html=) { |value| write_attribute "#{attr_name}_html", value }
+
+ define_method("#{attr_name}_plaintext".to_sym) do
+
+ html = read_attribute("#{attr_name}_html")
+
+ # collapse whitespace
+ html.gsub!(/[ \t\r\n]+/, ' ')
+
+ tokenizer = HTML::Tokenizer.new(html)
+ output = []
+
+ linebreak_tags = ['</h1>', '</h2>', '</h3>', '</h4>']
+
+ while token = tokenizer.next
+ node = HTML::Node.parse(nil, 0, 0, token, false)
+
+ case node
+ when HTML::Text
+ output << token
+ when HTML::Tag
+ output << "\n\n" if linebreak_tags.include?(token)
+ end
+ end
+
+ output = output.join
+
+ # collapse spaces
+ output.gsub!(/ +/, ' ')
+
+ # convert entities
+ output = HTMLEntities.new.decode(output)
+
+ output.strip
+ end
+
before_save :format_content
end