-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
225 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,7 +89,6 @@ out | |
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
/* | ||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD | ||
if you want to view the source, please visit the github repository of this plugin | ||
*/ | ||
|
||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
|
||
// main.ts | ||
var main_exports = {}; | ||
__export(main_exports, { | ||
FileWriter: () => FileWriter, | ||
default: () => MyPlugin, | ||
slugify: () => slugify | ||
}); | ||
module.exports = __toCommonJS(main_exports); | ||
var import_obsidian = require("obsidian"); | ||
|
||
// settings.ts | ||
var DEFAULT_SETTINGS = { | ||
mySetting: "default", | ||
actionHeading: "popclip", | ||
action: "advanced-uri" | ||
}; | ||
var CUSTOM_SETTINGS = { | ||
useFrontmatter: true, | ||
useHeader: true | ||
}; | ||
var SETTINGS = { | ||
...DEFAULT_SETTINGS, | ||
...CUSTOM_SETTINGS | ||
}; | ||
|
||
// main.ts | ||
var MyPlugin = class extends import_obsidian.Plugin { | ||
async onload() { | ||
await this.loadSettings(); | ||
this.registerObsidianProtocolHandler(SETTINGS.action, async (ev) => { | ||
if (ev.heading === SETTINGS.actionHeading) { | ||
new FileWriter(this.app).writeToFile( | ||
JSON.parse(ev.data) | ||
); | ||
} | ||
}); | ||
} | ||
onunload() { | ||
} | ||
async loadSettings() { | ||
this.settings = Object.assign({}, SETTINGS, await this.loadData()); | ||
} | ||
async saveSettings() { | ||
await this.saveData(this.settings); | ||
} | ||
async activateView() { | ||
} | ||
}; | ||
var FileWriter = class { | ||
constructor(app) { | ||
this.app = app; | ||
} | ||
async writeToFile(payload) { | ||
const path = this.normalizePath(payload); | ||
this.app.vault.create((0, import_obsidian.normalizePath)(path), this.setContent(payload)); | ||
} | ||
normalizePath(payload) { | ||
const fileName = payload.title && typeof payload.title === "string" && payload.title.length < 60 ? payload.title : this.normalizeDate(); | ||
let filePath = decodeURIComponent(payload.path) || ""; | ||
console.log(payload.path, filePath); | ||
const path = slugify(`${filePath.trim()}/${fileName.trim()}`) + ".md"; | ||
return path; | ||
} | ||
normalizeDate() { | ||
const datetime = new Date().toISOString().split(".")[0]; | ||
return datetime.replaceAll("-", "").replaceAll(":", "").replace("t", ""); | ||
} | ||
setFrontmatter(payload) { | ||
const elements = [ | ||
"---", | ||
`title: "${payload == null ? void 0 : payload.title}"`, | ||
`source: ${(payload == null ? void 0 : payload.source) || ""}`, | ||
`date: ${new Date().toISOString()}`, | ||
"---" | ||
]; | ||
return elements.join("\n"); | ||
} | ||
setHeader(payload) { | ||
return `# ${payload == null ? void 0 : payload.title}`; | ||
} | ||
setContent(payload) { | ||
const elements = [ | ||
this.setFrontmatter(payload), | ||
this.setHeader(payload), | ||
payload == null ? void 0 : payload.clipping | ||
]; | ||
return elements.join("\n\n"); | ||
} | ||
}; | ||
function slugify(str) { | ||
str = str.replace(/^\s+|\s+$/g, ""); | ||
str = str.toLowerCase(); | ||
var from = "\u0131\xFC\xF6\xE7\u011F\xE0\xE1\xE4\xE2\xE8\xE9\xEB\xEA\xEC\xED\xEF\xEE\xF2\xF3\xF6\xF4\xF9\xFA\xFC\xFB\xF1\xE7\xB7/_,:;"; | ||
var to = "iuocgaaaaeeeeiiiioooouuuunc------"; | ||
for (var i = 0, l = from.length; i < l; i++) { | ||
str = str.replace(new RegExp(from.charAt(i), "g"), to.charAt(i)); | ||
} | ||
str = str.replace(/[^a-z0-9 -]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-"); | ||
if (str.startsWith("-")) { | ||
str = str.substring(1); | ||
} else if (str.endsWith("-")) { | ||
str = str.substring(0, str.length - 1); | ||
} | ||
return str; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"id": "popclip", | ||
"name": "Popclip", | ||
"version": "1.0.0", | ||
"minAppVersion": "0.15.0", | ||
"description": "This plugin sent the text you selected to Obsidian. It requires you to install Popclip MacOS app and and Obsidian extension for that .", | ||
"author": "Can Burak Sofyalıoğlu", | ||
"authorUrl": "https://[email protected]/", | ||
"fundingUrl": "", | ||
"isDesktopOnly": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
This CSS file will be included with your plugin, and | ||
available in the app when your plugin is enabled. | ||
If your plugin does not need CSS, delete this file. | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters