当前位置: 首页 > wzjs >正文

县城乡建设局网站wordpress输出外部文章

县城乡建设局网站,wordpress输出外部文章,做网站录入和查询需求,设计图片网站哪个好一、背景 当我们使用Joplin时,上传图片时会自动上传到Joplin服务器并替换链接 但是Joplin的编辑器不好用,我更习惯用Typora来编辑, 然而Typora中上传的图片只能在本地,无法上传到Joplin服务器,在其他客户端也看不到图片…

一、背景

当我们使用Joplin时,上传图片时会自动上传到Joplin服务器并替换链接

但是Joplin的编辑器不好用,我更习惯用Typora来编辑,

然而Typora中上传的图片只能在本地,无法上传到Joplin服务器,在其他客户端也看不到图片

本文编写了一个脚本,通过Typora的上传服务器功能,自动上传图片并替换为Joplin链接

二、准备脚本

2.1 第一个脚本,修改token

token可以在网页剪藏器中获取

在这里插入图片描述

import requests
import sys
import json
import subprocess# 修改为你的token
token = "请修改我"
# WARNING: replace 41184 with your joplin web clipper port
port = 41184
# 修改为你的python路径
python_exe_path = r'C:\Users\realw\AppData\Local\Microsoft\WindowsApps\python.exe'
# 修改为你的第二个脚本路径
second_script_path = r'D:\app\Typora\job\typora-windows-2.py'# collect args for typora-windows-2.py
args = []
for arg in sys.argv:# the first arg is .py file, ignore itif(".py" in arg):continue# the second arg is the current editing file passed by Typoraif(".md" in arg):args.append(arg)continue# other arg is the local Typora-Image path passed by Typoraurl = "http://127.0.0.1:" + str(port) + "/resources/?token=" + tokenpayload = {'props': '{}'}files = [('data', ('typora.png', open(arg, 'rb'), 'image/png'))]headers = {}# upload your images to joplin resources using joplin web clipper APIresponse = requests.request("POST", url, headers=headers, data=payload, files=files)newFilePath = "http://127.0.0.1:" + str(port) + "/resources/" + json.loads(response.text)["id"] + "/file?token=" + token# print newFilePath, so Typora can replace the local-typora-image path with the joplin web clipper url.# We cannot directly use "resources/" + json.loads(response.text)["id"] + ".png" since Typora thinks it is an illegal URL,# and a warning will show up.print(newFilePath)args.append(newFilePath)args.append("resources/" + json.loads(response.text)["id"] + ".png")# first arg is .py file, second arg is .md file, then newFilePath and "resources/" + json.loads(response.text)["id"] + ".png" appear in order
# We use subprocess because Typora will wait for the result of the first script and then replace the Typora_local_path with newFilePath.
# If we don't use subprocess, our replacement will be ahead of Typora's, and covered by Typora, which makes newFilePath as the final result link.
# This is not what we want, we want "resources/" + json.loads(response.text)["id"] + ".png" as the result.
subprocess.Popen([python_exe_path, second_script_path] + args, creationflags=subprocess.DETACHED_PROCESS, shell=False)sys.exit()

2.1 准备第二个脚本,按需修改delay时间

import sys
import time# We need to wait Typora's replacement happens first
delay_time = 5# Typora 将 typora-local-image-link 替换为 web-clipper-link 后,
# 而您没有按“ctrl + s”保存,您的内容不会“提交”到当前文件,
# 这使得 python 无法检测到 web-clipper-link 并将其替换为 joplin-resources-link。
# 因此我们至少重试该函数 10 次以等待您的保存。(如果您在 50 秒内没有按“ctrl + s”保存,则替换将失败)
retry_times = 10
time.sleep(delay_time)for i in range(retry_times):try:with open(sys.argv[1], 'r+', encoding='utf-8') as file:file_content = file.read()file_content_copy = file_contentfor index, arg in enumerate(sys.argv):if ((".png" in arg) or (".md" in arg) or (".py" in arg)):continue# replace newFilePath with "resources/{id}.png"file_content = file_content.replace(sys.argv[index], sys.argv[index + 1])file.seek(0)file.write(file_content)file.truncate()time.sleep(delay_time)except Exception as e:print(f"An error occurred: {e}")time.sleep(delay_time)
sys.exit()

