Typecho的Joe主题编辑器加入转载地址展示

Typecho的Joe主题编辑器加入转载地址展示

执念博客
2021-05-19 / 7 评论 / 220 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2021年06月02日,已超过116天没有更新,若内容或图片失效,请留言反馈。

0.成品图
kpfevykl.png

1.修改copyright.php文件,新增代码,文件路径:

①第一段,新增,最上方
<?php
    $content = $this->content;
    $content = _parseReply($content);
    $isContain = 0;
    if(strpos($content, 'custom-copyright') !== false) { 
        $isContain = 1;
    }
?>
<style>
    .custom-copyright{
        display: none;
    }
</style>

②第二段,新增,中间
<div class="item custom-copyright">
    <svg t="1622634042051" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9170" width="20" height="20"><path d="M512 1024C229.230021 1024 0 794.769979 0 512S229.230021 0 512 0s512 229.230021 512 512-229.230021 512-512 512z m248.300679-758.012243l-2.297023-2.297023c-52.932428-52.921694-139.621434-52.921694-192.554935 0L442.70504 386.411874c-52.932428 52.921694-52.932428 139.5946 0 192.516294l2.297023 2.297023c4.36327 4.361124 9.070021 8.379841 13.892696 12.054004l44.896067-44.88748c-5.28208-3.098834-10.219606-6.772998-14.697727-11.248973l-2.297024-2.297023c-28.704201-28.698834-28.704201-75.536637 0-104.236545l122.744755-122.718994c28.705275-28.699908 75.551665-28.699908 104.256939 0l2.297023 2.29595c28.705275 28.698834 28.705275 75.536637 0 104.235472l-55.459153 55.448419c9.64535 23.763455 14.238323 49.133753 13.778919 74.50405l85.886121-85.868947c52.932428-52.921694 52.932428-139.5946 0-192.516294zM578.882013 442.776956c-4.36327-4.362197-9.070021-8.380914-13.892696-12.054004l-44.894994 44.886406c5.281006 3.098834 10.218532 6.772998 14.696654 11.248973l2.297023 2.297023c28.704201 28.698834 28.704201 75.536637 0 104.236545L414.344319 716.110893c-28.705275 28.699908-75.551665 28.699908-104.25694 0l-2.297023-2.29595c-28.705275-28.698834-28.705275-75.536637 0-104.235471l55.574005-55.44842c-9.64535-23.763455-14.238323-49.133753-13.778919-74.50405l-85.886121 85.868948c-52.932428 52.921694-52.932428 139.5946 0 192.516293l2.297023 2.297023c52.932428 52.921694 139.621434 52.921694 192.554935 0l122.743681-122.720067c52.932428-52.921694 52.932428-139.5946 0-192.516293l-2.411874-2.297023z" fill="#F7A349" p-id="9171"></path></svg>
    <span class="custom-copyright-title">文章转载:</span>
    <span class="text">
        <a class="link custom-copyright-href" href="" target="_blank" rel="noopener noreferrer"></a>
    </span>
</div>

③第三段,新增,最下方
<script>
    var isContain = <?php echo $isContain ?>;
    if(isContain) {
        $('.custom-copyright').css({
            'display': 'block'
        });
        var title = $('#custom-copyright').attr('data-title');
        var href = $('#custom-copyright').attr('data-href');
        $('.custom-copyright-title').text(title + ':');
        $('.custom-copyright-href').text(href);
        $('.custom-copyright-href').attr('href', href);
    }
</script>

kov0z7mw.png
kov1054j.png
kov11awx.png

2.新建custom.js文件,将以下代码防在文件内,文件路径:usr/themes/Joe-master/assets/js

