mycpen

Mycpen

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

02_Reprint - Deploying Memos & Butterfly Based on Memos to Implement Checklist Functionality

2023/06/01 Update#

Recently, Replit's Repl has experienced rollback phenomena, causing the latest changes to be lost, as mentioned by the repository manager of uptimekumaonreplit Replit is a bit slow, seems to roll back, which causes many database mismatches. Just use it casually 20220430, I have not yet found a solution to the rollback phenomenon.

The following content is fully excerpted from Atticus and Leonus articles.

Article 1. Atticus: Free Deployment of Memos on Replit#

Deployment#

Use the default project name memos-on-replit, otherwise it will not deploy.

The language must be Go.

image-20230208012722551

License#

memos-replit is open-source software licensed under AGPL-3.0.

Disclaimer#

  • This program is a free open-source project aimed at sharing cloud disk files for easy downloading and learning Golang. Please comply with relevant laws and regulations when using it, and do not abuse it;
  • This program is implemented by calling the official SDK/API, with no destructive behavior towards the official interface;
  • This program only performs 302 redirection/traffic forwarding, without intercepting, storing, or tampering with any user data;
  • Before using this program, you should understand and bear the corresponding risks, including but not limited to account bans, download speed limits, etc., which are unrelated to this program;
  • If there is any infringement, please contact me via email, and it will be handled promptly. @Blog · @GitHub · @Telegram Group

Copyright belongs to: atticus
Article link: https://www.iweec.cn/30.htm

Article 2. Leonus: Implementing Sayings and List Functionality Based on Memos#

Related Links

  1. Leonus: Implementing Sayings and List Functionality Based on Memos
  2. Leonus: Implementing Dynamic Albums Based on Memos

The following content is fully excerpted from Leonus: Implementing Sayings and List Functionality Based on Memos List Functionality section.

List Functionality

To reiterate, all of this is just the rules I set, and you can modify the code as you wish to achieve the effects you want.

Implementation#

First, use hexo n page xxx to create a page.
Then paste the following code and modify the content according to the comments.

<style>
/* Page Initialization */
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;
}

/* Page Initialization End */
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>
// Waterfall function, ignore
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}

// List function
todolist();
function todolist() {
    fetch('https://yourmemosaddress/api/memo?creatorId=1&tag=list').then(res => res.json()).then(data => { // Note to replace the link
        // Get and process data
        data = data.data
        let box = document.getElementById('todolist')
        data.forEach(item => {
            // Process data
            let content = item.content,
                title = content.match(/\[(.*?)\]/g)[0].replace(/\[(.*?)\]/,'$1');
            // Remove excess content, replace list content
            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>`);
            // Render data
            let div = document.createElement('div');
            div.className = 'list_item';
            div.innerHTML = `<h3>${title}</h3><ul>${content}</ul>`;
            box.appendChild(div);
        });
        waterfall('#todolist');
    }).catch()
}
</script>

Usage#

The format used is as follows:

#List [Places to Go]
- [ ] Mickey's Funhouse (added by a light laugh)
- [x] Completed List

Note that the #List at the front is fixed. The title is enclosed in square brackets. To mark as completed, simply change the space inside the brackets to x.

image-20230208013833064

Article Author: Leonus
Article Link: https://blog.leonus.cn/2023/memeos.html

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