Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New tag video & warn when use exturl or extlink #652

Merged
merged 3 commits into from
Mar 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# ---------------------------------------------------------------
# Theme Core Configuration Settings
# See: https://theme-next.org/docs/theme-settings/
# ---------------------------------------------------------------

# If false, merge configs from `_data/next.yml` into default configuration (rewrite).
Expand Down Expand Up @@ -175,6 +176,7 @@ scheme: Muse

# ---------------------------------------------------------------
# Sidebar Settings
# See: https://theme-next.org/docs/theme-settings/sidebar/
# ---------------------------------------------------------------

# Posts / Categories / Tags in sidebar.
Expand Down Expand Up @@ -265,6 +267,7 @@ sidebar:

# ---------------------------------------------------------------
# Post Settings
# See: https://theme-next.org/docs/theme-settings/posts/
# ---------------------------------------------------------------

# Automatically scroll page to section which is under <!-- more --> mark.
Expand Down Expand Up @@ -383,11 +386,7 @@ highlight_theme: normal
# Enable "cheers" for archive page.
cheers: true


# ---------------------------------------------------------------
# Tagcloud Settings
# ---------------------------------------------------------------

# TagCloud settings for tags page.
tagcloud:
# If true, font size and color can be customized
enable: false
Expand Down Expand Up @@ -456,6 +455,7 @@ font:

# ---------------------------------------------------------------
# Third Party Services Settings
# See: https://theme-next.org/docs/third-party-services/
# ---------------------------------------------------------------

# Math Equations Render Support
Expand Down Expand Up @@ -824,9 +824,9 @@ reading_progress:

# ---------------------------------------------------------------
# Tags Settings
# See: https://theme-next.org/docs/tag-plugins/
# ---------------------------------------------------------------

# See: https://theme-next.org/docs/tag-plugins/
# Note tag (bs-callout)
note:
# Note tag style values:
Expand All @@ -841,9 +841,6 @@ note:
# Offset also applied to label tag variables. This option can work with disabled note tag.
light_bg_offset: 0

# Label tag
label: true

# Tabs tag
tabs:
enable: true
Expand Down Expand Up @@ -932,9 +929,10 @@ canvas_ribbon:

# Script Vendors.
# Set a CDN address for the vendor you want to customize.
# See: https://theme-next.org/docs/advanced-settings/
# For example
# jquery: https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js
# Be aware that you should use the same version as internal ones to avoid potential problems.
# Be aware that you would better use the same version as internal ones to avoid potential problems.
# Please use the https protocol of CDN files when you enable https on your site.
vendors:
# Internal path prefix. Please do not edit it.
Expand Down
2 changes: 1 addition & 1 deletion layout/_layout.swig
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
{% block script_extra %}{% endblock %}

