1 Star 16 Fork 5

晓凹凸曼 / push-markdown

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

Push Markdown

License

此代码是基于Publish Markdown重构的。

原代码地址:https://github.com/jzj1993/PublishMarkdown

软件更新地址:http://download.szx.life/push-markdown

使用前务必先查看使用教程!!!

使用前务必先查看使用教程!!!

使用前务必先查看使用教程!!!

背景

由于原来的代码并没有进行更新维护,框架可能有点老,而且有时候有bug,因此萌生了用基于electron13、vue3和TypeScript重构代码的想法。

由于我本人并不会electron开发和vue开发,算是半个开发小白,所以也想借助最近搭建博客的热情来顺便重构一下这款软件的代码。毕竟兴趣是最好的老师,而且在别人的基础上前行,也是能够进步非常快的,希望我能够真正的完成这款软件的重构,一步一步个脚印,无限进步吧!

软件简介

Push Markdown 是一款将本地Markdown文件发布到Wordpress和cnblogs的开源工具,基于Electron实现,支持中英文,目前仅有windows安装包,无mac电脑来编译macos平台。

  1. 支持主流Markdown语法、TOC、代码高亮、MathJax数学公式,支持本地预览和简易编辑功能(建议使用Haroopad、Typora等工具编写好后,再使用本工具发布)。
  2. 全自动博客发布。博客可设置标题、摘要、固定链接、作者、发布时间、标签、分类等属性,自动批量上传markdown文件中引用的本地图片。
  3. 对文章上传逻辑和图片上传逻辑进行了优化,不仅只依赖本地缓存,这样能适应多台设备和新装软件的情况,详情逻辑可以查看我的技术博客

欢迎界面

使用事项

注意

  • 务必先查看使用教程!!!
  • 版本2.X与1.X不兼容!版本2.0.X和2.1.X不兼容!
  • 已知:与WP Editor.md插件会有冲突,需要禁用此插件!!!
  • CDN设置了IP访问限频配置,访问阈值设请不要设置太低。访问阈值就是每秒钟访问网页的次数。由于图片上传逻辑中,会检测网页中的图片是否还存在,因此当文档的图片太多时,很可能检测的次数会超过这个CDN设置的访问阈值,导致检测失败,强制更新图片,这样子会造成的一定的流量浪费并延长上传时间。
  • 注意锚点的使用,建议按照规范来,最好不要出现标点符号,虽然我们已经做过适配了。空格使用短横杠 "-" ,英文字母小写。如果有想要typora中tab的效果,请使用全角空格进行替代。
  • 每次更新了wordpress,都需要重新运行脚本替换

出错

打开文档失败或者上传错误,请按照以下的顺序查找问题。

  1. 认真阅读使用教程🙂

  2. 请认真看准当前的版本,软件-帮助-关于可以查看当前版本,每个版本的使用可能有具体差异,可以在gitee或者github的左上角切换tags,到对应的版本查看使用教程。不过建议一直保持最新的,然后查看最新使用说明即可!

  3. 如果是图片上传错误,看看脚本是否替换成功了,具体看使用教程的脚本替换。

  4. 如果是打开文档失败,看看文件的最上面的yaml有没有写错,尽量把所有的参数都写上,可以为空,但是参数名尽量留着,具体文章可以参照软件里的 帮助-查看示例文档

    ---
    title: push-markdown(这个名称最好有)
    
    abstract: (可以为空)
    
    url: (可以为空,自动提取默认的title的拼音,个人建议为空)
    
    date: (可以为空,默认为上传的时间)
    
    category:
    - 分享(或者为空)
    
    tags:
    - bala(或者为空)
    
    thumbnail: (可以为空,或者填写本地图片的路径,上传图片的时候同时设置文章头图)
    
    other_images:
    - (上传一些本文章正文用不到的图片到wordpress,如果无特殊需求的话,不建议使用这个字段)
    
    ---
  5. 上传失败有多个因素,可能网络的问题,还有可能wordpress插件的问题,可以先关掉所有的wordpress的插件试试看。比如上述说的WP Editor.md插件,这个插件将wordpress的编辑器改成支持Markdown编辑器的,但是他对文章ID进行了一波改动,导致旧文章的更新不是沿用原来的文章ID,而是用了新的文章ID,这对本软件是致命打击,因为本软件创建新的文章之后,会保存返回的文章ID,留着下次更新旧文章使用,因此需要禁用这类软件(再说用了这个上传markdown的软件,就不用这个插件编辑器了吧,二选一就行了)。

  6. 如果自动模式发布出错了,尝试使用手动模式看看,指定文章ID强制覆盖试试看。

  7. 尝试打开软件的开发者工具,在菜单栏的窗口里面,看看有没有明显错误。

  8. 有多个博客站点的话可能会有问题,因为我没有多个博客,所以无法测试,建议就只使用一个博客。

  9. 都不行的话,发issue寻求作者帮忙解决吧(作者不一定能解决😁)