3. 修改Typora配置

在这里插入图片描述

选择图象,上传服务,命令,确保你的python环境和模块正确

python D:\app\Typora\job\typora-windows.py ${filepath}

点击验证图片上传
在这里插入图片描述

4 在编辑器内测试

用法:

在编辑器内粘贴图片,按下ctrl+s 保存,等待几秒后自动替换为内部连接,大公告成

如果遇到问题,可以手动点击上传图片,检查顶部报错

在这里插入图片描述


文章转载自:

http://nXIbFD9o.Ldqzz.cn
http://XpBTahaY.Ldqzz.cn
http://GR78mq4G.Ldqzz.cn
http://fjmf0OZG.Ldqzz.cn
http://l1Ehbxrq.Ldqzz.cn
http://ntI2bwP2.Ldqzz.cn
http://Vb0lTKHs.Ldqzz.cn
http://y5HCNTxy.Ldqzz.cn
http://kfiaIUPc.Ldqzz.cn
http://mEEQCSfB.Ldqzz.cn
http://bIVd6yyd.Ldqzz.cn
http://ST7ruNiR.Ldqzz.cn
http://d5D48ZZx.Ldqzz.cn
http://Ps0MkOTN.Ldqzz.cn
http://rXSXP1S2.Ldqzz.cn
http://yc1mQvcP.Ldqzz.cn
http://bAqeZUEX.Ldqzz.cn
http://pLlj0fT6.Ldqzz.cn
http://X4snd41d.Ldqzz.cn
http://P5OvYMr6.Ldqzz.cn
http://DXE2b65v.Ldqzz.cn
http://lSLmJKgK.Ldqzz.cn
http://nMOF5jBS.Ldqzz.cn
http://RouRcN12.Ldqzz.cn
http://NZtFxX9C.Ldqzz.cn
http://ISbrvmSZ.Ldqzz.cn
http://DmDmki14.Ldqzz.cn
http://wwgqtsCl.Ldqzz.cn
http://ixmGMfSk.Ldqzz.cn
http://MnOHznEV.Ldqzz.cn
http://www.dtcms.com/wzjs/683776.html

相关文章:

  • 仿网站建设教程视频中交建设集团 网站
  • 网站制作商seo文章排名优化
  • 制作xml网站地图文件中国商标注册网
  • 网站设计的基本知识结构wordpress使用手册
  • 商务酒店网站建设惠州市博罗县建设局网站
  • 网站建设技术服务税种分类做阅读理解的网站
  • 自己做的网站怎么接入网页游戏教学信息化大赛网站建设作品
  • 做彩票网站违法吗怎么做网站主导航
  • 网站制作案例wordpress 菜单设置
  • 网站建设开票属于什么服务网络推广活动具体实施方案
  • 有没有一种app类似网站建设网站开发全程实例
  • 网站建设有没有资质俄罗斯网络公司排名
  • 莒南县建设局网站如何建设网站教育
  • 成都网站建设开发价报社网站建设方案
  • 网站怎么推广比较好wordpress设置网站地址
  • 模板网站好还是定制网站好福州企业网站建设推广
  • 设置一个网站到期页面广告营销平台
  • 单位建网站怎么做wordpress页面属性模板
  • 网站制作需要哪些软件有哪些上海互联网推广找哪家
  • 自由策划企业网站管理系统破解版程序员参与洗钱网站建设
  • 怎么做免费网站wordpress站点跟换域名
  • 花都区水务建设管理中心官方网站公众号开发者平台
  • 网站系统搭建前端工程师招聘
  • 搜狐快站官网太原网站模板公司
  • 淘宝客返利网站开发设计师导航
  • 淮北市住房和城乡建设局网站win10怎么删除2345网址导航
  • 虚拟货币网站建设班级设计网站建设
  • 如何整合网站直播视频软件哪个好
  • 移动端手机网站制作科技有限公司最低注册资金
  • 瑞安规划建设局网站抖音代运营服务流程