mycpen

Mycpen

记录学习历程与受益知识
github
telegram
bilibili

02_转载-Replit 部署 Memos & Butterfly 基于 Memos 实现清单功能

2023/06/01 更新#

最近 Replit 的 Repl 出现回档现象,导致最新变更操作丢失,正如 uptimekumaonreplit 仓库管理者提到的 Replit有点拉,似乎会回档,会导致数据库很多对不上。随便用用吧20220430,回档现象我暂未找到解决办法

参考链接#

以下内容全文摘自 AtticusLeonus 的文章

文章 1. Atticus:replit 免费部署 memos#

部署#

使用默认项目名称 memos-on-replit,否则会无法部署

语言必须为 Go

image-20230208012722551

许可#

memos-replit 是在 AGPL-3.0 许可下许可的开源软件。

免责声明#

  • 本程序为免费开源项目,旨在分享网盘文件,方便下载以及学习 golang,使用时请遵守相关法律法规,请勿滥用;
  • 本程序通过调用官方 sdk / 接口实现,无破坏官方接口行为;
  • 本程序仅做 302 重定向 / 流量转发,不拦截、存储、篡改任何用户数据;
  • 在使用本程序之前,你应了解并承担相应的风险,包括但不限于账号被 ban,下载限速等,与本程序无关;
  • 如有侵权,请通过邮件与我联系,会及时处理。@博客 · @GitHub · @Telegram 群

版权属于: atticus
本文链接: https://www.iweec.cn/30.htm

文章 2. Leonus:基于 Memos 实现说说和清单功能#

相关链接

  1. Leonus:基于 Memos 实现说说和清单功能
  2. Leonus:基于 memos 实现动态相册

以下内容全文摘自 Leonus:基于 Memos 实现说说和清单功能 清单功能 部分

清单功能

再次说明,这一切只是我定的规则而已,你可以随意修改代码来实现你想实现的效果。

实现#

还是先使用hexo n page xxx创建页面。
然后粘贴如下代码并按照注释修改内容。

<style>
/* 页面初始化 */
div#page {
    background: none;
    border: 0;
    padding: 0;
}
[data-theme=dark] #twikoo .tk-content,
#twikoo .tk-content {
    padding: 0;
    background: transparent;
}

.tk-comments-container>.tk-comment,
.tk-submit:nth-child(1){
    background: var(--card-bg);
    border: 1px rgba(188, 188, 188, 0.8) solid;
    box-shadow: 0 5px 10px rgb(189 189 189 / 10%);
    transition: all .3s ease-in-out;
    border-radius: 12px;
}

.tk-comments-container>.tk-comment:hover,
.tk-submit:nth-child(1):hover {
    border-color: #6dc3fd;
}

.tk-submit {
    padding: 20px 10px 0;
}

.tk-comments-container>.tk-comment {
    padding: 15px;
}

/* 页面初始化结束 */
div#todolist {
    display: flex;
    flex-wrap: wrap;
    margin-top: 1rem;
}
.list_item {
    display: inline-block;
    width: calc(50% - .4rem);
    background: #ffe3dd;
    border-radius: 12px;
    padding: 10px 1rem 1.2rem;
    border: 2px dashed #f7a796;
    --todo-border: 1px solid #f7a796;
    margin-right: 1rem;
    margin-bottom: 1rem;
}
.list_item h3 {
    margin: 0;
    border-bottom: var(--todo-border);
}
.list_item ul {
    font-size: 17px;
    padding: 0 !important;
    margin: 0;
}
 .list_item li{
    margin: 0 !important;
    border-bottom: var(--todo-border);
 }
.list_item li::marker {
  content: none;
}
li.achieve {
    opacity: .8;
    text-decoration: line-through;
}
@media screen and (max-width: 900px) {
  div#todolist {
    margin: 1rem 5px 0;
  }
}
@media screen and (max-width: 768px) {
  .list_item{
    width: 100%;
  }
}
</style>


<div id="todolist"></div>


<script>
// 瀑布流函数,不用管
function waterfall(t){function e(t,e){var n=window.getComputedStyle(e);return parseFloat(n["margin"+t])||0}function n(t){return t+"px"}function r(t){return parseFloat(t.style.left)}function o(t){return t.clientWidth}function l(t){return function(t){return parseFloat(t.style.top)}(t)+function(t){return t.clientHeight}(t)+e("Bottom",t)}function i(t){return r(t)+o(t)+e("Right",t)}function u(t){t=t.sort((function(t,e){return l(t)===l(e)?r(e)-r(t):l(e)-l(t)}))}function a(e){o(t)!=h&&(e.target.removeEventListener(e.type,arguments.callee),waterfall(t))}"string"==typeof t&&(t=document.querySelector(t));var s=[].map.call(t.children,(function(t){return t.style.position="absolute",t}));t.style.position="relative";var f=[];s.length&&(s[0].style.top="0px",s[0].style.left=n(e("Left",s[0])),f.push(s[0]));for(var p=1;p<s.length;p++){var c=s[p-1],y=s[p];if(!(i(c)+o(y)<=o(t)))break;y.style.top=c.style.top,y.style.left=n(i(c)+e("Left",y)),f.push(y)}for(;p<s.length;p++){u(f);y=s[p];var d=f.pop();y.style.top=n(l(d)+e("Top",y)),y.style.left=n(r(d)),f.push(y)}u(f);var v=f[0];t.style.height=n(l(v));var h=o(t);window.addEventListener?window.addEventListener("resize",a):document.body.onresize=a}

// 清单函数
todolist();
function todolist() {
    fetch('https://你的memos地址/api/memo?creatorId=1&tag=清单').then(res => res.json()).then(data => { // 注意替换链接
        // 获取并处理数据
        data = data.data
        let box = document.getElementById('todolist')
        data.forEach(item => {
            // 处理数据
            let content = item.content,
                title = content.match(/\[(.*?)\]/g)[0].replace(/\[(.*?)\]/,'$1');
            // 去掉多余内容,替换清单内容
            content = content.replace(/#.*\s/g, '').replace(/(-\s\[\s\]\s)(.*)/g, `<li><i style="margin-right: 5px;" class="fa-regular fa-circle"></i>$2</li>`).replace(/(-\s\[x\]\s)(.*)/g, `<li class="achieve"><i style="margin-right: 5px;" class="fa-regular fa-circle-check"></i>$2</li>`);
            // 渲染数据
            let div = document.createElement('div');
            div.className = 'list_item';
            div.innerHTML = `<h3>${title}</h3><ul>${content}</ul>`;
            box.appendChild(div);
        });
        waterfall('#todolist');
    }).catch()
}
</script>

使用#

使用的格式如下:

#清单 [想去的地方]
- [ ] 轻笑的米奇妙妙屋(轻笑让我加的)
- [x] 已完成的清单

注意,前面的#清单 是固定的。标题用中括号包起来。已完成的将括号内的空格改成 x 即可。

image-20230208013833064

文章作者: Leonus
文章链接: https://blog.leonus.cn/2023/memeos.html

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.