其他文档

心得体会

项目搭建

push-markdown 示例文档 – 巷子深的生活 (szx.life)

特别感谢vite-electron-builder模版,对我2.0.0升级有着举足轻重的作用

重要版本

v2.1.2

  • 修复批量上传有日期字段无法上传成功的问题

v2.1.1

  • 添加批量上传界面,在文件-批量上传中,使用前建议看看注意事项
  • 修复关闭当前页面左侧的页面,导致后续页面重新读取渲染的问题(vue的v-for索引key值的问题,经典问题)
  • 修复外链图片没有加上fancybox的问题(仅支持argon主题)

v2.1.0

  • 添加设置文章头图,可以在上传的时候直接设置头图,只需要在文件头部的参数中加入thumbnai和图片路径即可
  • 不支持外链图片设置特色图片!xmlrpc的wp_thumbnail_id只支持wordpress的图片ID,不能设置为链接!wordpress默认也不支持特色图片外链!
  • 注意:此版本的数据结构与2.0.X不一致,都赖作者没有做好规划!建议重新导入数据,看使用教程的说明!

v2.0.2

  • 再次紧急修复一下slugify,现在标题是中文和英文混合的模式,中间会有横杠,因为transliteration这个库有点问题,不仅有数字和中文混合缺少斜杠的问题,现在发现中文和英文也有混合的问题,因此使用了两个slugify的库,一个先翻译,一个再进行正常的横杠拼接。
  • 可能会导致之前的中文和英文混合的标题文章无法找到本地缓存ID了,实在是非常抱歉,建议去设置里面,打开文件,手动更改一下文章的url。

v2.0.1

  • 再次优化发布逻辑,之前的比较冗余,自动模式直接根据本地缓存发编辑或者发布,不再去获取一遍文章,速度再次提升
  • 文章url的slugify再次变动,数字前后也加上短杠,回归1.x模式
  • 检查更新和关于的图标显示修正

v2.0.0

  • 注意:这个版本和1.x不兼容,建议安装前先卸载1.x,安装完2.x去设置里面重置一下,并且wordpress替换脚本也变了!!需要重新换成新的脚本,具体看使用教程

  • 这个版本主要针对项目结构、代码结构等进行调整(不敢说是优化)

  • 包管理从yarn更换到pnpm,打包工具从vue/cli升级到vite3,AnyScript升级到TypeScript,Vue3写法更新到Vue3组件式API写法,electron更新到20

  • 稍微美化界面样式,带来了全新的暗黑模式(手机厂商营销术语)

  • 添加一键导入博客文章配置的方法,超实用!具体看使用教程

  • 可以打开设置文件,查看相关的信息,也可以手动更改一些配置

  • 发布逻辑微调,不需要发布的时候再次渲染,减少性能消耗,加快发布时间

  • 应用支持检查更新,在帮助-检查更新