{% include '_scripts/next-boot.swig' %}
{% include '_third-party/quicklink/index.swig' %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's fine

{% include '_third-party/quicklink.swig' %}
{% include '_third-party/comments/index.swig' %}
{% include '_third-party/search/index.swig' %}
{% include '_third-party/analytics/lean-analytics.swig' %}
Expand Down
156 changes: 78 additions & 78 deletions layout/_third-party/copy-code.swig
Original file line number Diff line number Diff line change
@@ -1,83 +1,83 @@
{% if theme.codeblock.copy_button.enable %}
<style>
.copy-btn {
display: inline-block;
padding: 6px 12px;
font-size: 13px;
font-weight: 700;
line-height: 20px;
color: #333;
white-space: nowrap;
vertical-align: middle;
cursor: pointer;
{% if theme.codeblock.copy_button.style === 'flat' %}
background-color: #fff;
border: none;
{% else %}
background-color: #eee;
background-image: linear-gradient(#fcfcfc, #eee);
border: 1px solid #d5d5d5;
border-radius: 3px;
{% endif %}
user-select: none;
outline: 0;
}
<style>
.copy-btn {
display: inline-block;
padding: 6px 12px;
font-size: 13px;
font-weight: 700;
line-height: 20px;
color: #333;
white-space: nowrap;
vertical-align: middle;
cursor: pointer;
{% if theme.codeblock.copy_button.style === 'flat' %}
background-color: #fff;
border: none;
{% else %}
background-color: #eee;
background-image: linear-gradient(#fcfcfc, #eee);
border: 1px solid #d5d5d5;
border-radius: 3px;
{% endif %}
user-select: none;
outline: 0;
}

.highlight-wrap .copy-btn {
transition: opacity .3s ease-in-out;
opacity: 0;
padding: 2px 6px;
position: absolute;
{% if theme.codeblock.copy_button.style === 'flat' %}
right: 0px;
height: 42px;
{% else %}
right: 4px;
top: 8px;
{% endif %}
}
.highlight-wrap .copy-btn {
transition: opacity .3s ease-in-out;
opacity: 0;
padding: 2px 6px;
position: absolute;
{% if theme.codeblock.copy_button.style === 'flat' %}
right: 0px;
height: 42px;
{% else %}
right: 4px;
top: 8px;
{% endif %}
}

.highlight-wrap:hover .copy-btn,
.highlight-wrap .copy-btn:focus {
opacity: 1;
}
.highlight-wrap:hover .copy-btn,
.highlight-wrap .copy-btn:focus {
opacity: 1;
}

.highlight-wrap {
position: relative;
}
</style>
<script>
$('.highlight').each(function(i, e) {
var $wrap = $('<div>').addClass('highlight-wrap');
$(e).after($wrap);
$wrap.append($('<button>').addClass('copy-btn').append('{{__("post.copy_button")}}').on('click', function(e) {
var code = $(this).parent().find('.code').find('.line').map(function(i, e) {
return $(e).text();
}).toArray().join('\n');
var ta = document.createElement('textarea');
var yPosition = window.pageYOffset || document.documentElement.scrollTop;
ta.style.top = yPosition + 'px'; // Prevent page scroll
ta.style.position = 'absolute';
ta.style.opacity = '0';
ta.readOnly = true;
ta.value = code;
document.body.appendChild(ta);
ta.select();
ta.setSelectionRange(0, code.length);
ta.readOnly = false;
var result = document.execCommand('copy');
{% if theme.codeblock.copy_button.show_result %}
if (result) $(this).text('{{__("post.copy_success")}}');
else $(this).text('{{__("post.copy_failure")}}');
{% endif %}
ta.blur(); // For iOS
$(this).blur();
})).on('mouseleave', function(e) {
var $b = $(this).find('.copy-btn');
setTimeout(function() {
$b.text('{{__("post.copy_button")}}');
}, 300);
}).append(e);
})
</script>
.highlight-wrap {
position: relative;
}
</style>
<script>
$('.highlight').each(function(i, e) {
var $wrap = $('<div>').addClass('highlight-wrap');
$(e).after($wrap);
$wrap.append($('<button>').addClass('copy-btn').append('{{__("post.copy_button")}}').on('click', function(e) {
var code = $(this).parent().find('.code').find('.line').map(function(i, e) {
return $(e).text();
}).toArray().join('\n');
var ta = document.createElement('textarea');
var yPosition = window.pageYOffset || document.documentElement.scrollTop;
ta.style.top = yPosition + 'px'; // Prevent page scroll
ta.style.position = 'absolute';
ta.style.opacity = '0';
ta.readOnly = true;
ta.value = code;
document.body.appendChild(ta);
ta.select();
ta.setSelectionRange(0, code.length);
ta.readOnly = false;
var result = document.execCommand('copy');
{% if theme.codeblock.copy_button.show_result %}
if (result) $(this).text('{{__("post.copy_success")}}');
else $(this).text('{{__("post.copy_failure")}}');
{% endif %}
ta.blur(); // For iOS
$(this).blur();
})).on('mouseleave', function(e) {
var $b = $(this).find('.copy-btn');
setTimeout(function() {
$b.text('{{__("post.copy_button")}}');
}, 300);
}).append(e);
})
</script>
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@
<script>
{% if theme.quicklink.delay %}
window.addEventListener('load', () => {
{% include 'quicklink.swig' %}
{% endif %}
quicklink({
timeout: {{ theme.quicklink.timeout }},
priority: {{ theme.quicklink.priority }},
ignores: [uri => uri.includes('#'),uri => uri == '{{ url.replace('index.html', '') }}',{{ theme.quicklink.ignores }}]
});
{% if theme.quicklink.delay %}
});
{% elif not theme.quicklink.delay %}
{% include 'quicklink.swig' %}
{% endif %}
</script>
{% endif %}
{% endif %}
{% endif %}
5 changes: 0 additions & 5 deletions layout/_third-party/quicklink/quicklink.swig

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/tags/exturl.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function extURL(args) {
'data-url': url,
title : title
};

hexo.log.warn('WARNING: `exturl` and `extlink` tag will not longer be supported.');
return htmlTag('span', attrs, text.join(' ') + '<i class="fa fa-external-link"></i>');
}

Expand Down
10 changes: 1 addition & 9 deletions scripts/tags/group-pictures.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
/**
* group-pictures.js
*
* Usage:
*
* {% grouppicture [group]-[layout] %}{% endgrouppicture %}
* {% gp [group]-[layout] %}{% endgp %}
*
* [group] : Total number of pictures to add in the group.
* [layout] : Default picture under the group to show.
* group-pictures.js | https://theme-next.org/docs/tag-plugins/group-pictures/
*/

/* global hexo */
Expand Down
13 changes: 13 additions & 0 deletions scripts/tags/video.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* video.js | https://theme-next.org/docs/tag-plugins/video/
*/

/* global hexo */

'use strict';

function postVideo(args) {
return `<video src="${args}" preload="metadata" controls playsinline poster="">Sorry, your browser does not support the video tag.</video>`;
}

hexo.extend.tag.register('video', postVideo, {ends: false});
2 changes: 1 addition & 1 deletion source/css/_common/components/header/header.styl
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
@import "site-meta";
@import "site-nav";
@import "menu";
@import "github-banner" if hexo-config('github_banner');
@import "github-banner" if hexo-config('github_banner.enable');
1 change: 0 additions & 1 deletion source/css/_common/components/highlight/highlight.styl
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,4 @@ pre {
.javascript .function {
color: $highlight-purple;
}

}
2 changes: 1 addition & 1 deletion source/css/_common/components/tags/tags.styl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import "full-image";
@import "blockquote-center";
@import "group-pictures";
@import "label";
@import "note" if hexo-config('note.style') == 'simple' || hexo-config('note.style') == 'flat';
@import "note-modern" if hexo-config('note.style') == 'modern';
@import "label" if hexo-config('label');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems need to remove label option from config.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's related to theme-next/theme-next.org#18, and won't cause any side effect. The label option only appears once. Considering that we didn't add options for most tags (e.g. button, center-quote, full-image etc.), it would be better to remove it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, looks fine now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ivan-nginx Able to merge now?

@import "tabs" if hexo-config('tabs.enable');
9 changes: 6 additions & 3 deletions source/css/_common/scaffolding/base.styl
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ a, span.exturl {
cursor: pointer;
}

blockquote {
margin: 0;
padding: 0;
video {
max-width: 100%;
display: block;
margin-left: auto;
margin-right: auto;
}

img {
Expand All @@ -91,6 +93,7 @@ hr {
}

blockquote {
margin: 0;
padding: 0 15px;
color: $grey-dim;
border-left: 4px solid $gray-lighter;
Expand Down
3 changes: 1 addition & 2 deletions source/css/_schemes/Pisces/_sidebar.styl
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,8 @@

.links-of-blogroll {
text-align: center;
margin-top: 20px;
margin-top: 5px;
padding: 3px 0 0;
border-top: 1px dotted $grey-light;
}
.links-of-blogroll-title { margin-top: 0; }
.links-of-blogroll-item { padding: 0; }
Expand Down