週報テンプレート.js// 週報1週間分のフォーマットを生成する。
(function() {
Date.prototype.setWeek = function(year, week, day) {
var week1 = new Date(year, 0, 1)
var prevLastDay = new Date(week1.getTime() - 86400000 * (week1.getDay() || 7))
console.log(prevLastDay)
return this.setTime(prevLastDay.getTime() + 86400000 * ((week - 1) * 7 + day))
}
Date.prototype.setISOWeek = function(year, week, day) {
var week1 = new Date(year, 0, 4)
var prevLastDay = new Date(week1.getTime() - 86400000 * (week1.getDay() || 7))
console.log(prevLastDay)
return this.setTime(prevLastDay.getTime() + 86400000 * ((week - 1) * 7 + day))
}
Date.prototype.format = function(format) {
// yyyy, MM, dd, ddd だけ
const days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
return format.replace('ddd', days[this.getDay()])
.replace('yyyy', this.getFullYear())
.replace('MM', ('0' + (this.getMonth() + 1)).slice(-2))
.replace('dd', ('0' + this.getDate()).slice(-2))
}
// 処理ここから
const yearWeek = scrapbox.Page.title.split("'") // 新規ページの仮タイトルから、年と週番号を取得して
const d = new Date()
console.log(yearWeek)
// 週番号の計算方法をここで指定するよ
//d.setWeek(yearWeek[0], yearWeek[1], 0) // 米国式・月曜始まり
//d.setWeek(yearWeek[0] - 1, yearWeek[1], 6) // 米国式・日曜始まり
d.setISOWeek(yearWeek[0], yearWeek[1], 0) // ISO式・月曜始まり
//d.setISOWeek(yearWeek[0], yearWeek[1] - 1, 6) // ISO式・日曜始まり
const dateFormat = "yyyy-MM-dd"
const dayFormat = "ddd"
// ここで返してるものがページのタイトルと本文になるよ! 1週間分の日付と曜日を並べていきます
return `
[**. [${new Date(d.setDate(d.getDate() + 1)).format(dateFormat)}] ${d.format(dayFormat)}]
[MTG] `@ 8:30` プランニング
[**. [${new Date(d.setDate(d.getDate() + 1)).format(dateFormat)}] ${d.format(dayFormat)}]
[**. [${new Date(d.setDate(d.getDate() + 1)).format(dateFormat)}] ${d.format(dayFormat)}]
[MTG] `@ 8:30` 進捗報告
[**. [${new Date(d.setDate(d.getDate() + 1)).format(dateFormat)}] ${d.format(dayFormat)}]
[**. [${new Date(d.setDate(d.getDate() + 1)).format(dateFormat)}] ${d.format(dayFormat)}]
[**. [${new Date(d.setDate(d.getDate() + 1)).format(dateFormat)}] ${d.format(dayFormat)}]
[**. [${new Date(d.setDate(d.getDate() + 1)).format(dateFormat)}] ${d.format(dayFormat)}]
[**. Backlog]
`
})()
週報テンプレートS.js(function() {
Date.prototype.setWeek = function(year, week, day) {
var week1 = new Date(year, 0, 1)
var prevLastDay = new Date(week1.getTime() - 86400000 * (week1.getDay() || 7))
return this.setTime(prevLastDay.getTime() + 86400000 * ((week - 1) * 7 + day))
}
Date.prototype.setISOWeek = function(year, week, day) {
var week1 = new Date(year, 0, 4)
var prevLastDay = new Date(week1.getTime() - 86400000 * (week1.getDay() || 7))
return this.setTime(prevLastDay.getTime() + 86400000 * ((week - 1) * 7 + day))
}
Date.prototype.format = function(format) {
// yyyy, MM, dd, ddd だけ
const days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
return format.replace('ddd', days[this.getDay()])
.replace('yyyy', this.getFullYear())
.replace('MM', ('0' + (this.getMonth() + 1)).slice(-2))
.replace('dd', ('0' + this.getDate()).slice(-2))
}
// 処理ここから
const yearWeek = scrapbox.Page.title.split("'") // 新規ページの仮タイトルから、年と週番号を取得して
const d = new Date()
// 週番号の計算方法をここで指定するよ
//d.setWeek(yearWeek[0], yearWeek[1], 0) // 米国式・月曜始まり
//d.setWeek(yearWeek[0] - 1, yearWeek[1], 6) // 米国式・日曜始まり
d.setISOWeek(yearWeek[0], yearWeek[1], 0) // ISO式・月曜始まり
//d.setISOWeek(yearWeek[0], yearWeek[1] - 1, 6) // ISO式・日曜始まり
const dateFormat = "yyyy-MM-dd"
const dayFormat = "ddd"
// ここで返してるものがページのタイトルと本文になるよ! 1週間分の日付と曜日を並べていきます
return `
[**. [${new Date(d.setDate(d.getDate() + 1)).format(dateFormat)}] ${d.format(dayFormat)}]
[**. [${new Date(d.setDate(d.getDate() + 1)).format(dateFormat)}] ${d.format(dayFormat)}]
[**. [${new Date(d.setDate(d.getDate() + 1)).format(dateFormat)}] ${d.format(dayFormat)}]
[**. [${new Date(d.setDate(d.getDate() + 1)).format(dateFormat)}] ${d.format(dayFormat)}]
[**. [${new Date(d.setDate(d.getDate() + 1)).format(dateFormat)}] ${d.format(dayFormat)}]
[**. [${new Date(d.setDate(d.getDate() + 1)).format(dateFormat)}] ${d.format(dayFormat)}]
[**. [${new Date(d.setDate(d.getDate() + 1)).format(dateFormat)}] ${d.format(dayFormat)}]
[**. Backlog]
`
})()
日誌テンプレート.js// 日誌用テンプレートを生成する
// {前の日付リンク}→前 次→{次の日付リンク}
function yyyymmdd(date, separator) {
const year = date.getFullYear();
const month = (date.getMonth()+1).toString().padStart(2, "0");
const dt = date.getDate().toString().padStart(2, "0");
return year + separator + month + separator + dt;
}
function makeLink(txt) {
return "[" + txt + "]";
}
(function (){
// 新規ページの仮タイトルから、年月日を取得
// yyyy/mm/ddな仮タイトルを想定している
const title = scrapbox.Page.title.split(/[-/]/)
const baseDate = new Date(title[0], title[1] - 1, title[2]);
const yesterday = new Date(baseDate.getTime() - 24 * 60 * 60 * 1000);
const tomorrow = new Date(baseDate.getTime() + 24 * 60 * 60 * 1000);
// セパレータを検出
const separator = scrapbox.Page.title.includes("/") ? "/" : "-";
const text = makeLink(yyyymmdd(yesterday, separator)) + "←前 次→" + makeLink(yyyymmdd(tomorrow, separator));
return `
${text}
#日誌
`
})()
ページテンプレート.js// ページ用のテンプレートを生成する
// Wikipedia形式で参考・関連と分けておくとページが散らかりにくい
/**
* URLのクエリを読めるようにするため特定の文字だけエンコードする
* @param {string} str
* @return {string}
*/
function encode2ReadableQuery(str) {
const specialChars = ' !"#$%&\'()*+,/:;<=>?@[]^`{|}~';
let result = '';
for (let i = 0; i < str.length; i++) {
if (specialChars.indexOf(str[i]) !== -1) {
result += "%" + str.charCodeAt(i).toString(16).substring(-2);
} else {
result += str[i];
}
}
return result;
}
/**
* 文字列の先頭のみ大文字に変換
* @param {string} str 対象の文字列
* @return {string} 変換された文字列を返す
*/
function capitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
}
(function (){
const title = scrapbox.Page.title.trim()
const result1 = confirm("タイトルは日本語?")
const title_ja = (() => {
if (!result1) {
return prompt("日本語タイトルを入力", title)
}
return title
})().trim()
const title_en = (() => {
if (result1) {
return prompt("英語タイトルを入力", title)
}
return title
})().trim()
const title1 = (() => {
if (result1) {
return title_ja + '(' + title_en + ')'
}
return title_en + '(' + title_ja + ')'
})()
const title_underscore_ja = title_ja.replaceAll(/ /g, "_")
const title_underscore_en = title_en.replaceAll(/ /g, "_")
const title_display_en = capitalize(title_en)
const title_plus_ja = title_ja.split(" ").map((x) => {
return encode2ReadableQuery(x)
}).join("+")
const title_plus_en = title_en.split(" ").map((x) => {
return encode2ReadableQuery(x)
}).join("+")
return `
#Fleeting_Notes
${title1}
[* 確認用]
Q. ${title}
[* 調査用]
[/pogi-log/Google.icon] [https://www.google.com/search?q=${title_plus_ja}&gl=jp&hl=ja ${title_ja}(日)]
[/pogi-log/Google.icon] [https://www.google.com/search?q=${title_plus_en}&gl=us&hl=en ${title_display_en}(英)]
[/pogi-log/Wikipedia.icon]
[https://ja.wikipedia.org/wiki/${title_underscore_ja} ${title_ja} - Wikipedia(日)]
[https://ja.wikipedia.org/w/index.php?search=${title_plus_ja}&title=Special:Search&profile=advanced&fulltext=1&ns0=1 ${title_ja}(検索) - Wikipedia(日)]
[/pogi-log/Wikipedia.icon]
[https://en.wikipedia.org/wiki/${title_underscore_en} ${title_display_en} - Wikipedia(英)]
[https://en.wikipedia.org/w/index.php?search=${title_plus_en}&title=Special:Search&profile=advanced&fulltext=1&ns0=1 ${title_display_en}(検索) - Wikipedia(英)]
`
})()
調査用テンプレート.js// 調査用のリンクテンプレート
function encodeReadableQuery(str) {
const specialChars = ' !"#$%&\'()*+,/:;<=>?@[]^`{|}~';
let result = '';
for (let i = 0; i < str.length; i++) {
if (specialChars.indexOf(str[i]) !== -1) {
result += "%" + str.charCodeAt(i).toString(16).substring(-2);
} else {
result += str[i];
}
}
return result;
}
(function (){
const title = scrapbox.Page.title.split("/")
console.log(title)
const title_underscore = title.join(" ").trim().replaceAll(/ /g, "_")
const title_plus = title.join(" ").trim().map((x) => {
return encodeReadableQuery(x)
}).join("+")
return `
[* 調査用]
[/pogi-log/Google.icon] [https://www.google.com/search?q=${title_plus}&gl=jp&hl=ja ${title}]
[/pogi-log/Google.icon] [https://www.google.com/search?q=${title_plus}&gl=us&hl=en ${title}]
[/pogi-log/Wikipedia.icon]
[https://ja.wikipedia.org/wiki/${title_underscore} ${title} - Wikipedia(日)]
[https://ja.wikipedia.org/w/index.php?search=${title_plus}&title=Special:Search&profile=advanced&fulltext=1&ns0=1 ${title}(検索) - Wikipedia(日)]
[/pogi-log/Wikipedia.icon]
[https://en.wikipedia.org/wiki/${title_underscore} ${title} - Wikipedia(英)]
[https://en.wikipedia.org/w/index.php?search=${title_plus}&title=Special:Search&profile=advanced&fulltext=1&ns0=1 ${title}(検索) - Wikipedia(英)]
`
})()
図書館テンプレ.js// テンプレ挿入(所持のところを自分の名前に)
(function (){
const temp = "著者:\n訳者:\n版元:\n発行年:\n頁数:\n形態:\n流通:\n定価:\n所持:[pogin503.icon]\n\n#文献";
return `
${temp}
`
})()
論文用テンプレ(落合式).js(function (){
return `
1. どんなもの?
2. 先行研究と比べてどこがすごい?
3. 技術や手法のキモはどこ?
4. どうやって有効だと検証した?
5. 議論はある?
6. 次に読むべき論文は?
[* 確認用]
Q.
#論文読み #論文 #文献
`
})()