v1.2.8

  • 图片恢复能够预览放大(需要搭配argon主题的fancybox)
  • sample文档图片换源到github(gitee不允许外链了)
  • electron更新到18

v1.2.7

  • 新增渲染任务列表
  • 设置界面添加防抖函数(没啥大用,主要为了凑够两条更新)

v1.2.6

  • 新增鼠标中键和右键关闭文件
  • 新增设置摘要提取的字数
  • 修复关闭当前第一个界面,文件列表没有刷新的bug

v1.2.5

  • 新增关键当前文件和重新加载文件的快捷键
  • 根据当前打开文件的本地缓存的文件ID来自动判断发布模式
  • 半修复文件重新刷新而导致的bug(需要先保存文件,或者关闭文件)
  • electron更新到17

v1.2.4

  • 去掉/优化滚动条样式
  • 在发布界面显示本地缓存的文章ID

v1.2.3

  • 文件排序按照自然人的理解,即字符串中含有数字,将按照数字大小排序
  • 刷新时状态栏给出提示
  • 上传每张图片的时候状态栏给出提示

v1.2.2

  • 自动检测新增不检查网络图片,仅利用本地缓存,大大加快发布速度
  • 手动发布新增使用远程文章的网络图片来更新本地缓存,具体看使用教程

v1.2.1

  • 再次修复锚点的问题(每次修复锚点都会有新的bug)
  • 修改刷新文件的逻辑,不再卡顿,变得丝滑

v1.2.0

  • 软件适配macos
  • 博客适配cnblogs博客园
  • 新增主题切换,多款主题任你挑选
  • 新增侧边文件资源管理栏,可以快速打开同级目录下的文件
  • 修复本地锚点中有中英文标点符号不能跳转的问题
  • 修复图片绝对路径使用\作为分隔符不能正常显示的问题
  • 修复了图片名称中含有中文从而导致网络检测失败的问题
  • 美化了滚动条
  • 修复滚动条高度不对的bug
  • 修复界面文本框拖拽的问题
  • 更新了使用文档
  • electron升级到16

v1.1.2

  • 新增url拼音转换,当url设置为空时,会将标题转换为拼音url格式
  • 更新了一波依赖,electron升级到15.2(腹泻式更新)

v1.1.1

  • 限制electron只能开一个应用
  • 更换sample文档的网络图片源地址,垃圾github加载不出来
  • 修复修改wordpress的脚本错误

v1.1.0

  • 将electron升级为14(是的,我是个升级怪)
  • 半修复锚点,如果想实现tab的效果,那么需要用全角中文来替换标题
  • 加入一键重载的按钮,原理很简单,先关闭再打开(懒)
  • 将tab转换为全角空格,因为这样子源码好看点,没有丑陋的emsp
  • 重新加入MathJax,有万能的markdown-it库,直接搞定。

v1.0.6

​ 这版主要是修复bug

  • 将webSecurity重新改为true,相关的网络操作提前在preload里加载,舒服了。
  • 半修复TOC目录代码,在软件里依旧不能跳转,但上传到博客后能够正确跳转,后续可能不修复了,毕竟TOC目录没有必要,typora会自动生成,我的博客也会自动生成。
  • 修复点击示例文档没有相关文件。
  • 修复主页点击sample样例没有反应。
  • 修复点击外链是页内跳转的问题。

v1.0.5

  • 图片居中
  • 修复tab转换为emsp的问题,之前为全局替换,会把代码的tab也给替换,现在只替换普通文本的tab
  • 新增脚本替换Wordpress
  • 修复保存标签栏的历史状态bug
  • 修复没有修改状态的保存

v1.0.4

​ 对图片上传的逻辑进行了优化,也是因为多台设备和远程可能删除篡改图片的问题。

​ 现在的逻辑是如果在手动模式下,选择了强制更新图片,那么就会强制覆盖原来有的图片,而且不会生成新的图片。自动覆盖的代码也需要修改wordpress的部分代码,因为wordpress的xmlrpc原本的逻辑是会生成-1,-2这样后缀的图片,而不会覆盖原来的图片,所以需要加一小段。

