[2] | 1 | <%! |
---|
| 2 | def inherit( context ): |
---|
| 3 | if context.get('no_panels'): |
---|
| 4 | return '/base.mako' |
---|
| 5 | else: |
---|
| 6 | return '/webapps/galaxy/base_panels.mako' |
---|
| 7 | |
---|
| 8 | from galaxy.model import History, StoredWorkflow, Page |
---|
| 9 | from galaxy.web.framework.helpers import iff |
---|
| 10 | %> |
---|
| 11 | <%inherit file="${inherit( context )}"/> |
---|
| 12 | <%namespace file="/tagging_common.mako" import="render_individual_tagging_element, render_community_tagging_element" /> |
---|
| 13 | <%namespace file="/display_common.mako" import="*" /> |
---|
| 14 | |
---|
| 15 | ## |
---|
| 16 | ## Functions used by base.mako and base_panels.mako to display content. |
---|
| 17 | ## |
---|
| 18 | |
---|
| 19 | <%def name="title()"> |
---|
| 20 | Galaxy | ${iff( item.published, "Published ", iff( item.importable , "Accessible ", iff( item.users_shared_with, "Shared ", "Private " ) ) ) + get_class_display_name( item.__class__ )} | ${get_item_name( item ) | h} |
---|
| 21 | </%def> |
---|
| 22 | |
---|
| 23 | <%def name="init()"> |
---|
| 24 | <% |
---|
| 25 | self.has_left_panel=False |
---|
| 26 | self.has_right_panel=True |
---|
| 27 | self.message_box_visible=False |
---|
| 28 | self.active_view="shared" |
---|
| 29 | self.overlay_visible=False |
---|
| 30 | %> |
---|
| 31 | </%def> |
---|
| 32 | |
---|
| 33 | <%def name="javascripts()"> |
---|
| 34 | ${parent.javascripts()} |
---|
| 35 | ${h.js( "jquery", "jquery.tipsy", "galaxy.base", "json2", "class", "jquery.jstore", "jquery.autocomplete", "jquery.rating", "autocomplete_tagging", "trackster" )} |
---|
| 36 | |
---|
| 37 | <script type="text/javascript"> |
---|
| 38 | |
---|
| 39 | // Handle click on community tag. |
---|
| 40 | function community_tag_click(tag_name, tag_value) { |
---|
| 41 | <% controller_name = get_controller_name( item ) %> |
---|
| 42 | var href = '${h.url_for ( controller='/' + controller_name , action='list_published')}'; |
---|
| 43 | href = href + "?f-tags=" + tag_name; |
---|
| 44 | if (tag_value != undefined && tag_value != "") { |
---|
| 45 | href = href + ":" + tag_value; |
---|
| 46 | } |
---|
| 47 | self.location = href; |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | // Map item rating to number of stars to show. |
---|
| 51 | function map_rating_to_num_stars(rating) { |
---|
| 52 | if (rating <= 0) |
---|
| 53 | return 0; |
---|
| 54 | else if (rating > 0 && rating <= 1.5) |
---|
| 55 | return 1; |
---|
| 56 | else if (rating > 1.5 && rating <= 2.5) |
---|
| 57 | return 2; |
---|
| 58 | else if (rating > 2.5 && rating <= 3.5) |
---|
| 59 | return 3; |
---|
| 60 | else if (rating > 3.5 && rating <= 4.5) |
---|
| 61 | return 4; |
---|
| 62 | else if (rating > 4.5) |
---|
| 63 | return 5; |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | // Init. on document load. |
---|
| 67 | $(function() { |
---|
| 68 | // Set links to Galaxy screencasts to open in overlay. |
---|
| 69 | $(this).find("a[href^='http://screencast.g2.bx.psu.edu/']").each( function() { |
---|
| 70 | $(this).click( function() { |
---|
| 71 | var href = $(this).attr('href'); |
---|
| 72 | show_in_overlay( |
---|
| 73 | { |
---|
| 74 | url: href, |
---|
| 75 | width: 640, |
---|
| 76 | height: 480, |
---|
| 77 | scroll: 'no' |
---|
| 78 | } |
---|
| 79 | ); |
---|
| 80 | return false; |
---|
| 81 | }); |
---|
| 82 | }); |
---|
| 83 | |
---|
| 84 | // Init history boxes. |
---|
| 85 | init_history_items( $("div.historyItemWrapper"), false, "nochanges" ); |
---|
| 86 | |
---|
| 87 | // Init user item rating. |
---|
| 88 | $('.user_rating_star').rating({ |
---|
| 89 | callback: function(rating, link) { |
---|
| 90 | $.ajax({ |
---|
| 91 | type: "GET", |
---|
| 92 | url: "${h.url_for ( controller='/' + controller_name , action='rate_async' )}", |
---|
| 93 | data: { id : "${trans.security.encode_id( item.id )}", rating : rating }, |
---|
| 94 | dataType: 'json', |
---|
| 95 | error: function() { alert( "Rating submission failed" ); }, |
---|
| 96 | success: function( community_data ) { |
---|
| 97 | $('#rating_feedback').show(); |
---|
| 98 | $('#num_ratings').text(Math.round(community_data[1]*10)/10); |
---|
| 99 | $('#ave_rating').text(community_data[0]); |
---|
| 100 | $('.community_rating_star').rating('readOnly', false); |
---|
| 101 | $('.community_rating_star').rating('select', map_rating_to_num_stars(community_data[0])-1); |
---|
| 102 | $('.community_rating_star').rating('readOnly', true); |
---|
| 103 | } |
---|
| 104 | }); |
---|
| 105 | }, |
---|
| 106 | required: true // Hide cancel button. |
---|
| 107 | }); |
---|
| 108 | }); |
---|
| 109 | </script> |
---|
| 110 | </%def> |
---|
| 111 | |
---|
| 112 | <%def name="stylesheets()"> |
---|
| 113 | ${parent.stylesheets()} |
---|
| 114 | ${h.css( "autocomplete_tagging", "embed_item", "trackster", "jquery.rating" )} |
---|
| 115 | |
---|
| 116 | <style type="text/css"> |
---|
| 117 | .page-body { |
---|
| 118 | padding: 10px; |
---|
| 119 | ## float: left; |
---|
| 120 | ## width: 65%; |
---|
| 121 | } |
---|
| 122 | .page-meta { |
---|
| 123 | float: right; |
---|
| 124 | width: 27%; |
---|
| 125 | padding: 0.5em; |
---|
| 126 | margin: 0.25em; |
---|
| 127 | vertical-align: text-top; |
---|
| 128 | border: 2px solid #DDDDDD; |
---|
| 129 | border-top: 4px solid #DDDDDD; |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | ## Make sure that history items and workflow steps do not get too long. |
---|
| 133 | .historyItemContainer, .toolForm { |
---|
| 134 | max-width: 500px; |
---|
| 135 | } |
---|
| 136 | |
---|
| 137 | ## Space out tool forms in workflows. |
---|
| 138 | div.toolForm{ |
---|
| 139 | margin-top: 10px; |
---|
| 140 | margin-bottom: 10px; |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | ## Add border to history item container. |
---|
| 144 | .historyItemContainer { |
---|
| 145 | padding-right: 3px; |
---|
| 146 | border-right-style: solid; |
---|
| 147 | border-right-color: #66AA66; |
---|
| 148 | } |
---|
| 149 | </style> |
---|
| 150 | </%def> |
---|
| 151 | |
---|
| 152 | <%def name="render_item_links( item )"> |
---|
| 153 | ## Override. |
---|
| 154 | </%def> |
---|
| 155 | |
---|
| 156 | <%def name="render_item_header( item )"> |
---|
| 157 | <h3>Galaxy ${get_class_display_name( item.__class__ )} '${get_item_name( item )| h}'</h3> |
---|
| 158 | %if hasattr( item, "annotation") and item.annotation is not None: |
---|
| 159 | <div class="annotation">Annotation: ${item.annotation}</div> |
---|
| 160 | %endif |
---|
| 161 | <hr/> |
---|
| 162 | </%def> |
---|
| 163 | |
---|
| 164 | <%def name="render_item( item, item_data=None )"> |
---|
| 165 | ## Override. |
---|
| 166 | </%def> |
---|
| 167 | |
---|
| 168 | ## For base.mako |
---|
| 169 | <%def name="body()"> |
---|
| 170 | ${self.render_content()} |
---|
| 171 | </%def> |
---|
| 172 | |
---|
| 173 | ## For base_panels.mako |
---|
| 174 | <%def name="center_panel()"> |
---|
| 175 | ${self.render_content()} |
---|
| 176 | </%def> |
---|
| 177 | |
---|
| 178 | |
---|
| 179 | ## |
---|
| 180 | ## Render page content. Pages that inherit this page should override render_item_links() and render_item() |
---|
| 181 | ## |
---|
| 182 | <%def name="render_content()"> |
---|
| 183 | |
---|
| 184 | ## Get URL to other published items owned by user that owns this item. |
---|
| 185 | <% |
---|
| 186 | ##TODO: is there a better way to create this URL? Can't use 'f-username' as a key b/c it's not a valid identifier. |
---|
| 187 | controller_name = get_controller_name( item ) |
---|
| 188 | item_plural = get_item_plural( item ) |
---|
| 189 | href_to_all_items = h.url_for( controller='/' + controller_name, action='list_published') |
---|
| 190 | href_to_user_items = h.url_for( controller='/' + controller_name, action='list_published', xxx=item.user.username) |
---|
| 191 | href_to_user_items = href_to_user_items.replace( 'xxx', 'f-username') |
---|
| 192 | %> |
---|
| 193 | |
---|
| 194 | <div class="unified-panel-header" unselectable="on"> |
---|
| 195 | <div class="unified-panel-header-inner"> |
---|
| 196 | %if item.published: |
---|
| 197 | <a href="${href_to_all_items}">Published ${item_plural}</a> | |
---|
| 198 | <a href="${href_to_user_items}">${item.user.username}</a> |
---|
| 199 | %elif item.importable: |
---|
| 200 | Accessible ${get_class_display_name( item.__class__ )} |
---|
| 201 | %elif item.users_shared_with: |
---|
| 202 | Shared ${get_class_display_name( item.__class__ )} |
---|
| 203 | %else: |
---|
| 204 | Private ${get_class_display_name( item.__class__ )} |
---|
| 205 | %endif |
---|
| 206 | | ${get_item_name( item )} |
---|
| 207 | </div> |
---|
| 208 | </div> |
---|
| 209 | |
---|
| 210 | <div class="unified-panel-body"> |
---|
| 211 | <div style="overflow: auto; height: 100%;"> |
---|
| 212 | <div class="page-body"> |
---|
| 213 | <div style="float: right"> |
---|
| 214 | ${self.render_item_links( item )} |
---|
| 215 | </div> |
---|
| 216 | <div> |
---|
| 217 | ${self.render_item_header( item )} |
---|
| 218 | </div> |
---|
| 219 | |
---|
| 220 | ${self.render_item( item, item_data )} |
---|
| 221 | </div> |
---|
| 222 | |
---|
| 223 | |
---|
| 224 | </div> |
---|
| 225 | </div> |
---|
| 226 | </%def> |
---|
| 227 | |
---|
| 228 | <%def name="right_panel()"> |
---|
| 229 | |
---|
| 230 | <% |
---|
| 231 | ## FIXME: duplicated from above for now |
---|
| 232 | controller_name = get_controller_name( item ) |
---|
| 233 | item_plural = get_item_plural( item ) |
---|
| 234 | href_to_all_items = h.url_for( controller='/' + controller_name, action='list_published') |
---|
| 235 | href_to_user_items = h.url_for( controller='/' + controller_name, action='list_published', xxx=item.user.username) |
---|
| 236 | href_to_user_items = href_to_user_items.replace( 'xxx', 'f-username') |
---|
| 237 | %> |
---|
| 238 | |
---|
| 239 | <div class="unified-panel-header" unselectable="on"> |
---|
| 240 | <div class="unified-panel-header-inner"> |
---|
| 241 | About this ${get_class_display_name( item.__class__ )} |
---|
| 242 | </div> |
---|
| 243 | </div> |
---|
| 244 | |
---|
| 245 | <div class="unified-panel-body"> |
---|
| 246 | <div style="overflow: auto; height: 100%;"> |
---|
| 247 | <div style="padding: 10px;"> |
---|
| 248 | |
---|
| 249 | <div style="float: right;"><img src="http://www.gravatar.com/avatar/${h.md5(item.user.email)}?d=identicon"></div> |
---|
| 250 | |
---|
| 251 | <h4>Author</h4> |
---|
| 252 | |
---|
| 253 | <p>${item.user.username | h}</p> |
---|
| 254 | |
---|
| 255 | ## Related items. |
---|
| 256 | <h4>Related ${item_plural}</h4> |
---|
| 257 | <p> |
---|
| 258 | <a href="${href_to_all_items}">All published ${item_plural.lower()}</a><br> |
---|
| 259 | <a href="${href_to_user_items}">Published ${item_plural.lower()} by ${item.user.username | h}</a> |
---|
| 260 | |
---|
| 261 | ## Rating. |
---|
| 262 | <h4>Rating</h4> |
---|
| 263 | |
---|
| 264 | <% |
---|
| 265 | label = "ratings" |
---|
| 266 | if num_ratings == 1: |
---|
| 267 | label = "rating" |
---|
| 268 | %> |
---|
| 269 | <div style="padding-bottom: 0.75em; float: left"> |
---|
| 270 | Community<br> |
---|
| 271 | <span style="font-size:80%"> |
---|
| 272 | (<span id="num_ratings">${num_ratings}</span> ${label}, |
---|
| 273 | <span id="ave_rating">${"%.1f" % ave_item_rating}</span> average) |
---|
| 274 | <span> |
---|
| 275 | </div> |
---|
| 276 | <div style="float: right"> |
---|
| 277 | <input name="star1" type="radio" class="community_rating_star star" disabled="disabled" value="1" |
---|
| 278 | %if ave_item_rating > 0 and ave_item_rating <= 1.5: |
---|
| 279 | checked="checked" |
---|
| 280 | %endif |
---|
| 281 | |
---|
| 282 | /> |
---|
| 283 | <input name="star1" type="radio" class="community_rating_star star" disabled="disabled" value="2" |
---|
| 284 | %if ave_item_rating > 1.5 and ave_item_rating <= 2.5: |
---|
| 285 | checked="checked" |
---|
| 286 | %endif |
---|
| 287 | /> |
---|
| 288 | <input name="star1" type="radio" class="community_rating_star star" disabled="disabled" value="3" |
---|
| 289 | %if ave_item_rating > 2.5 and ave_item_rating <= 3.5: |
---|
| 290 | checked="checked" |
---|
| 291 | %endif |
---|
| 292 | /> |
---|
| 293 | <input name="star1" type="radio" class="community_rating_star star" disabled="disabled" value="4" |
---|
| 294 | %if ave_item_rating > 3.5 and ave_item_rating <= 4.5: |
---|
| 295 | checked="checked" |
---|
| 296 | %endif |
---|
| 297 | /> |
---|
| 298 | <input name="star1" type="radio" class="community_rating_star star" disabled="disabled" value="5" |
---|
| 299 | %if ave_item_rating > 4.5: |
---|
| 300 | checked="checked" |
---|
| 301 | %endif |
---|
| 302 | /> |
---|
| 303 | </div> |
---|
| 304 | <div style="clear: both;"></div> |
---|
| 305 | %if trans.get_user(): |
---|
| 306 | <div style="float: left"> |
---|
| 307 | Yours<br><span id="rating_feedback" style="font-size:80%; display: none">(thanks!)</span> |
---|
| 308 | </div> |
---|
| 309 | <div style="float: right"> |
---|
| 310 | <input name="star2" type="radio" class="user_rating_star" value="1" |
---|
| 311 | %if user_item_rating == 1: |
---|
| 312 | checked="checked" |
---|
| 313 | %endif |
---|
| 314 | /> |
---|
| 315 | <input name="star2" type="radio" class="user_rating_star" value="2" |
---|
| 316 | %if user_item_rating == 2: |
---|
| 317 | checked="checked" |
---|
| 318 | %endif |
---|
| 319 | /> |
---|
| 320 | <input name="star2" type="radio" class="user_rating_star" value="3" |
---|
| 321 | %if user_item_rating == 3: |
---|
| 322 | checked="checked" |
---|
| 323 | %endif |
---|
| 324 | /> |
---|
| 325 | <input name="star2" type="radio" class="user_rating_star" value="4" |
---|
| 326 | %if user_item_rating == 4: |
---|
| 327 | checked="checked" |
---|
| 328 | %endif |
---|
| 329 | /> |
---|
| 330 | <input name="star2" type="radio" class="user_rating_star" value="5" |
---|
| 331 | %if user_item_rating == 5: |
---|
| 332 | checked="checked" |
---|
| 333 | %endif |
---|
| 334 | /> |
---|
| 335 | </div> |
---|
| 336 | %endif |
---|
| 337 | <div style="clear: both;"></div> |
---|
| 338 | |
---|
| 339 | ## Tags. |
---|
| 340 | <h4>Tags</h4> |
---|
| 341 | <p> |
---|
| 342 | ## Community tags. |
---|
| 343 | <div> |
---|
| 344 | Community: |
---|
| 345 | ${render_community_tagging_element( tagged_item=item, tag_click_fn='community_tag_click', use_toggle_link=False )} |
---|
| 346 | %if len ( item.tags ) == 0: |
---|
| 347 | none |
---|
| 348 | %endif |
---|
| 349 | </div> |
---|
| 350 | ## Individual tags. |
---|
| 351 | %if trans.get_user(): |
---|
| 352 | <p> |
---|
| 353 | <div> |
---|
| 354 | Yours: |
---|
| 355 | ${render_individual_tagging_element( user=trans.get_user(), tagged_item=item, elt_context='view.mako', use_toggle_link=False, tag_click_fn='community_tag_click' )} |
---|
| 356 | </div> |
---|
| 357 | %endif |
---|
| 358 | </div> |
---|
| 359 | </div> |
---|
| 360 | </div> |
---|
| 361 | |
---|
| 362 | </%def> |
---|