document.addEventListener('DOMContentLoaded', () => {
    var copyright = '<div class="cm-tools-item" title="版权"><svg t="1622610141615" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2895" width="20" height="20"><path d="M515.52 722.259c-109.945 0-199.476-89.467-199.476-199.476s89.467-199.475 199.476-199.475 199.475 89.466 199.475 199.475S625.465 722.26 515.52 722.26z m0-339.883c-77.435 0-140.407 62.972-140.407 140.471 0 77.435 62.972 140.408 140.407 140.408s140.407-62.973 140.407-140.408c0-77.499-62.972-140.47-140.407-140.47z m29.054 229.874h-18.687c-49.34 0-89.466-40.126-89.466-89.403 0-49.34 40.125-89.466 89.466-89.466h18.751c16.319 0 29.502 13.183 29.502 29.502s-13.183 29.502-29.502 29.502h-18.75c-16.768 0-30.399 13.631-30.399 30.462 0 16.767 13.631 30.398 30.398 30.398h18.751c16.319 0 29.502 13.184 29.502 29.503s-13.247 29.502-29.566 29.502z m-29.054 411.686c-4.16 0-8.32-0.896-12.223-2.688L302.22 929.606c-137.08-62.46-222.194-181.109-222.194-309.549v-434.66c0-8.832 3.968-17.152 10.751-22.783 6.784-5.632 15.743-7.872 24.383-6.208 26.11 5.12 52.924 7.68 79.739 7.68 88.634 0 175.093-28.67 237.297-78.587l64.764-52.03c10.815-8.703 26.174-8.703 36.926 0L598.65 85.5c62.204 49.98 148.662 78.587 237.297 78.587 26.814 0 53.628-2.56 79.739-7.68 8.64-1.728 17.599 0.576 24.382 6.208 6.784 5.631 10.752 13.951 10.752 22.782v434.661c0 128.44-85.115 247.089-222.195 309.549l-201.075 91.642c-3.712 1.792-7.871 2.688-12.031 2.688zM139.03 219.89v400.167c0 105.082 71.932 203.124 187.637 255.856l188.788 86.075 188.788-86.075C820.013 823.117 891.88 725.075 891.88 620.057V219.89a478.563 478.563 0 0 1-55.868 3.264c-103.29 0-200.692-32.51-274.287-91.642L515.52 94.33l-46.333 37.182c-73.532 59.068-170.934 91.642-274.223 91.642-18.751 0-37.438-1.088-55.933-3.264z" fill="" p-id="2896"></path></svg></div>';
    $(".cm-tools").append(copyright);
    $(".cm-tools .cm-tools-item").click(function(){
        if($(this).attr("title") == '版权') {
            var copyright_txt = '插入版权';
            var copyright_body = '<div class="fitem"><label>版权名称</label><input autocomplete="off" name="copyright_title" placeholder="请输入版权名称"></div>';
            copyright_body += '<div class="fitem"><label>版权地址</label><input autocomplete="off" name="copyright_url" placeholder="请输入版权地址"></div>';
            $(".cm-modal__wrapper-header .cm-modal__wrapper-header--text").html(copyright_txt);
            $(".cm-modal__wrapper-bodyer").html(copyright_body);
            $('.cm-modal').addClass('active');
            $(".cm-modal__wrapper-footer--confirm").attr('style', 'display: none');
            $(".cm-modal__wrapper-footer").removeAttr('style');
            var copyright_button = '<div class="cm-modal__wrapper-footer--confirm custom_button">确认</div>';
            $('.custom_button').remove();
            $(".cm-modal__wrapper-footer").append(copyright_button);
            $(".custom_button").click(function(){
                var copyright_title = $( ".fitem input[name='copyright_title']").val();
                var copyright_url = $( ".fitem input[name='copyright_url']").val();
                var text= "<span><</span>div id='custom-copyright' data-title='" + copyright_title + "' data-href='" + copyright_url + "'><span><</span>/div>";
                $(".cm-mainer .cm-scroller .cm-content").append('<br>!!!<br>');
                $(".cm-mainer .cm-scroller .cm-content").append(text);
                $(".cm-mainer .cm-scroller .cm-content").append('<br>!!!<br>');
                $('.cm-modal').removeClass('active');
            });
        }
        else {
            $(".cm-modal__wrapper-footer--confirm").removeAttr('style');
            $('.custom_button').remove();
        }
    });
});

kpfejap4.png

4.修改factory.php文件,新增以下代码,文件路径:usr/themes/Joe-master/core

下载地址如下:

本文共 134 个字数,平均阅读时长 ≈ 1分钟
4

打赏

海报

正在生成.....

评论 (7)

取消
  1. 头像
    1018博客 Lv.1
    Windows 10 · Google Chrome
    沙发

    看一下这个是什么

    回复 删除 垃圾
  2. 头像
    俊宏 Lv.1
    Windows 7 · Google Chrome
    板凳

    又搞隐藏。。。。

    回复 删除 垃圾
    1. 头像
      执念博客 Lv.6 作者
      Windows 7 · Google Chrome
      @ 俊宏

      不隐藏咋混评论呢

      回复 删除 垃圾
  3. 头像
    川川 Lv.2
    Windows 7 · QQ Browser
    地毯

    看看

    回复 删除 垃圾
  4. 头像
    十点 Lv.1
    Windows 10 · Google Chrome
    第4楼

    看看

    回复 删除 垃圾
  5. 头像
    神话 Lv.2
    Android · Google Chrome
    第5楼

    到底隐藏了个什么东西

    回复 删除 垃圾
    1. 头像
      执念博客 Lv.6 作者
      Windows 7 · Google Chrome
      @ 神话

      隐藏了下载地址表情

      回复 删除 垃圾