Skip to content

Commit

Permalink
Merge pull request #379 from imdone/1.41.1
Browse files Browse the repository at this point in the history
1.41.1
  • Loading branch information
piascikj authored May 29, 2024
2 parents 15b86c8 + 6f6640a commit 30f076c
Show file tree
Hide file tree
Showing 19 changed files with 1,099 additions and 30 deletions.
1 change: 1 addition & 0 deletions .imdone/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ settings:
appendNewCardsTo: imdone-tasks.md
newCardSyntax: MARKDOWN
replaceSpacesWith: '-'
noDST: false
plugins:
devMode: false
imdone-sample-plugin:
Expand Down
106 changes: 106 additions & 0 deletions .imdone/plugins/imdone-card-link-plugin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

.imdone/plugins
3 changes: 3 additions & 0 deletions .imdone/plugins/imdone-card-link-plugin/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
imdone-tasks.md
main.js
.imdone
21 changes: 21 additions & 0 deletions .imdone/plugins/imdone-card-link-plugin/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 imdone

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions .imdone/plugins/imdone-card-link-plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# imdone-card-link-plugin

This plugin adds a card action to copy a card markdown link to the clipboard.
140 changes: 140 additions & 0 deletions .imdone/plugins/imdone-card-link-plugin/bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
'use strict';

var crypto = require('crypto');

var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};

function getDefaultExportFromCjs (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}

var plugin = {exports: {}};

(function (module, exports) {
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Plugin = void 0;
class Plugin {
constructor(project) {
this.project = project;
this.unimplWarning = {};
}
destroy() { }
onBeforeAddTask(request) {
return __awaiter(this, void 0, void 0, function* () {
this.unimplemented('onBeforeAddTask()');
const { path, list, content, meta, tags, contexts } = request;
return { path, content, meta, tags, contexts };
});
}
onBeforeBoardUpdate() {
this.unimplemented('onBeforeBoardUpdate()');
}
onBoardUpdate(lists) {
this.unimplemented('onBoardUpdate(lists: Array<List>)');
}
onTaskUpdate(task) {
this.unimplemented('onTaskUpdate(task: Task)');
}
onAfterDeleteTask(task) {
this.unimplemented('onAfterDeleteTask(task: Task)');
}
getCardProperties(task) {
this.unimplemented('getCardProperties(task: Task)');
return {};
}
getCardActions(task) {
this.unimplemented('getCardActions(task: Task)');
return [];
}
getBoardActions() {
this.unimplemented('getBoardActions()');
return [];
}
getSettingsSchema() {
this.unimplemented('getSettingsSchema()');
return null;
}
getSettings() {
return null;
}
unimplemented(signature) {
if (this.unimplWarning[signature])
return;
console.info(`${this.constructor.name}.${signature} is not implemented.`);
this.unimplWarning[signature] = true;
}
}
exports.Plugin = Plugin;
(module).exports = Plugin;
}(plugin, plugin.exports));

var Plugin = /*@__PURE__*/getDefaultExportFromCjs(plugin.exports);

const urlAlphabet =
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';

const POOL_SIZE_MULTIPLIER = 128;
let pool, poolOffset;
let fillPool = bytes => {
if (!pool || pool.length < bytes) {
pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER);
crypto.randomFillSync(pool);
poolOffset = 0;
} else if (poolOffset + bytes > pool.length) {
crypto.randomFillSync(pool);
poolOffset = 0;
}
poolOffset += bytes;
};
let nanoid = (size = 21) => {
fillPool((size -= 0));
let id = '';
for (let i = poolOffset - size; i < poolOffset; i++) {
id += urlAlphabet[pool[i] & 63];
}
return id
};

class CardLinkPlugin extends Plugin {

constructor (project) {
super(project);
}

getCardActions (task) {
const project = this.project;
const actions = [
{
title: 'Copy card markdown link to clipboard',
action: () => {
let sid = task.meta.sid && task.meta.sid[0];
if (!sid) {
sid = nanoid();
project.addMetadata(task, 'sid', sid);
}
const url = `imdone://card.select/${project.path}?sid=${sid}`;
const link = `[${task.text}](${url})`;
return project.copyToClipboard(
link,
`Card markdown link copied to clipboard`
)
},
icon: 'clone',
pack: 'fas'
}
];
return actions
}

}

module.exports = CardLinkPlugin;
35 changes: 35 additions & 0 deletions .imdone/plugins/imdone-card-link-plugin/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import Plugin from 'imdone-api'
import { nanoid } from 'nanoid'

export default class CardLinkPlugin extends Plugin {

constructor (project) {
super(project)
}

getCardActions (task) {
const project = this.project
const actions = [
{
title: 'Copy card markdown link to clipboard',
action: () => {
let sid = task.meta.sid && task.meta.sid[0]
if (!sid) {
sid = nanoid()
project.addMetadata(task, 'sid', sid)
}
const url = `imdone://card.select/${project.path}?sid=${sid}`
const link = `[${task.text}](${url})`
return project.copyToClipboard(
link,
`Card markdown link copied to clipboard`
)
},
icon: 'clone',
pack: 'fas'
}
]
return actions
}

}
Loading

0 comments on commit 30f076c

Please sign in to comment.