Skip to content

Commit

Permalink
remove pic_base_url.
Browse files Browse the repository at this point in the history
  • Loading branch information
Doradx committed Sep 6, 2023
1 parent bc9d1a2 commit cb112a2
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 33 deletions.
4 changes: 0 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ inputs:
```
详见: https://picgo.github.io/PicGo-Core-Doc/zh/guide/config.html#%E6%89%8B%E5%8A%A8%E7%94%9F%E6%88%90
default: "{}"
pic_base_url:
description: |
图床的基础链接, 例如: https://i.blog.com/image/, 如填写此链接, 在图片上传图床前, 会检查该图片是否已经上传过, 如已上传则跳过, 提升效率。
default: "false"
pic_compress:
description: |
是否开启图片压缩?true为开启, 默认不开启
Expand Down
31 changes: 18 additions & 13 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -282187,7 +282187,6 @@ const imageminGifsicle = __nccwpck_require__(60006);
const imageminSvgo = __nccwpck_require__(14038);



async function migrateNotionImageFromURL(ctx, url) {
// 检查图片是否为notion的图片
const urlReg = /^https:\/\/.*?amazonaws\.com\/.+\.(?:jpg|jpeg|bmp|tif|tiff|svg|png|gif|webp)\?.+/;
Expand All @@ -282200,8 +282199,8 @@ async function migrateNotionImageFromURL(ctx, url) {
const uuidreg = /[a-fA-F0-9]{8}-(?:[a-fA-F0-9]{4}-){3}[a-fA-F0-9]{12}/g;
const uuid = url.match(uuidreg)?.pop();
const ext = url.split('?')[0].split('.').pop()?.toLowerCase();
const picUrl = `${base_url}${uuid}.${ext}`;
if (base_url) {
const picUrl = new URL(`${uuid}.${ext}`, base_url).href;
// get pic uuid from the url using regex
if (await checkPicExist(ctx, picUrl)) {
// console.log(`Image ${picUrl} already exists, skip`)
Expand Down Expand Up @@ -282371,7 +282370,6 @@ let config = {
clean_unpublished_post: true,
},
timezone: "Asia/Shanghai",
pic_base_url: "",
pic_compress: false,
last_sync_datetime: 0,
keys_to_keep: [],
Expand All @@ -282390,11 +282388,16 @@ function init(conf) {
}
});

const domain = new URL(config.pic_base_url).hostname;
if (!config?.pic_base_url && config.picBed?.uploader) {
const bed = config.picBed[config.picBed?.uploader]
if (bed?.customUrl && bed?.path) {
config.pic_base_url = new URL(bed.path, bed.customUrl).href;
}
}

let picgo_config = {
"picBed": config.picBed,
"pic-base-url": config.pic_base_url || null
"pic-base-url": config?.pic_base_url || null
}

picgo_config["compress"] = config.pic_compress ? true : false;
Expand Down Expand Up @@ -282953,6 +282956,14 @@ module.exports = require("https");

/***/ }),

/***/ 31405:
/***/ ((module) => {

"use strict";
module.exports = require("inspector");

/***/ }),

/***/ 98188:
/***/ ((module) => {

Expand Down Expand Up @@ -305372,7 +305383,6 @@ var __webpack_exports__ = {};
const notion = __nccwpck_require__(64281);
const core = __nccwpck_require__(45463);


function isJson(str) {
try {
const obj = JSON.parse(str);
Expand All @@ -305397,12 +305407,6 @@ if (migrate_image) {
pic_bed_config = JSON.parse(picBedConfigStr);
}

var pic_base_url = core.getInput("pic_base_url") || null;

if (pic_base_url && !pic_base_url.endsWith("/")) {
pic_base_url = pic_base_url + "/";
}

var keys_to_keep = core.getInput("keys_to_keep");
if (keys_to_keep && keys_to_keep.trim().length > 0) {
keys_to_keep = keys_to_keep.split(",").map((key) => key.trim());
Expand All @@ -305413,7 +305417,6 @@ let config = {
database_id: core.getInput("database_id"),
migrate_image: migrate_image || false,
picBed: pic_bed_config || {},
pic_base_url: pic_base_url || null,
pic_compress: core.getInput("pic_compress") === "true" || false,
status: {
name: core.getInput("status_name") || "status",
Expand All @@ -305433,6 +305436,8 @@ let config = {
process.env.PATH = __dirname + ":" + process.env.PATH;
// add all the exec file under __dirname/vendor* dirs the executable permission expect the source dir
const { execSync } = __nccwpck_require__(32081);
const { url } = __nccwpck_require__(31405);
const { BADFAMILY } = __nccwpck_require__(9523);
// try to find all the files under __dirname/vendor* dirs and set the executable permission
try {
execSync(`find ${__dirname}/vendor* -type f -not -name "*.tar.gz" -exec chmod +x {} \\;`);
Expand Down
Binary file added dist/vendor1/cjpeg
Binary file not shown.
Binary file removed dist/vendor1/gifsicle
Binary file not shown.
Binary file removed dist/vendor1/source/gifsicle-1.92.tar.gz
Binary file not shown.
Binary file added dist/vendor1/source/mozjpeg.tar.gz
Binary file not shown.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "notion2markdown-action",
"version": "0.7.4",
"version": "0.7.5",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
10 changes: 2 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
const notion = require("./notion");
const core = require("@actions/core");


function isJson(str) {
try {
const obj = JSON.parse(str);
Expand All @@ -36,12 +35,6 @@ if (migrate_image) {
pic_bed_config = JSON.parse(picBedConfigStr);
}

var pic_base_url = core.getInput("pic_base_url") || null;

if (pic_base_url && !pic_base_url.endsWith("/")) {
pic_base_url = pic_base_url + "/";
}

var keys_to_keep = core.getInput("keys_to_keep");
if (keys_to_keep && keys_to_keep.trim().length > 0) {
keys_to_keep = keys_to_keep.split(",").map((key) => key.trim());
Expand All @@ -52,7 +45,6 @@ let config = {
database_id: core.getInput("database_id"),
migrate_image: migrate_image || false,
picBed: pic_bed_config || {},
pic_base_url: pic_base_url || null,
pic_compress: core.getInput("pic_compress") === "true" || false,
status: {
name: core.getInput("status_name") || "status",
Expand All @@ -72,6 +64,8 @@ let config = {
process.env.PATH = __dirname + ":" + process.env.PATH;
// add all the exec file under __dirname/vendor* dirs the executable permission expect the source dir
const { execSync } = require("child_process");
const { url } = require("inspector");
const { BADFAMILY } = require("dns");
// try to find all the files under __dirname/vendor* dirs and set the executable permission
try {
execSync(`find ${__dirname}/vendor* -type f -not -name "*.tar.gz" -exec chmod +x {} \\;`);
Expand Down
3 changes: 1 addition & 2 deletions src/migrateNotionImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const imageminGifsicle = require("imagemin-gifsicle");
const imageminSvgo = require("imagemin-svgo");



async function migrateNotionImageFromURL(ctx, url) {
// 检查图片是否为notion的图片
const urlReg = /^https:\/\/.*?amazonaws\.com\/.+\.(?:jpg|jpeg|bmp|tif|tiff|svg|png|gif|webp)\?.+/;
Expand All @@ -33,8 +32,8 @@ async function migrateNotionImageFromURL(ctx, url) {
const uuidreg = /[a-fA-F0-9]{8}-(?:[a-fA-F0-9]{4}-){3}[a-fA-F0-9]{12}/g;
const uuid = url.match(uuidreg)?.pop();
const ext = url.split('?')[0].split('.').pop()?.toLowerCase();
const picUrl = `${base_url}${uuid}.${ext}`;
if (base_url) {
const picUrl = new URL(`${uuid}.${ext}`, base_url).href;
// get pic uuid from the url using regex
if (await checkPicExist(ctx, picUrl)) {
// console.log(`Image ${picUrl} already exists, skip`)
Expand Down
10 changes: 7 additions & 3 deletions src/notion.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ let config = {
clean_unpublished_post: true,
},
timezone: "Asia/Shanghai",
pic_base_url: "",
pic_compress: false,
last_sync_datetime: 0,
keys_to_keep: [],
Expand All @@ -57,11 +56,16 @@ function init(conf) {
}
});

const domain = new URL(config.pic_base_url).hostname;
if (!config?.pic_base_url && config.picBed?.uploader) {
const bed = config.picBed[config.picBed?.uploader]
if (bed?.customUrl && bed?.path) {
config.pic_base_url = new URL(bed.path, bed.customUrl).href;
}
}

let picgo_config = {
"picBed": config.picBed,
"pic-base-url": config.pic_base_url || null
"pic-base-url": config?.pic_base_url || null
}

picgo_config["compress"] = config.pic_compress ? true : false;
Expand Down

0 comments on commit cb112a2

Please sign in to comment.