​ 如果在手动模式下的不强制更新图片或者自动模式,那么就会检查本地缓存和远程URL有没有图片记录,如果都有,那么就不会更新图片,即便图片已经经过了修改(只看文件名称)。如果没有,那么也会进行覆盖更新。

​ 因此我的建议是,在远程删除了图片,或者本地修改了图片,那么就强制更新图片,自动模式不一定有效,因为有时候还有CDN的效果,即使删除了图片,CDN还有缓存,会有影响。

​ 因为wordpress5.8现在支持webp格式,因此上传也需要支持webp图片格式,就一行代码的事情。

v1.0.3

​ 对文章上传到Wordpress进行了逻辑优化,起因是开发软件的时候老是多次安装,甚至清缓存,或是多台设备试用这个软件,或者wordpress删除了文章,这就会导致原来的逻辑代码不能够适用。

​ 目前的更新逻辑为下:

  1. 手动确认:先模式一;若指定ID为0,则模式二;若模式二失败,则模式三;若模式三失败,则模式四;
  2. 自动判断:先模式二;若模式二失败,则模式三;若模式三失败,则为模式四;
  3. 创建新文章:直接模式四;
  • 模式一:更新指定文章ID
  • 模式二:更新本地缓存获取的文章ID(相同的URL)
  • 模式三:更新远程获得的文章ID(相同的标题,因为获取所有的文章,包括内容,比较费流量)
  • 模式四:创建新的文章

​ 手动更新适用于第一次使用软件,或者是换了一台设备更新文章,那么就可以指定文章ID来使当前这次能够成功更新,并且在本地缓存了更新后的ID。

​ 自动判断适用于就一台设备,而且有本地缓存的情况,当然没有也能够自动获取远程文章ID,除了费流量没啥硬伤。

v1.0.0

​ 终于完成了1.0.0的版本建设,10天的工作量,终于差不多把原来的源代码全部挪过来,逻辑和方法都没改,就是变成TypeScript(AnyScript😁)。虽然现在还有很多很多问题,比如去除了MathJax,因为原来的代码不能试用,而且我也没有这方面的需求,还有图片上传逻辑等等,但毕竟现在能用,就已经大告成功了。

​ 可以推送博客了,好耶 ( •̀ ω •́ )✧。

待做

  • v-html改为组件模版,为了安全。(懒,问题不大)
  • 标题栏和菜单栏实现。(懒,不想实现)
  • 文章图片cache基类这个逻辑可能还需要再重新写一遍,目前觉得用md5进行重写会不会合适一点?本地记录一下图片的名称和md5,然后比对。(不用md5,因为麻烦,还耗费资源,目前没看到必要性,详细看1.0.4)
  • 一个tab键转换的时候会变成一个空格键,希望能够变成一个全角空格(~~已经修复,直接将\t替换 就行~~~~了 )~~~~(又修改了一遍,将\t替换为全角空格)。
  • mathjax实现,不一定做,因为现在没用到,而且很麻烦。
  • 图片居中
  • 记录文件打开历史
  • 文件修改后有标记
  • 能够有一键重载文件的按钮
  • 使用typescript(即不要全用any)
  • 改成vue3格式
  • 左侧使用类似Typora的文件管理的效果
  • 适配cnblogs~~,oschina(没文档,不行)~~
  • 可选markdown的渲染样式

其他人类似的项目

发布本地文章到各种平台——写作助手

命令行方式上传markdown到博客园——pycnblog

苹果用户非常棒的Markdown写作软件——MWeb

能够发布到微信公众号的markdown编辑器——微信 Markdown 编辑器

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

将本地markdown推送到wordpress 展开 收起
Apache-2.0
取消

发行版 (8)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/xaotuman/push-markdown.git
git@gitee.com:xaotuman/push-markdown.git
xaotuman
push-markdown
push-markdown
master

搜索帮助