diff --git a/.build.php b/.build.php index a31910f..df1f228 100644 --- a/.build.php +++ b/.build.php @@ -60,16 +60,3 @@ function fetchFiles(string $subdir) return $files; } - -/** - * GitHub Action - * 自动更新 Hash 文件 - */ - -$files = fetchFiles('./'); -$hash = []; - -foreach ($files as $file) - $hash[] = hash('sha256', file_get_contents($file)) . ' ' . $file; - -file_put_contents(__DIR__ . "/hash.txt", implode("\n", $hash)); diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fece176..f6b436f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Auto Build +name: Build-Ci on: push: @@ -9,14 +9,13 @@ jobs: run: runs-on: ubuntu-latest steps: - - name: Check + - name: Checkout uses: actions/checkout@v1 - - name: Build - run: php .build.php - - name: Commit - uses: stefanzweifel/git-auto-commit-action@v2.5.0 + - name: Build MDr-Petals + run: | + php .build.php + - name: Upload Artifact + uses: actions/upload-artifact@v2 with: - commit_message: Auto Build - branch: petals - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + name: sci-hub-p2p-frontend-${{ matrix.node-version }} + path: ./ \ No newline at end of file diff --git a/.github/workflows/hash.yml b/.github/workflows/hash.yml deleted file mode 100644 index d3a24ae..0000000 --- a/.github/workflows/hash.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Auto Hash - -on: - push: - branches: - - master - -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: Running update.php hash - run: php update.php hash - - name: Commit hash.txt - uses: stefanzweifel/git-auto-commit-action@v2.5.0 - with: - commit_message: Update hash.txt - branch: master - file_pattern: hash.txt - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/comments.php b/comments.php index b9e73b2..68dce95 100644 --- a/comments.php +++ b/comments.php @@ -1,14 +1,15 @@ permalink) : - if (!$this->user->hasLogin()) : - $showLimited = true; - else : - if (!$this->user->pass('editor', true)) : +if (count(FindContents('page-whisper.php')) > 0) + if (FindContents('page-whisper.php')[0]["permalink"] == $this->permalink) : + if (!$this->user->hasLogin()) : $showLimited = true; + else : + if (!$this->user->pass('editor', true)) : + $showLimited = true; + endif; endif; endif; -endif; if ($showLimited) : echo ''; endif; diff --git a/core/config.ini.php b/core/config.ini.php index 50e88a9..5982a69 100644 --- a/core/config.ini.php +++ b/core/config.ini.php @@ -11,4 +11,7 @@ 'mdrCopytext' => null, // 自定义底部版权所属,默认为站点名称。 'mdrMDUICDNlink' => null, // MDUI 静态资源自建地址,只在上面的选项选择自建时需要。 'mdrcjCDNlink' => null, // 其他公共静态资源自建地址,只在上面的选项选择自建时需要。 -]); \ No newline at end of file + 'mdrSponsor' => [ + //['爱发电', 'deep-purple-accent', 'https://afdian.net'], + ], //参照上述格式 +]); diff --git a/core/css/style-petals.css b/core/css/style-petals.css index eafa83c..e27eb03 100644 --- a/core/css/style-petals.css +++ b/core/css/style-petals.css @@ -29,7 +29,7 @@ } #main { - margin-top: -20px; + margin-top: -12px; } #main>* { @@ -174,6 +174,58 @@ footer { padding-bottom: 2px; } +/** License **/ + +.license { + padding: 24px; + overflow: hidden; + position: relative; + background-color: #f5f5f5; +} + +body.mdui-theme-layout-dark .license { + background-color: #383838; +} + +.license, .license p { + margin: 0; +} + +.license svg { + position: absolute; + width: 128px; + height: 128px; + top: -35px; + right: -22px; + opacity: .25; +} + +body.mdui-theme-layout-dark .license svg { + filter: invert(1); +} + +/** Sponsor **/ + +.mdr-sponsor { + text-align: center; +} + +.mdr-sponsor .mdui-btn { + border-radius: 5px; +} + +/** Tags **/ + +.tags { + margin-bottom: 15px; + padding: 0 10px; + text-align: center +} + +.tags .mdui-chip { + margin: 0 2px; +} + /* Page Navigator */ .page-navigator { @@ -223,7 +275,7 @@ footer { padding-top: 100%; } -.link-card > * { +.link-card>* { position: absolute; bottom: 0; } \ No newline at end of file diff --git a/core/css/style.css b/core/css/style.css index 7226bd7..55b6eee 100644 --- a/core/css/style.css +++ b/core/css/style.css @@ -274,12 +274,6 @@ html.pray { top: 8px } -.tags { - margin: 15px 0; - padding: 0 10px; - text-align: center -} - #post .mdui-card-header { padding-top: 8px; padding-bottom: 8px; diff --git a/core/functions.php b/core/functions.php index b02e4f3..db135bc 100644 --- a/core/functions.php +++ b/core/functions.php @@ -4,12 +4,22 @@ require_once __DIR__ . '/lib/Main.php'; require_once __DIR__ . '/lib/ShortCode.php'; +$options = Helper::options(); + define('MDR_DEBUG', file_exists(__DIR__ . '/.debugger')); -if (!defined('MDR_OUTREQUIER') && Helper::options()->GravatarUrl) - define('__TYPECHO_GRAVATAR_PREFIX__', Helper::options()->GravatarUrl); +if (!defined('MDR_OUTREQUIER') && $options->GravatarUrl) + define('__TYPECHO_GRAVATAR_PREFIX__', $options->GravatarUrl); define('MDR_PJAX', isset($_GET['_pjax']) ? true : false); define('MDR_COLOR', json_decode(file_get_contents(__DIR__ . '/lib/Color.json'), true)); define('MDR_VERSION', Typecho_Plugin::parseInfo(__DIR__ . '/../index.php')['version']); +define('MDR_LANG', __DIR__ . '/../lang'); + +/* if ($options->lang && $options->lang != 'zh_CN') + if (file_exists(MDR_LANG . '/' . $options->lang . '.mo')) { + Typecho_I18n::translate(''); + Typecho_I18n::addLang(MDR_LANG . '/' . $options->lang . '.mo'); + } +*/ function cjUrl($path) { @@ -67,7 +77,7 @@ function Postviews($archive) Typecho_Cookie::set('contents_views', $cookie); } } - echo $exist == 0 ? '暂无阅读' : $exist . ' 次阅读'; + echo $exist == 0 ? _t('暂无阅读') : _t('%d 次阅读', $exist); } /** @@ -129,7 +139,7 @@ function Contents_Post_Initial($limit = 10, $order = 'created') echo '
  • PjaxOption ? '' : ' href="' . $post['permalink'] . '"') . '>' . htmlspecialchars($post['title']) . '
  • ' . "\n"; } } else { - echo '
  • 暂无文章
  • ' . "\n"; + echo '
  • ' . _t('暂时没有文章') . '
  • ' . "\n"; } } @@ -158,7 +168,7 @@ function Contents_Comments_Initial($limit = 10, $ignoreAuthor = 0) echo '
  • PjaxOption ? '' : ' href="' . permaLink($comment) . '"') . ' title="来自: ' . $parent['title'] . '">' . $comment['author'] . ': ' . ($parent['hidden'] && $options->PjaxOption ? '内容被隐藏' : Typecho_Common::subStr(strip_tags($comment['text']), 0, 35, '...')) . '
  • ' . "\n"; } } else { - echo '
  • 暂无回复
  • ' . "\n"; + echo '
  • ' . _t('暂时没有回复') . '
  • ' . "\n"; } } @@ -248,14 +258,14 @@ function Whisper() ); } else { return array( - '

    暂无内容

    ', + '

    ' . _t('暂时没有内容') . '

    ', $page['permalink'], $page['title'] ); } } else { return array( - '

    暂无内容

    ' + '

    ' . _t('暂时没有内容') . '

    ' ); } } @@ -398,6 +408,7 @@ function MyLinks($links) /* function 许可协议 */ function license($license) { + $svg = ""; $licenselist = array( 'BY' => '署名 4.0 国际 (CC BY 4.0)', 'BY-SA' => '署名-相同方式共享 4.0 国际 (CC BY-SA 4.0)', @@ -406,11 +417,24 @@ function license($license) 'BY-NC-SA' => '署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)', 'BY-NC-ND' => '署名-非商业性使用-禁止演绎 4.0 国际 (CC BY-NC-ND 4.0)' ); - if (isset($license) && $license != 'NONE') { - echo ''; - } else { - echo ''; - } + $text = (isset($license) && $license != 'NONE') ? + '本篇文章采用 ' . $licenselist[$license] . ' 许可协议进行许可。' : + "本篇文章未指定许可协议。"; + + echo "

    $text

    转载或引用本文时请遵守许可协议,注明出处。

    $svg
    "; +} + +/* function Sponsor */ +function mdrSponsor($class) +{ + if (!isset($class->mdrSponsor)) return; + if (!is_array($class->mdrSponsor)) return; + if (count($class->mdrSponsor) < 1) return; + $buttons = ''; + foreach ($class->mdrSponsor as list($name, $color, $link)) + $buttons .= "
    $name
    "; + + echo '

    喜欢这篇文章?为什么不考虑打赏一下作者呢?

    ' . $buttons . '
    '; } /* function 是否为状态 */ @@ -459,15 +483,17 @@ function staticUrl($file = '') $lists = explode("\r\n", Helper::options()->mdrMDUICDNlink); $mdrMDUIlinks = [ 'mdui.min.css' => [ - 'cssnet' => 'cdnjs.loli.net/ajax/libs/mdui/0.4.3/css/mdui.min.css', - 'bootcss' => 'cdn.bootcss.com/mdui/0.4.2/css/mdui.min.css', - 'cdnjs' => 'cdnjs.cloudflare.com/ajax/libs/mdui/0.4.3/css/mdui.min.css', + 'jsdelivr' => 'cdn.jsdelivr.net/npm/mdui@1.0.1/dist/css/mdui.min.css', + 'cssnet' => 'cdnjs.loli.net/ajax/libs/mdui/1.0.1/css/mdui.min.css', + 'bootcss' => 'cdn.bootcss.com/mdui/1.0.1/css/mdui.min.css', + 'cdnjs' => 'cdnjs.cloudflare.com/ajax/libs/mdui/1.0.1/css/mdui.min.css', 'custom' => isset($lists[0]) ? $lists[0] : '' ], 'mdui.min.js' => [ - 'cssnet' => 'cdnjs.loli.net/ajax/libs/mdui/0.4.3/js/mdui.min.js', - 'bootcss' => 'cdn.bootcss.com/mdui/0.4.2/js/mdui.min.js', - 'cdnjs' => 'cdnjs.cloudflare.com/ajax/libs/mdui/0.4.3/js/mdui.min.js', + 'jsdelivr' => 'cdn.jsdelivr.net/npm/mdui@1.0.1/dist/js/mdui.min.js', + 'cssnet' => 'cdnjs.loli.net/ajax/libs/mdui/1.0.1/js/mdui.min.js', + 'bootcss' => 'cdn.bootcss.com/mdui/1.0.1/js/mdui.min.js', + 'cdnjs' => 'cdnjs.cloudflare.com/ajax/libs/mdui/1.0.1/js/mdui.min.js', 'custom' => isset($lists[1]) ? $lists[1] : '' ] ]; @@ -494,13 +520,13 @@ function staticUrl($file = '') 'jquery.fancybox.min.css' => [ 'bc' => 'cdn.bootcss.com/fancybox/3.5.7/jquery.fancybox.min.css', 'cf' => 'cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.css', - 'jd' => 'cdn.jsdelivr.net/npm/fancybox@3.0.1/dist/css/jquery.fancybox.css', + 'jd' => 'cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.css', 'custom' => isset($lists[3]) ? $lists[3] : '' ], 'jquery.fancybox.min.js' => [ 'bc' => 'cdn.bootcss.com/fancybox/3.5.7/jquery.fancybox.min.js', 'cf' => 'cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.js', - 'jd' => 'cdn.jsdelivr.net/npm/fancybox@3.0.1/dist/js/jquery.fancybox.min.js', + 'jd' => 'cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js', 'custom' => isset($lists[4]) ? $lists[4] : '' ] ]; diff --git a/core/js/darkmode.js b/core/js/darkmode.js index a667eef..f62e9e5 100644 --- a/core/js/darkmode.js +++ b/core/js/darkmode.js @@ -32,12 +32,12 @@ const getDarkModeFromCookie = () => { * 是否为 Dark Mode */ const getDarkModeFromDom = () => { - return mdui.JQ('body').hasClass('mdui-theme-layout-dark') + return mdui.$('body').hasClass('mdui-theme-layout-dark') } /**MDr On DarkMode */ const onDarkMode = () => { - var body = mdui.JQ('body'), + var body = mdui.$('body'), appbar = document.getElementsByClassName('mdui-appbar')[0]; console.log('Dark mode on'); document.cookie = "dark=1;path=/;" + mdrDarkModeFD; @@ -49,7 +49,7 @@ const onDarkMode = () => { /**MDr Off Darkmode */ const offDarkMode = () => { - var body = mdui.JQ('body'), + var body = mdui.$('body'), appbar = document.getElementsByClassName('mdui-appbar')[0]; console.log('Dark mode off'); document.cookie = "dark=0;path=/;" + mdrDarkModeFD; @@ -61,8 +61,8 @@ const offDarkMode = () => { /* Dark Mode 对于 @print 的适配 */ window.addEventListener("beforeprint", function () { - var body = mdui.JQ('body'), - appbar = mdui.JQ('.mdui-appbar'); + var body = mdui.$('body'), + appbar = mdui.$('.mdui-appbar'); appbar.hide(); if (body.hasClass('mdui-theme-layout-dark')) { body.addClass('mdui-theme-layout-dark-print'); @@ -70,8 +70,8 @@ window.addEventListener("beforeprint", function () { } }); window.addEventListener("afterprint", function () { - var body = mdui.JQ('body'), - appbar = mdui.JQ('.mdui-appbar'); + var body = mdui.$('body'), + appbar = mdui.$('.mdui-appbar'); appbar.show(); if (body.hasClass('mdui-theme-layout-dark-print')) { body.addClass('mdui-theme-layout-dark'); diff --git a/core/js/script.js b/core/js/script.js index 51e0412..76ebd28 100644 --- a/core/js/script.js +++ b/core/js/script.js @@ -15,7 +15,7 @@ const mdrScroll = () => { header.css('background', getDarkModeFromDom() ? '#212121' : '#ffffff'); } else { header.addClass('mdui-shadow-0'); - header.css('background', 'none'); + header.css('background', getDarkModeFromDom() ? '#121212' : '#ffffff'); } } @@ -77,10 +77,10 @@ const mdrCatalog = (data) => { return; } mdrTab.show(0); - var list = mdui.JQ('#mdrDrawerLtoc .mdui-list'); + var list = mdui.$('#mdrDrawerLtoc .mdui-list'); list.empty(); data.forEach((value) => { - var dom = mdui.JQ(document.createElement('a')); + var dom = mdui.$(document.createElement('a')); dom.addClass('mdui-list-item mdui-ripple'); dom.addClass('mdui-p-l-' + Math.min(value.depth * 2, 5)); dom.attr('href', '#cl-' + value.count); diff --git a/footer.php b/footer.php index aac0481..f6dc543 100644 --- a/footer.php +++ b/footer.php @@ -14,7 +14,7 @@
    © options->mdrCopytext) ? $this->options->mdrCopytext() : $this->options->title() ?>. Powered by Typecho. - Theme MDr by FlyingSky.
    + Theme MDr-Petals by FlyingSky.
    @@ -26,12 +26,12 @@ const mdrVersion = ''; const mdrSnackbar = 'options->mdrSnackbar ?>'; const mdrTab = new mdui.Tab('#mdrTab'); - const mdrTabDom = mdui.JQ('#mdrTab'); + const mdrTabDom = mdui.$('#mdrTab'); const mdrAjaxLoadTimes = options->AjaxLoadTimes ?>; user->hasLogin() && $this->user->pass('administrator', true) and null !== @$_GET['debug']) : ?> - + user->hasLogin() && $this->user->pass('administrator', true) and null !== @$_GET['debug']) : ?> - + diff --git a/functions.php b/functions.php index e41bf4e..f777e0d 100644 --- a/functions.php +++ b/functions.php @@ -80,11 +80,6 @@ function themeConfig($form)

    - -

    @@ -122,11 +117,7 @@ function mdrInstantView() { } EOF; - echo "" . '' . ''; + echo ""; /* MDr Color 主题色设置 */ $mdrNotice = new Typecho_Widget_Helper_Form_Element_Text('mdrNotice', NULL, NULL, _t('

    主题色设置 Color

    ')); @@ -162,11 +153,12 @@ function mdrInstantView() { 'bootcss' => _t('BootCDN'), 'cdnjs' => _t('CDNJS'), 'cssnet' => _t('CSSnet'), + 'jsdelivr' => _t('jsDelivr'), 'custom' => _t('自建') ), - 'cssnet', + 'jsdelivr', _t('MDUI 静态资源来源'), - _t('默认 CSSnet ,请根据需求选择合适来源') + _t('默认 jsDelivr ,请根据需求选择合适来源') ); $form->addInput($mdrMDUICDN); @@ -207,8 +199,8 @@ function mdrInstantView() { $mdrNavDefOpen = new Typecho_Widget_Helper_Form_Element_Radio( 'mdrNavDefOpen', array( - true => _t('开'), - false => _t('关') + true => _t('启用'), + false => _t('关闭') ), false, _t('默认打开抽屉导航栏'), @@ -216,23 +208,11 @@ function mdrInstantView() { ); $form->addInput($mdrNavDefOpen); - $mdrNavBackground = new Typecho_Widget_Helper_Form_Element_Radio( - 'mdrNavBackground', - array( - true => _t('开'), - false => _t('关') - ), - false, - _t('应用栏背景'), - _t('开启时应用栏背景颜色为主题主色,关闭后则为白色') - ); - $form->addInput($mdrNavBackground); - $mdrNavColorBut = new Typecho_Widget_Helper_Form_Element_Radio( 'mdrNavColorBut', array( - true => _t('开'), - false => _t('关') + true => _t('启用'), + false => _t('关闭') ), true, _t('抽屉导航栏彩色按钮'), @@ -294,8 +274,8 @@ function mdrInstantView() { $RandomLinks = new Typecho_Widget_Helper_Form_Element_Radio( 'RandomLinks', array( - true => _t('开'), - false => _t('关') + true => _t('启用'), + false => _t('关闭') ), true, _t('友情链接随机排序'), @@ -306,8 +286,8 @@ function mdrInstantView() { $mdrPray = new Typecho_Widget_Helper_Form_Element_Radio( 'mdrPray', array( - true => _t('开'), - false => _t('关') + true => _t('启用'), + false => _t('关闭') ), false, _t('全站暗淡'), @@ -318,8 +298,8 @@ function mdrInstantView() { $mdrHitokoto = new Typecho_Widget_Helper_Form_Element_Radio( 'mdrHitokoto', array( - true => _t('开'), - false => _t('关') + true => _t('启用'), + false => _t('关闭') ), true, _t('一言 API 开关'), @@ -431,7 +411,7 @@ function mdrInstantView() { 'mdrPostAuthor', array( true => _t('显示'), - false => _t('不显示') + false => _t('隐藏') ), false, _t('文章内页显示作者'), diff --git a/hash.txt b/hash.txt deleted file mode 100644 index 07be743..0000000 --- a/hash.txt +++ /dev/null @@ -1,25 +0,0 @@ -8df17163c449b8393a6c0a7b1f966025b638f1c48a3771a1a6f8a0230152efbd ./update.php -87db1d525526dfa4ca0b6508541fa266bcfcab3c3906dd39f7763e62faea2db0 ./screenshot.png -d3967102e6f848f3309e22865af0c40a547774f354a023f9c879aa672bc93cd5 ./post.php -298d54504a415667d2fc11ac24b544263e1ffd16d038eb6d4d2a6263c9b60f65 ./page.php -8699736c825984e7e2699abc4dcf15186cb333f546863c6e9721ea5466421d10 ./page-links.php -140cc79e506a088cd4f9af9d9bd6640b945bc27a0eeba1de47bb2402511da623 ./page-archives.php -aebce060ddd83c93d5c5e9c45232c73719a933752157dfc8c84163c99a648e77 ./index.php -edd0a939b4a41f36b049f1f462b1feaf72b0d8d8e146a40866d2957d8951ad8b ./header.php -40f05c28c9d6dfe895f24669a491107317d92d28abd2ad68504970e73965bb71 ./functions.php -f422daff3cac9dd91e62cdda2e2061e7ec80e944d7378449c98e1051f7ce1ab4 ./footer.php -21bfef409d3bf5fb8853756afcee81bc3f67aef25a01292087ea7cecc6907a7c ./core/lib/ShortCode.php -7568b3c55b731eababe8bf4d893874aa7f861e06c7fa127da0c2bdc2a462297e ./core/lib/Main.php -a7aced8cef30a94707dc67d6db740e5e810c3e494f505d9ca2b3fed012140426 ./core/lib/Color.json -34ba2f010c86c02a05bf895180cc32cf83631116255c2473b053ff6cca8f70d6 ./core/js/script.js -52a611105c7481b9ba325bb95dc426cfd9e31530977e0585b9352002cfa7a5cf ./core/js/darkmode.js -d253eb4b946284df1fd05b3357e651e59bafdf52252aaa567c55015b9aaa288a ./core/functions.php -13fe67d3f0d2ba86b0202dd1ed7a63c8e1da2e85f04fc4a6c19ae4889c9ec768 ./core/css/style.min.css -00ec901acbedfb921e3605fde12fd379da439bfcb8d22ef343783550fdbc084a ./core/css/style-petals.css -e91fe21eb4ffefd1c4e8dd4d3b497a3ca43b0a39f282e49aeec525f2c956cece ./core/config.ini.php -e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ./core/.debugger -8bc72d55db0b0e641ba03e1b1cdc18a0f6a3afbafe2973285cb8c1ea1899eeb7 ./comments.php -033a847c6e2a56bbdb3ae9428c60a26cf5c3ee131fff7642f571ffab9cae1a14 ./archive.php -1d75297b22f3b08c972f05056e30773162465e3cd2838798ee21d0466b3a374c ./README.md -9f199afc5e744068485d42a16ee27ac9a03d4121becd65a9afe09598d4896210 ./LICENSE -03160d8f540779fda4122dac8ef7b29638ea3f6bb89ceee19ff4f29d789e29e9 ./404.php \ No newline at end of file diff --git a/header.php b/header.php index d0ac851..ff35f4a 100644 --- a/header.php +++ b/header.php @@ -16,12 +16,13 @@ exit(); } else foreach ($_SESSION['mdrConfig'] as $name => $key) $this->options->$name = $key; } -} ?> +} +?> options->mdrPray) : ?>class="pray" lang="zh-CN"> - + @@ -39,17 +40,21 @@ options->mdrCornertool) : ?> - - + + options->ViewImg) : ?> @@ -66,7 +71,7 @@
    -
    +
    menu @@ -82,12 +87,7 @@