custard
https://gyazo.com/dba813d5b534615dfdccf8465a6da866
学生です
整備中のため,網羅はできてないかも
始めてから4ヶ月ほど
まだまだ試行錯誤中test.icon
5ヶ月経過
2000ページ到達も,実感はない
膨大なページと適切なリンク,切り分けが肝心だと思う
自然体でやっていこう
6ヶ月ほど経過
8月は思考やその記述が少ない
イラスト > ノーコピーライトガール
使用している画像の大半がここ
cf. どこか
code: script.js
scrapbox.PageMenu.addItem({
title: () => {
if (!scrapbox.Page.lines) return
const chars = scrapbox.Page.lines.map(line => line.text.length).reduce((a,b) => a + b)
const words = scrapbox.Page.lines.map(line => line.text.split(/\s+/).length).reduce((a,b) => a + b)
return ${chars}文字 ${words}単語 ${scrapbox.Page.lines.length}行
},
onClick: () => null
})
code: style.css
button#Templates.tool-btn:hover { text-decoration: none }
button#Templates.tool-btn::before { position: absolute; content: '\f067'; font: 900 21px/46px 'Font Awesome 5 Free' }
button#Templates.tool-btn img { opacity: 0 }
code: script.js
addTemplateItemsToPageMenu()
function addTemplateItemsToPageMenu() {
// define templates
const __templates = [
{ title: '📄 daily', template: '/api/code/main-custard/template/daily_log.js' },
{ title: '📄 weekly', template: '/api/code/main-custard/template/weekly_log.js' },
{ title: '📄 reading', template: '/api/code/main-custard/template/reading_list.js'},
{ title: '📄 やりたいこと', template: '/api/code/main-custard/template/anyTask.js' }
]
const __templMenuTitle = 'Templates'
scrapbox.PageMenu.addMenu({ title: __templMenuTitle, image: '/assets/img/logo.png', onClick: () => { } })
__templates.forEach((i) => {
scrapbox.PageMenu(__templMenuTitle).addItem({
title: i.title,
onClick: () => { __loadTemplate(i.template) }})
})
var __loadTemplate = function (templateUrl) {
if (scrapbox.Page.lines && scrapbox.Page.lines.length == 1) {
// タイトル行をクリックしたことにする
const line = document.getElementById('L' + scrapbox.Page.lines0.id) const lastChar = line.querySelector('span.char-index:last-of-type')
const textarea = document.getElementById('text-input')
lastChar.dispatchEvent(new MouseEvent('click', {bubbles: true, cancelable: true}))
textarea.dispatchEvent(new KeyboardEvent('keydown', {bubbles: true, cancelable: true, keyCode: 35}))
// テンプレートを読み込む
$('#text-input').load(templateUrl, function (response, status, xhr) {
if (status == "success") {
try {
// 読み込んだテンプレートをテキストエリアにセットしまして
textarea.value = /\.js$/.test(templateUrl) ? eval(response) : response
// テキストエリアのinputイベントを出しまして
textarea.dispatchEvent(new InputEvent('input', {bubbles: true, cancelable: true}))
} catch (ex) {
console.log("あぼーん\n" + ex)
}
} else {
console.log("あぼーん \n" + status)
}
})
}
}
}
アイコンを試す
code: script.js
// ここからアイコンとスタイルの定義
// - アイコンの名前はエンコードしなくてOK、日本語でもOK
// - スタイル部分は content だけ必須、バックスラッシュ2個必要なので注意、あとはお好みで
const tagIconStyles = {
"!" : "{ content: '\\f06a'; color: #F6AE2D }", /* ひらめき */ "?" : "{ content: '\\f059'; color: #758E4F }", /* 疑問、要調査 */ "*" : "{ content: '\\f069'; color: #F26419 }", /* 重要 */ "_" : "{ content: '\\f0c8'; color: #08BDBD }", /* タスク */ "x" : "{ content: '\\f14a'; color: #2489C5 }", /* 完了タスク */ ">" : "{ content: '\\f14d'; color: lightgrey }", /* 先送りしたタスク */
"<" : "{ content: '\\f274'; color: lightgrey }", /* 日付を決めたタスク */
"e" : "{ content: '\\f192'; color: #F26419 }", /* イベント */ "good" : "{ content: '\\f164' }", /* おまけ。下に説明があるよ */
"bad" : "{ content: '\\f165' }",
"good_meal" : "{ content: '\\f087\\f805\\f069'; letter-spacing: .2em }"
};
// ここから下は無視してね ---------------------
(function(m){
let charSelectors = [], afterLinkSelectors = [], iconStyle = ""
const linkSelFmt = ".line:not(.cursor-line) ahref$='/#':not(.icon)" const charStyle = "{display:inline-block;width:0;text-indent:-9999px}"
const afterLinkStyle = "{display:inline-block;min-width:1.15em;padding-left:1px;font: 900 110%/normal 'Font Awesome 5 Free';text-align:center}"
const a = "::after", f = " span"
const encode = tag => Array.from(tag).map(c => {
const i = enc0.indexOf(c) return -1 < i && enc1i ? enc1i : encodeURIComponent(c) }).join(""); for (var k in m) {
const href = encode(k)
charSelectors.push(linkSelFmt.replace(/#/, href) + f)
afterLinkSelectors.push(linkSelFmt.replace(/#/, href) + a)
iconStyle += linkSelFmt.replace(/#/, href) + a + mk }
let style = document.createElement('style')
style.appendChild(document.createTextNode(charSelectors.join(",") + charStyle))
style.appendChild(document.createTextNode(afterLinkSelectors.join(",") + afterLinkStyle))
style.appendChild(document.createTextNode(iconStyle))
document.head.appendChild(style)
})(tagIconStyles)