From a7cb3b9658482ae7c2ae6e7eec3ddfe31a907aed Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Tue, 27 Mar 2018 19:39:49 +0200 Subject: [PATCH] Use view_base for assets --- .../nodes/custom/asset/file/view_embed.pug | 44 +---- .../nodes/custom/asset/image/view_embed.pug | 45 +---- .../nodes/custom/asset/video/view_embed.pug | 114 +++++------ .../nodes/custom/hdri/view_embed.pug | 187 +++++------------- 4 files changed, 102 insertions(+), 288 deletions(-) diff --git a/src/templates/nodes/custom/asset/file/view_embed.pug b/src/templates/nodes/custom/asset/file/view_embed.pug index 4483d710..3e1b5b87 100644 --- a/src/templates/nodes/custom/asset/file/view_embed.pug +++ b/src/templates/nodes/custom/asset/file/view_embed.pug @@ -1,43 +1 @@ -| {% block body %} - -#node-container - #node-overlay - - | {% if node.picture %} - section#node-preview.node-preview.file - img.node-preview-thumbnail#node-preview-thumbnail( - src="{{ node.picture.thumbnail('l', api=api) }}") - | {% endif %} - - section.node-details-container - include ../../_node_details - - #comments-embed - .comments-list-loading - i.pi-spin - -include ../../_scripts - -| {% endblock %} - -| {% block footer_scripts %} -script. - // Generate GA pageview - ga('send', 'pageview', location.pathname); - - var content_type = $("li.node-details-meta-list-item.type").text(); - var type_trimmed = content_type.substring(content_type.indexOf("/") + 1); - - if (type_trimmed == 'x-blender' || type_trimmed == 'blend'){ - type_trimmed = ''; - }; - - $("li.node-details-meta-list-item.type").html(type_trimmed); - - $('.sorry').click(function() { - $.get('/403', function(data) { - $('#node-overlay').html(data).addClass('active'); - }) - }); - -| {% endblock %} +| {% extends "nodes/view_base.html" %} diff --git a/src/templates/nodes/custom/asset/image/view_embed.pug b/src/templates/nodes/custom/asset/image/view_embed.pug index 5eea445d..3e1b5b87 100644 --- a/src/templates/nodes/custom/asset/image/view_embed.pug +++ b/src/templates/nodes/custom/asset/image/view_embed.pug @@ -1,44 +1 @@ -| {% block body %} - -#node-container - #node-overlay - - | {% if node.picture %} - | {% if current_user.has_cap('subscriber') %} - section#node-preview.node-preview.image.js-node-preview-image - img.node-preview-thumbnail#node-preview-thumbnail( - src="{{ node.picture.thumbnail('l', api=api) }}") - | {% else %} - section#node-preview.node-preview.image.node-preview-blur - img.node-preview-thumbnail#node-preview-thumbnail( - src="{{ node.picture.thumbnail('t', api=api) }}") - | {% endif %} - | {% endif %} - - section.node-details-container - include ../../_node_details - - #comments-embed - .comments-list-loading - i.pi-spin - -include ../../_scripts - -| {% endblock %} - -| {% block footer_scripts %} -script. - // Generate GA pageview - ga('send', 'pageview', location.pathname); - - var content_type = $("li.node-details-meta-list-item.type").text(); - $("li.node-details-meta-list-item.type").text(content_type.substring(content_type.indexOf("/") + 1)); - - $('.sorry').click(function() { - $.get('/403', function(data) { - $('#node-overlay').html(data).addClass('active'); - }) - }); - -| {% endblock %} - +| {% extends "nodes/view_base.html" %} diff --git a/src/templates/nodes/custom/asset/video/view_embed.pug b/src/templates/nodes/custom/asset/video/view_embed.pug index ae1faf90..72cd5a73 100644 --- a/src/templates/nodes/custom/asset/video/view_embed.pug +++ b/src/templates/nodes/custom/asset/video/view_embed.pug @@ -1,60 +1,53 @@ -| {% block body %} +| {% extends "nodes/view_base.html" %} -#node-container - #node-overlay +| {% block node_preview %} +| {% if node.video_sources %} +section.node-preview.video + video#videoplayer.video-js( + controls, + data-setup="{}", + preload="auto", + poster="{% if node.picture %}{{ node.picture.thumbnail('l', api=api) }}{% endif %}") + | {% for source in node.video_sources %} + source( + src="{{ source.src }}", + type="{{ source.type }}") + | {% endfor %} + p.vjs-no-js. + To view this video please enable JavaScript, and consider upgrading to a web browser that + supports HTML5 video +| {% else %} +| {% include 'nodes/custom/_node_preview_forbidden.html' %} +| {% endif %} +| {% endblock node_preview %} - section.node-preview.video - | {% if node.video_sources %} - video#videoplayer.video-js( - controls, - data-setup="{}", - preload="auto", - poster="{% if node.picture %}{{ node.picture.thumbnail('l', api=api) }}{% endif %}") - | {% for source in node.video_sources %} - source( - src="{{ source.src }}", - type="{{ source.type }}") - | {% endfor %} - p.vjs-no-js. - To view this video please enable JavaScript, and consider upgrading to a web browser that - supports HTML5 video - | {% else %} - .video-dummy.sorry( - style="{% if node.picture %}background-image: url({{ node.picture.thumbnail('l', api=api) }});{% endif %}") - .video-dummy-content - .video-dummy-content-text - span Available to Blender Cloud subscribers - span - small Support Blender and get awesome stuff! - hr - | {% if current_user.has_cap('can-renew-subscription') %} - a.subscribe(href="/renew") You have a subscription, it just needs to be renewed. Renew your subscription now! - | {% else %} - a.subscribe(href="{{ url_for('cloud.join') }}") Subscribe to Blender Cloud. - | {% endif %} - | {% if current_user.is_anonymous %} - a(href="{{ url_for('users.login') }}") Already a subscriber? Log in - | {% endif %} - | {% endif %} +| {% block node_download %} +| {% if node.file_variations %} +button.btn.btn-default.dropdown-toggle( + type="button", + data-toggle="dropdown", + aria-haspopup="true", + aria-expanded="false") + i.pi-download + | Download + i.pi-angle-down.icon-dropdown-menu + +ul.dropdown-menu + | {% for variation in node.file_variations %} + li + a(href="{{ variation.link }}", + title="Download this format", + download) + span.length {{ variation.length | filesizeformat }} + + span.format {{ variation.format }} + span.size {{ variation.size }} + | {% endfor %} +| {% endif %} +| {% endblock node_download %} - section.node-details-container.video - - .node-details-header - .node-title#node-title - | {{node.name}} - - | {% if node.description %} - .node-details-description#node-description - | {{ node.description | markdown }} - | {% endif %} - - include ../../_node_details - - #comments-embed - .comments-list-loading - i.pi-spin - +| {% block node_scripts %} script(type="text/javascript"). {% if node.video_sources %} @@ -114,17 +107,6 @@ script(type="text/javascript"). } }; - {% endif %} + {% endif %} // if node.video_sources - $(function(){ - // Generate GA pageview - ga('send', 'pageview', location.pathname); - - var content_type = $("li.node-details-meta-list-item.type").text(); - $("li.node-details-meta-list-item.type").text(content_type.substring(content_type.indexOf("/") + 1)); - - }); - -include ../../_scripts - -| {% endblock %} +| {% endblock node_scripts %} diff --git a/src/templates/nodes/custom/hdri/view_embed.pug b/src/templates/nodes/custom/hdri/view_embed.pug index 9a6f02ff..2fc00288 100644 --- a/src/templates/nodes/custom/hdri/view_embed.pug +++ b/src/templates/nodes/custom/hdri/view_embed.pug @@ -1,144 +1,62 @@ -| {% block body %} +| {% extends "nodes/view_base.html" %} -#node-container.texture - #node-overlay - section.node-preview - | {% if node.picture %} - iframe( - id='vrview_window' - width='100%', - height='450px', - scrolling='no', - frameborder='0', - allowfullscreen='', - src="{{url_for('main.vrview', preview=node.picture.thumbnail('l', api=api), image=node.picture.thumbnail('h', api=api), default_yaw=(node.properties.default_yaw or 0))}}") - | {% endif %} +| {% block node_preview %} +| {% if node.picture %} +iframe( +id='vrview_window' +width='100%', +height='450px', +scrolling='no', +frameborder='0', +allowfullscreen='', +src="{{url_for('main.vrview', preview=node.picture.thumbnail('l', api=api), image=node.picture.thumbnail('h', api=api), default_yaw=(node.properties.default_yaw or 0))}}") +| {% else %} +section.node-preview + h3 Missing Preview +| {% endif %} +| {% endblock node_preview %} - section.node-details-container +| {% block node_details_meta_extra %} +| {% if write_access %} +li.node-details-meta-list-item + a.btn#copy_yaw( + href='javascript:void(0);' + title='Copies current yaw of panorama to the clipboard, so you can set it as default yaw.' + ) Copy yaw +| {% endif %} +| {% endblock node_details_meta_extra %} - .node-details-header - .node-title#node-title - | {{node.name}} +| {% block node_download %} +| {% if node.properties.files %} +button.btn.btn-default.dropdown-toggle( + title="Download HDRI", + type="button", + data-toggle="dropdown", + aria-haspopup="true", + aria-expanded="false") + i.pi-download + | Download + i.pi-angle-down.icon-dropdown-menu - .node-details-meta.header - ul.node-details-meta-list - | {% if node.permissions.world %} - li.node-details-meta-list-item.access.public( - data-toggle="tooltip", - data-placement="bottom", - title="Anybody can download. Share it!") - i.pi-lock-open - span Public - | {% endif %} +ul.dropdown-menu + | {% for var in node.properties.files %} + li + a(href="{{ var.file.link }}", + title="Download this HDRi format", + download) + span.length {{ var.file.length | filesizeformat }} + span.format {{ var.file.format | hide_none }} + span.size {{ var.resolution }} - | {% if node.properties.license_type %} - | {% if node.properties.license_notes %} - li.node-details-meta-list-item.video.license( - id="asset-license", - data-toggle="popover", - data-placement="left", - data-trigger="hover", - data-content="{{ node.properties.license_notes }}", - title="{{ node.properties.license_type }}") + | {% endfor %} +| {% endif %} +| {% endblock node_download %} - i(class="pi-license-{{ node.properties.license_type }}") - | {% else %} - li.node-details-meta-list-item.video.license( - id="asset-license", - data-toggle="tooltip", - data-placement="bottom", - title="{{ node.properties.license_type }}") - i(class="pi-license-{{ node.properties.license_type }}") - | {% endif %} - | {% endif %} +| {% block node_comments %}{% endblock %} - | {% if write_access %} - li.node-details-meta-list-item - a.btn#copy_yaw( - href='javascript:void(0);' - title='Copies current yaw of panorama to the clipboard, so you can set it as default yaw.' - ) Copy yaw - | {% endif %} - - | {% if node.properties.files %} - li.btn-group.node-details-meta-list-item.video.download( - title="Download HDRI") - button.btn.btn-default.dropdown-toggle( - type="button", - data-toggle="dropdown", - aria-haspopup="true", - aria-expanded="false") - i.pi-download - i.pi-angle-down.icon-dropdown-menu - - ul.dropdown-menu - | {% for var in node.properties.files %} - li - a(href="{{ var.file.link }}", - title="Download this HDRi format", - download) - span.length {{ var.file.length | filesizeformat }} - - span.format {{ var.file.format | hide_none }} - span.size {{ var.resolution }} - - | {% endfor %} - | {% else %} - li.btn-group.node-details-meta-list-item.video.download.disabled( - title="Download HDRi") - button.btn.btn-default.sorry(type="button") - i.pi-lock - i.pi-download - | {% endif %} - - | {% if node.description %} - .node-details-description#node-description - | {{ node.description | markdown }} - | {% endif %} - - | {% if node.properties.license_notes %} - .node-details-meta.license - | {{ node.properties.license_notes }} - | {% endif %} - - .node-details-meta.footer - ul.node-details-meta-list - li.node-details-meta-list-item.status - | {{ node.properties.status | undertitle }} - - li.node-details-meta-list-item.author - | {{ node.user.full_name }} - - li.node-details-meta-list-item.date(title="Created {{ node._created }}") - | {{ node._created | pretty_date }} - | {% if (node._created | pretty_date) != (node._updated | pretty_date) %} - span(title="Updated {{ node._updated }}") (updated {{ node._updated | pretty_date }}) - | {% endif %} - - -include ../_scripts - -| {% endblock %} - -| {% block footer_scripts %} +| {% block node_scripts %} script(src="{{ url_for('static_pillar', filename='assets/js/vendor/clipboard.min.js')}}") - script. - $('#asset-license').popover(); - // Generate GA pageview - ga('send', 'pageview', location.pathname); - - - $('.sorry').click(function() { - $.get('/403', function(data) { - $('#node-overlay').html(data).show().addClass('active'); - }) - }); - - $('#node-overlay').click(function(){ - $(this).removeClass('active').hide().html(); - }); - $().ready(function () { new Clipboard('#copy_yaw', { text: function(trigger) { @@ -150,8 +68,7 @@ script. } }) .on('success', function(e) { - $(e.trigger).flashOnce(); + $(e.trigger).flashOnce(); }); }); - -| {% endblock %} +| {% endblock node_scripts %}