Skip to content

Commit

Permalink
🐛 fix b3log#239
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed May 28, 2019
1 parent c8c7150 commit b7c3270
Show file tree
Hide file tree
Showing 38 changed files with 587 additions and 715 deletions.
2 changes: 1 addition & 1 deletion pipe.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Server": "http://localhost:5897",
"StaticServer": "",
"StaticResourceVersion": "1558663975821",
"StaticResourceVersion": "1559019700699",
"RuntimeMode": "dev",
"LogLevel": "debug",
"ShowSQL": false,
Expand Down
13 changes: 1 addition & 12 deletions theme/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file themes tool.
*
* @author <a href='http://vanessa.b3log.org'>Liyuan Li</a>
* @version 1.0.0.0, Nov 8, 2018
* @version 1.0.0.1, May 28, 2019
*/

const gulp = require('gulp')
Expand Down Expand Up @@ -36,7 +36,6 @@ function baseSassProcessWatch () {

function devJSProcessWatch () {
const watcher = gulp.watch([
'./x/*/js/article.js',
'./x/*/js/common.js'])

watcher.on('change', function (entry) {
Expand Down Expand Up @@ -100,16 +99,6 @@ function minThemeJS () {
pipe(buffer()).
pipe(uglify()).
pipe(gulp.dest('.'))
fs.statSync(`${jsPath}/article.js`)
browserify({entries: [`${jsPath}/article.js`]}).
transform('babelify', {presets: ['@babel/preset-env']}).
bundle().
on('error', function (err) { console.error(err) }).
pipe(source(`${jsPath}/article.js`)).
pipe(rename({suffix: '.min'})).
pipe(buffer()).
pipe(uglify()).
pipe(gulp.dest('.'))
} catch (e) {
}
})
Expand Down
2 changes: 1 addition & 1 deletion theme/sw.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions theme/x/9IPHP/define-footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@
id="script"
data-blogurl="{{.BlogURL}}"
data-isLogin="{{if eq .User.URole 0}}false{{else}}true{{end}}"
{{if .Article}}
src="{{.Conf.StaticServer}}/theme/x/{{.Setting.ThemeName}}/js/article.min.js?{{.Conf.StaticResourceVersion}}"
{{else}}
src="{{.Conf.StaticServer}}/theme/x/{{.Setting.ThemeName}}/js/common.min.js?{{.Conf.StaticResourceVersion}}"
{{end}}
></script>

{{end}}
115 changes: 0 additions & 115 deletions theme/x/9IPHP/js/article.js

This file was deleted.

1 change: 0 additions & 1 deletion theme/x/9IPHP/js/article.min.js

This file was deleted.

119 changes: 110 additions & 9 deletions theme/x/9IPHP/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @fileoverview util and every page should be used.
*
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @version 0.4.0.0, Mar 28, 2019
* @version 1.0.0.0, May 28, 2019
*/

import $ from 'jquery'
Expand All @@ -12,6 +12,8 @@ import {
PreviewImg,
initPjax
} from '../../../js/common'
import { InitComment, InitToc, ShowEditor } from '../../../js/article'
import QRious from 'qrious'

const Common = {
/**
Expand All @@ -20,12 +22,7 @@ const Common = {
init: () => {
initPjax(() => {
if ($('#pipeComments').length === 1) {
$.ajax({
method: 'GET',
url: `${$('#pipeLang').data('staticserver')}/theme/x/9IPHP/js/article.min.js?${$('#pipeLang').data('staticresourceversion')}`,
dataType: 'script',
cache: true,
})
Article.init()
}
$('.nav a, .mobile__nav a').removeClass('nav--current')
$('.nav a, .mobile__nav a').each(function (i) {
Expand Down Expand Up @@ -125,11 +122,115 @@ const Common = {
}
}


const Article = {
/**
* @description 页面初始化
*/
init: () => {
$('#articleCommentBtn').click(function () {
const $this = $(this)
ShowEditor($this.data('title'), $this.data('id'))
})

if ($('#toc').length === 1) {
InitToc('toc', 'articleContent')

// https://github.com/b3log/pipe/issues/114
$('#toc a').each(function () {
$(this).data('href', $(this).attr('href')).attr('href', 'javascript:void(0)')
}).click(function () {
const hash = $(this).data('href')
location.hash = hash
$(window).scrollTop($(hash)[0].offsetTop - 50)
})

$('.side__toc').width($('.side').width()).css('max-height', ($(window).height() - 170) + 'px')

$(window).scroll(function () {
if ($(window).scrollTop() > 75) {
$('.side__toc').addClass('side__toc--fix')
} else {
$('.side__toc').removeClass('side__toc--fix')
}
})

$('#hideToc').click(function () {
$(this).hide()
$('#showToc').show()
$('.side__toc').animate({
'margin-top': '300px'
}, 300, function () {
$(this).hide()
$('.side > .fn__none').show()
})
})

$('#showToc').click(function () {
$(this).hide()
$('#hideToc').show()
$('.side__toc').show().animate({
'margin-top': '0'
}, 100)
$('.side > .fn__none').hide()
})

if ($(window).width() < 768) {
$('#hideToc').click()
}
}

InitComment()

Article._share()
},
_share: () => {
const $this = $('.share__btns')
const $qrCode = $this.find('.share__code')
const shareURL = $qrCode.data('url')
const avatarURL = $qrCode.data('avatar')
const title = encodeURIComponent($qrCode.data('title') + ' - ' + $qrCode.data('blogtitle')),
url = encodeURIComponent(shareURL)

const urls = {}
urls.tencent = 'http://share.v.t.qq.com/index.php?c=share&a=index&title=' + title +
'&url=' + url + '&pic=' + avatarURL
urls.weibo = 'http://v.t.sina.com.cn/share/share.php?title=' +
title + '&url=' + url + '&pic=' + avatarURL
urls.google = 'https://plus.google.com/share?url=' + url
urls.twitter = 'https://twitter.com/intent/tweet?status=' + title + ' ' + url

$this.find('.share__btn').click(function () {
const key = $(this).data('type')

if (!key) {
return
}

if (key === 'wechat') {
if ($qrCode.css('background-image') === 'none') {
const qr = new QRious({
element: $qrCode[0],
value: shareURL,
size: 128
})
$qrCode.css('background-image', `url(${qr.toDataURL('image/jpeg')})`).hide()
}
$qrCode.slideToggle()
return false
}

window.open(urls[key], '_blank', 'top=100,left=200,width=648,height=618')
})
}
}

if (!window.increase) {
window.increase = Common.increase
window.addLevelToTag = Common.addLevelToTag
Icon()
Common.init()
if ($('#pipeComments').length === 1) {
Article.init()
}
}

export default Common
2 changes: 1 addition & 1 deletion theme/x/9IPHP/js/common.min.js

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions theme/x/Fara/define-footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@
id="script"
data-blogurl="{{.BlogURL}}"
data-isLogin="{{if eq .User.URole 0}}false{{else}}true{{end}}"
{{if .Article}}
src="{{.Conf.StaticServer}}/theme/x/{{.Setting.ThemeName}}/js/article.min.js?{{.Conf.StaticResourceVersion}}"
{{else}}
src="{{.Conf.StaticServer}}/theme/x/{{.Setting.ThemeName}}/js/common.min.js?{{.Conf.StaticResourceVersion}}"
{{end}}
></script>
{{end}}
33 changes: 0 additions & 33 deletions theme/x/Fara/js/article.js

This file was deleted.

1 change: 0 additions & 1 deletion theme/x/Fara/js/article.min.js

This file was deleted.

Loading

0 comments on commit b7c3270

Please sign in to comment.