Code Monkey home page Code Monkey logo

hexo-qiniu-sync's Introduction

Travis Latest Stable Version NPM Downloads Dependency Status Github Release GitHub stars

简介

这是一个hexo插件, 可以让你在文档中入嵌存储在七牛上的图片、JS、CSS类型的静态文件。

你可以不用手动上传文件到七牛,插件会自动帮你将本地目录的文件同步到七牛。

项目作者:gyk001
代码贡献(字母序排列):

安装

在你的hexo主目录下运行以下命令进行安装:

npm install hexo-qiniu-sync --save

添加插件配置信息到 _config.yml 文件中:

#七牛云存储设置
##offline       是否离线. 离线状态将使用本地地址渲染
##sync          是否同步
##bucket        空间名称.
##access_key    上传密钥AccessKey
##secret_key    上传密钥SecretKey
##secret_file   秘钥文件路径,可以将上述两个属性配置到文件内,防止泄露,json格式。绝对路径相对路径均可
##dirPrefix     上传的资源子目录前缀.如设置,需与urlPrefix同步 
##urlPrefix     外链前缀.
##up_host      上传服务器路径,如选择华北区域的话配置为http://up-z1.qiniu.com
##local_dir     本地目录.
##update_exist  是否更新已经上传过的文件(仅文件大小不同或在上次上传后进行更新的才会重新上传)
##image/js/css  子参数folder为不同静态资源种类的目录名称,一般不需要改动
##image.extend  这是个特殊参数,用于生成缩略图或加水印等操作。具体请参考http://developer.qiniu.com/docs/v6/api/reference/fop/image/ 
##              可使用基本图片处理、高级图片处理、图片水印处理这3个接口。例如 ?imageView2/2/w/500 即生成宽度最多500px的缩略图
qiniu:
  offline: false
  sync: true
  bucket: bucket_name
  secret_file: sec/qn.json or C:
  access_key: AccessKey
  secret_key: SecretKey
  dirPrefix: static
  urlPrefix: http://bucket_name.qiniudn.com/static
  up_host: http://upload.qiniu.com
  local_dir: static
  update_exist: true
  image: 
    folder: images
    extend: 
  js:
    folder: js
  css:
    folder: css

注意,不要在plugins下面添加hexo-qiniu-sync的配置项,否则会导致错误,详见 #41 (comment)

plugins:
  - hexo-qiniu-sync

这里对配置中的几个需要注意的参数进行说明:

  • offline 参数:

如果要使用同步到七牛空间的静态资源,请设置为 false。如果只想浏览在本地的静态资源文件,则设置为 true

  • sync 参数:

如果你想关掉七牛同步,将此参数设置为false即可,不过一般用不到修改这个参数。

  • dirPrefix 参数:

将资源上传到七牛空间内这个目录下(说是目录会容易理解点),默认为 static 目录。

  • urlPrefix 参数:

七牛空间地址的前缀,会按默认格式自动生成地址,所以此参数可省略
默认格式为 http://bucket_name.qiniudn.com/static ,如果你的七牛空间使用自定义域名或域名不是此格式的,请配置此参数。
当你设置了 dirPrefix 参数后,如static。则此url地址必须加上目录后缀 /static , 即http://bucket_name.qiniudn.com/static,否则静态资源将无法访问。

  • local_dir 参数:

只填写一个目录名称即可,建立在hexo博客的主目录,不需要使用子目录。
当你在配置中填写好文件夹后,运行hexo时,会自动建立对应的目录。
如果你了解hexo文件夹的关系,担心这样会导致离线模式不能查看到图片,我可以告诉你你不需要担心这个问题。
在你以离线模式运行时,会自动使用软连接/联接方式帮你建立文件夹的引用,可以让你的离线浏览节省一倍的空间。

  • update_exist 参数:

如果你的静态文件会进行修改或替换,并需要更新七牛空间上原先上传的文件,则设置为 true
是否更新空间上已上传的文件,是按照对比文件大小是否相同或者本地文件在上传到七牛空间之后进行过修改的规则进行判断的。

  • image : extend 参数:

这是个特殊参数,是文章内使用 qnimg 标签引用图片的默认图片处理操作。请参考 七牛开发者中心-图片处理
可以使用 基本图片处理(imageView2)、高级图片处理(imageMogr2)、图片水印处理(watermark) 这三个图片处理接口,多个接口内容之间用 | 间隔。
例如 ?imageView2/2/w/500 即生成宽度最多500px的缩略图。

使用标签

{% qnimg imageFile attr1:value1 attr2:value2 'attr3:value31 value32 value3n' [extend:?imageView2/2/w/600 | normal:yes] %}
{% qnjs jsFile attr1:value1 attr2:value2 'attr3:value31 value32 value3n' %}
{% qncss cssFile attr1:value1 attr2:value2 'attr3:value31 value32 value3n' %}
  • jnimg 标签的图片处理:

如果你在 _config.yml 文件中配置了 extend 字段,则默认会对插入的图片进行对应的处理。
如果不想对一个图片进行处理,则可在 jnimg 标签内增加 normal:yes 参数,则使用原图,不进行图片处理。
如果只对当前图片进行处理,则可在 jnimg 标签内增加 extend:?imageView2/2/w/600 样式的配置参数。
_config.yml 文件中和 jnimg 标签内都定义了 extend 参数,则只会使用 jnimg 标签的 extend 参数。
请参考**七牛开发者中心-图片处理** ,可以使用 基本图片处理(imageView2)、高级图片处理(imageMogr2)、图片水印处理(watermark) 这三个图片处理接口,多个接口内容之间用 | 间隔。

Demo

{% qnimg test/demo.png title:图片标题 alt:图片说明 'class:class1 class2' extend:?imageView2/2/w/600 %}

将会被渲染成:

<img title="图片标题" alt="图片说明" class="class1 class2" src="http://gyk001.u.qiniudn.com/images/test/demo.png?imageView2/2/w/600">

命令行

作为一个带命令行功能的插件,漏掉了命令行的使用说明不是好习惯。 本插件命令行为 hexo qiniu ,所支持的子命令有:

  • info (简写 i )

功能:显示插件版本,作者及Github地址信息等

  • sync (简写 s )

功能:同步静态资源到七牛空间

  • sync2 (简写 s2 )

功能:同步静态资源到七牛空间,且会同步上传那些本地与七牛空间有差异的文件。
这个命令会无视 update_exist 配置
对比规则请看 update_exist 配置参数说明。

同步静态资源

当需要把静态资源同步到七牛空间中时,有如下几种方式可以同步资源:

  • 启用本地服务器.即使用 hexo server 命令(简写为 hexo s

当以本地服务器模式启动后,会自动监测 local_dir 目录下的文件变化, 会自动将新文件进行上传。
如果文件进行了修改,但设置中没有启用 update_exist 配置,则不会更新到七牛空间。

  • 使用命令行命令(sync | s | sync2 | s2)

命令行命令会扫描 local_dir 目录下的文件,同步至七牛空间。

备注:使用生成(generate)或部署(deploy)命令时,会提示需要上传的文件数量:

[info] Need upload file num: 0


## 小技巧

* 文章模板
>如果你经常在文章内插入图片,你可以修改文章模板,将空白的图片插入标签粘贴进去。  
这样新建立的文章就有空白标签可以让你直接填写图片路径就好了,会很省事。  
文章模板文件:`./scaffolds/post.md`  
图片标签`{% qnimg test/demo.png title:图片标题 alt:图片说明 'class:class1 class2' %}`

* 图片处理样式
>在前边的内容里,已经介绍了图片处理参数,下面来介绍一个更省事的技巧。  
>如果你经常使用的图片效果是固定的,你可以通过设置数据处理样式来达到灵活的控制。  
>  1. 首先登陆七牛空间,选择存储空间后,再选择`数据处理`菜单。
>  2. 设置分隔符。默认的 `-` 即可。
>  3. 点击 `新建样式` 按钮,根据提示创建一个处理样式。
>  4. 创建样式完毕后,你就可以将 `extend` 参数设置为 `分隔符+样式名称`了。  
     如你设置的分隔符为 `-` ,样式名称为 `new` ,则 `extend` 参数就是 `-new` 了。  
     简单吧?  
     你可以根据自己的需要,建立多个样式,然后在文章内使用时,为不同图片标签设置
     不同的`extend`参数,来达到不同的显示效果。

## 常见问题

* WINDOWS系统下使用离线模式,运行 `hexo s` 后,在文章页面中不能无法看到引用的静态资源图片  
如:`local_dir` 参数设置为 `static` ,运行 `hexo s` 后 `source` 目录下没有出现一个名字为 `static` 的目录链接。
>首先检查以下内容:  
   * 所在的磁盘的文件系统是否为`NTFS`。因为 WINDOWS 下 `NTFS` 系统才支持目录链接。
   * 运行 `hexo s` 时,是否以管理员身份运行的。目录链接操作需要管理员身份才可以执行,  
     如果你是在打开的cmd命令行中执行 `hexo s` 的,需要以管理员身份运行cmd才可以。  
     如果你是运行批处理文件运行( 例如内容为 `hexo s` ),请批处理文件的属性中设置为以管理员身份运行。
   * 不要把 `local_dir` 参数指定的目录设置为 `source` 目录的子目录,应当为 `source` 目录的同级目录。
   * 如果你是FAT32格式的磁盘,你只使用离线模式的话,可以把`local_dir` 参数设置为`source` 目录的子目录,
     这样在 `hexo s` 时,才可以正常预览。

* 在同步模式下,不能同步,出现报错为 `[error] SyntaxError: Unexpected end of input`
>请检查设置中的 `access_key` 与 `secret_key` 是否正确,以及是否可用。
   

hexo-qiniu-sync's People

Contributors

52cik avatar crazier9527 avatar gyk001 avatar k1988 avatar matrixhero avatar robinshen avatar xiajinchun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hexo-qiniu-sync's Issues

是插件不能用了吗?运行报错

运行时报错:

ERROR Plugin load failed: hexo-qiniu-sync
TypeError: Cannot read property 'html_tag' of undefined
    at /blog/node_modules/hexo-qiniu-sync/index.js:5:24

也就是这行:

var htmlTag = hexo.util.html_tag;

是按照项目下面说明来配置的。

qnimg标签不能并排排列图片

{% qnimg 01.png extend:?imageView2/2/w/200 %} {% qnimg 02.png extend:?imageView2/2/w/200 %}

贴入两张图片,预想结果是

1 2

这样并排排列。
但是实际上是

1
2

这样纵向排列,即使右边有很大的空隙。

看了下html,发现是a标签里包裹一个img标签,img是变小了,可是a标签是铺满横向的屏幕的。

怎么让两张图片并排排列?

主题下的图片也能上传图片吗

假如我有大量图片在主题文件下,并且引用是通过config.yml定义的root路径。文章是用raw写的html ,图片是用source下的图片。
那么可以实现替换和上传图片吗

插件正常就昨天成功了一张图片现在怎么读无法上传

又不报错 ,不知道为什么七牛里面没发现有上传。

dirPrefix: static
urlPrefix: http://ocobliy5d.bkt.clouddn.com/static
up_host: http://upload.qiniu.com
local_dir: static

2016/11/04 01:29

.
2016/11/04 01:29 ..
2016/11/06 02:33 .deploy_git
2016/11/06 02:19 91 .gitignore
2016/09/01 23:11 0 .gitkeep
2016/09/03 13:50 65 .npmignore
2016/09/15 08:23 cdn_files
2016/09/04 14:48 117 commit_source_to_serve
2016/11/06 02:33 174 db.json
2016/11/04 00:41 node_modules
2016/11/04 00:41 711 package.json
2016/11/04 00:15 public
2016/09/03 13:30 scaffolds
2016/11/06 02:18 source
2016/11/04 00:52 static
2016/09/03 14:42 themes
2016/09/04 14:45 187 upload.sh
2016/11/06 02:33 5,077 _config.yml
2016/09/01 23:11 60 本地测试.sh

安全问题

ak和sk直接放在config文件里会不会不太合适?

我想了一个方法,提供cli程序进行加密,然后在插件使用的之前进行解密。如果只是简单的对称加密又只是防君子不防小人。

然后我又完善了一下思路,通过RSA加密,将公钥文件加到.gitignore里

关于本项目的更新,请作者抽空看下。

这个项目是非常好的hexo插件。
用起来会极大方便使用hexo来写博客。
只是原先制作时没有考虑通用性(便捷配置),导致其他人通过npm install后,不了解这个插件从而无法使用。

由于qrsync的路径及其他一些路径都已经在代码中写死,使用必须到代码里改。最初我也是按自己机器的情况在代码里进行了修改,才可以正常使用。
后来看到其他一些,发现这个项目仅仅是这样残缺的情况非常可惜,而且初用起来进行配置真的有点麻烦。
所以,就东拼西凑的改了代码,不再使用千牛官方的qrsync进行同步。改为使用其他人制作的千牛node版sdk包进行调用,配置的话只用在_config.yml里设置几个必要的参数即可使用。
我注意到你项目中一些选项和设置格式与现在千牛的不一样,应该是2014年千牛对其软件及API等进行了升级,格式做了调整。如缩略图的调用查看方式就不一样,我计划近期抽时间把这代码进行完善。
但我不清楚作为原作者,一年没有更新此项目,是否还依然愿意抽时间来维护此项目呢?
如果是的话,我将修改代码,然后pull提交给你,由你提交npm。否则我只能重开个项目,提交npm,但会保留你是原作者的信息。

本地模式 会删除了static内容,并且无法建立软连接

E:\hexo>hexo clean
INFO -----------------------------------------------------------
INFO qiniu state: offline
INFO qiniu sync: false
INFO qiniu local dir: static
INFO qiniu url: /static
INFO -----------------------------------------------------------
WARN qiniu sync is offline mode
INFO Deleted database.
INFO Deleted public folder.

E:\hexo>hexo g
INFO -----------------------------------------------------------
INFO qiniu state: offline
INFO qiniu sync: false
INFO qiniu local dir: static
INFO qiniu url: /static
INFO -----------------------------------------------------------
WARN qiniu sync is offline mode
INFO Files loaded in 3.23 s
fs.js:852
return binding.symlink(preprocessSymlinkDestination(destination, type),
^
Error: ENOENT, no such file or directory 'E:\hexo\static'
at Error (native)
at Object.fs.symlinkSync (fs.js:852:18)
at E:\hexo\node_modules\hexo-qiniu-sync\sync.js:152:16
at FSReqWrap.cb as oncomplete

E:\hexo>

offline设为true后重新发布图片路径全部不对了

我把offline设为true之后,执行hexo g && hexo deploy
然后所有图片的地址变成/static/images/xxx/yyy.jpg了, 本地使用hexo server浏览是好的,但是服务器的根目录根本不存在static目录,导致图片全部404.

hexo deploy问题与及一些插件建议

  • 这插件挺好用的,首先要表示感谢!
  • hexo deploy在我电脑上会出现ERROR Deployer not found: git的错误,接着文件就不可以同步(注:本人Window7 64位),但是直接使用hexo qiniu s2可以解决同步上传问题!!不知道这算是问题吗!
  • 算是插件建议,某些文件我并不写同步到CDN中,比如html文件名,该如何设置好,是否应有个exclude的参数配置项比较好?

FATAL duplicated mapping key at xxxx folder: js

不知道为什么,直接从github教程上复制下来的,总是报错

qiniu:
  offline: false
  sync: true
  bucket: ***//这个我就不透露了
  secret_file: ./qiniu_key.json
  access_key: *******************
  secret_key: *********************
  dirPrefix: tomato
  urlPrefix: http://****.qiniudn.com/tomato
  up_host: http://upload.qiniu.com
  local_dir: public
  update_exist: true
  image:
        folder: images
  extend:
  js:
        folder: js
  css:
        folder: css

本地static文件夹的子文件夹中无文件

您好,我按照说明安装了插件,并在_config.yml配置文件中添加了如下的插件设置:

qiniu:
  offline: false
  sync: true
  bucket: haomwei
  access_key: 我的ak
  secret_key: 我的sk
  dirPrefix: static
  urlPrefix: http://haomwei.qiniudn.com/static
  local_dir: static
  update_exist: true
  image: 
    folder: images
    extend: 
  js:
    folder: js
  css:
    folder: css

但是在运行hexo clean和hexo generate之后,发现static文件夹中的images,js和css子文件夹内没有任何文件,这样我运行hexo qiniu sync也就没有向我的七牛空间中上传任何文件,请问是我使用的姿势不对还是哪里出了问题呢?非常感谢!

原来的markdown能无缝切换图床吗

还是一定要改文章使用qnimg标签
能否增加无缝切换图床的功能,把文章里所有的图片标签都使用七牛来存?
或者自动把图片挂到子域名下, 然后把子域名cname到七牛上?

使用qnimg标签写md报错

您好,
按照配置好文件后,如果不使用markdown的图片标签。而使用{% qnimg miyao201594.png title:图片标题 alt:图片说明 'class:class1 class2' extend:?imageView2/2/w/600 %}这种qnimg标签则会报错。报错的信息如下:can not read a block mapping entry;a multiline key may not be an implicit key

请问是不是imges.extends少加了什么的缘故,我什么都没写,按照给定模板来的
closes #xxx

七牛配置好之后,运行hexo s 出问题

hexo clean 和 hexo g 都可以正常运行,但是运行hexo s的时候提示:

hexo s --debug

09:18:58.453 DEBUG Hexo version: 3.2.2
09:18:58.456 DEBUG Working directory: ~/project/hexo/
09:18:58.523 DEBUG Config loaded: ~/project/hexo/_config.yml
09:18:58.549 INFO -----------------------------------------------------------
09:18:58.550 INFO qiniu state: online
09:18:58.550 INFO qiniu sync: true
09:18:58.550 INFO qiniu local dir: static
09:18:58.550 INFO qiniu url: http://7xq0jv.com1.z0.glb.clouddn.com/static
09:18:58.550 INFO -----------------------------------------------------------
09:18:58.590 DEBUG Plugin loaded: hexo-qiniu-sync
09:18:58.592 DEBUG Script loaded: themes/next/scripts/tags/center-quote.js
09:18:58.592 DEBUG Script loaded: themes/next/scripts/merge-configs.js
09:18:58.593 DEBUG Script loaded: themes/next/scripts/tags/full-image.js
09:18:58.593 DEBUG Script loaded: themes/next/scripts/tags/group-pictures.js
Usage: hexo

Commands:
clean Removed generated files and cache.
config Get or set configurations.
deploy Deploy your website.
generate Generate static files.
help Get help on a command.
init Create a new Hexo folder.
list List the information of the site
migrate Migrate your site from other system to Hexo.
new Create a new post.
publish Moves a draft post from _drafts to _posts folder.
qiniu Qiniu sync
render Render files with renderer plugins.
version Display version information.

Global Options:
--config Specify config file instead of using _config.yml
--cwd Specify the CWD
--debug Display all verbose messages in the terminal
--draft Display draft posts
--safe Disable all plugins and scripts
--silent Hide output on console

For more help, you can use 'hexo help [command]' for the detailed information
or you can check the docs: http://hexo.io/docs/
09:18:58.598 DEBUG Database saved

Process finished with exit code 0

PS:没有安装qiniu之后是可以正常运行的

文章添加qnimg标签之后hexo generate解析文章错乱

Environment Info

Node version(node -v):
v6.11.3

Your site _config.yml (Optional):

title: Glitchsome
subtitle: Random thoughts
description:
author: fhfuih
language: zh-cn
timezone: Asia/Shanghai

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://glitchso.me
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:

# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:

# Writing
new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
external_link: true # Open external links in new tab
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
highlight:
  enable: true
  line_number: true
  auto_detect: false
  tab_replace:

# Home page setting
# path: Root path for your blogs index page. (default = '')
# per_page: Posts displayed per page. (0 = disable pagination)
# order_by: Posts order. (Order by date descending by default)
index_generator:
  path: ''
  per_page: 10
  order_by: -date

# Category & Tag
default_category: uncategorized
category_map:
tag_map:

# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss

# Pagination
## Set per_page to 0 to disable pagination
per_page: 10
pagination_dir: page

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: landscape

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
  type: git
  repo: https://github.com/fhfuih/fhfuih.github.io.git
  branch: master

# hexo-hey Admin

admin:
  name: ====
  password: ====
  secret: ====
  expire: 60*1

# hexo-qiniu-sync
qiniu:
  offline: false
  sync: true
  bucket: blog
  access_key: =====
  secret_key: =====
  dirPrefix:
  urlPrefix: =====
  local_dir: cdn
  update_exist: true
  image:
    folder: images
    extend:
#   js:
#     folder: js
#   css:
#     folder: css

Hexo and Plugin version(npm ls --depth 0):

For BUG

I wrote a new article, no errors on generation, but the html has such errors:
Only a small part of the article is parsed,
Some sentences and characters are disordered,
hyperlinks are parsed wrongly, with ':' replaced by '=' and disordered double-quotation marks.

Deleting all the qnimg tags will be fine.

The article and html source have been uploaded to Gist:
https://gist.github.com/fhfuih/2e25cbc7ef3c07024d3e71affa94f947

主题的静态文件可以同步吗?

主题的静态文件是渲染的后出现在 public 文件夹中,并不在指定的 local_dir 里,所有主题的静态文件不会被同步,是不是说这样只能同步自定义的 js css 和图片,主题里就麻烦很多?目前来看如果要同步主题的静态文件的话,需要手动把静态文件复制到 local_dir 目录再修改主题的引用位置吧

文件名中包含空格,无法正常解析

如果文件名中包含空格,无法正常解析:

{% qnimg "屏幕快照 2015-05-07 15.11.57.png" title:图片标题 alt:图片说明 'class:class1' %}

这样解析的结果为:

<img title="图片标题" alt="图片说明" class="class1" src="http://static.qiniudn.com/static/images/屏幕快照">

Upload finished: undefined

INFO Now start qiniu sync.
INFO Need upload file: static/images/2015-04-26.jpeg
INFO Upload finished: undefined

能不能把qiniu的配置文件独立出来

RT

为了方便使用我的站点源码使用github托管的(我需要在多台电脑上使用hexo),所以_config.yml是公开的.如果把qiniu的配置也写在里面的话就不安全了.

希望可以使用自己的独立配置文件或者允许自己指定qiniu的配置文件位置.

关于图片地址的引用

请问该插件是否有快捷的图片引用地址的方法呢?还是要去七牛网上把地址复制下来?

code: 400, error: incorrect zone, please use up-z1.qiniu.com

_config.yml配置如下:

qiniu:
  offline: false
  sync: true
  bucket: github-pages
  secret_file: /Users/yangsicong/Documents/qn.json
  access_key: AccessKey
  secret_key: SecretKey
  dirPrefix: 
  urlPrefix: http://up-z1.qiniu.com/
  local_dir: static
  update_exist: true
  image:
    folder: images
    extend:
  js:
    folder: js
  css:
    folder: css

最初urlPrefix配置按照文档说明配置是http://github-pages.qiniudn.com/static,但命令行报错:

{ code: 400,
  error: 'incorrect zone, please use up-z1.qiniu.com' }

我把urlPrefix改成http://up-z1.qiniu.com/还是https://up-z1.qiniu.com/都还是报同样的问题。

这是为什么呢?

ERROR get file stat err

运行 hexo s 后,浏览器访问本地地址。出现此错误。打开含有静态图片的地址就会报相应图片的错误。

D:\Blog>hexo s
INFO  -----------------------------------------------------------
INFO  qiniu state: online
INFO  qiniu sync:  true
INFO  qiniu local dir:  cdn
INFO  qiniu url:   https://o6lny6xxi.qnssl.com/static
INFO  -----------------------------------------------------------
INFO  Start processing
INFO  Now start qiniu sync.
INFO  Need upload file num: 0
INFO  Hexo is running at http://localhost:4000/. Press Ctrl+C to stop.
INFO  Now start qiniu watch.
ERROR get file stat err: static/images/githug-2/commit-history-2.png
[object Object]
ERROR get file stat err: static/images/a-byte-of-python/python.jpg
[object Object]
ERROR get file stat err: static/images/js-booleanObject-and-LogicalAND/example-2.jpg
[object Object]
ERROR get file stat err: static/images/githug-2/git-stash.png
[object Object]
ERROR get file stat err: static/images/js-booleanObject-and-LogicalAND/example-3.jpg
[object Object]
ERROR get file stat err: static/images/ife-note-2/microdata-example-code.png
[object Object]
ERROR get file stat err: static/images/ife-note-2/quick-sort-java.gif
[object Object]
ERROR get file stat err: static/images/a-byte-of-python/python.jpg
[object Object]
ERROR get file stat err: static/images/learning-path/learning-path.jpg
[object Object]
ERROR get file stat err: static/images/how-does-email-work/mail-service.png
[object Object]
INFO  Good bye

broken hexo server (v1.4.0)

when enable this plugin, hexo server will not work, no error output ,just like this

$  hexo server
INFO  -----------------------------------------------------------
INFO  qiniu state: online
INFO  qiniu sync:  true
INFO  qiniu local dir:  static
INFO  qiniu url:   http://7u2l8h.com1.z0.glb.clouddn.com/static
INFO  -----------------------------------------------------------
Usage: hexo <command>

Commands:
  clean     Removed generated files and cache.
  config    Get or set configurations.
  deploy    Deploy your website.
  generate  Generate static files.
  help      Get help on a command.
  init      Create a new Hexo folder.
  list      List the information of the site
  migrate   Migrate your site from other system to Hexo.
  new       Create a new post.
  publish   Moves a draft post from _drafts to _posts folder.
  qiniu     Qiniu sync
  render    Render files with renderer plugins.
  version   Display version information.

Global Options:
  --config  Specify config file instead of using _config.yml
  --cwd     Specify the CWD
  --debug   Display all verbose messages in the terminal
  --draft   Display draft posts
  --safe    Disable all plugins and scripts
  --silent  Hide output on console

For more help, you can use 'hexo help [command]' for the detailed information
or you can check the docs: http://hexo.io/docs/

插件可能是不可用的吧

我按照文档说明安装了这个插件,不可用。
然后我查看了源代码,比如:

var qrsync = '/Users/Guo/.qiniu/';

好几个地方都是类似这样的路径啊,应该在别人的机器上无法正常运行的。

是么?

ERROR Plugin load failed: hexo-qiniu-sync

npm uninstall hexo-qiniu-sync

删除七牛插件,并将_config.yml中plugin和七牛配置信息清除掉后,hexo d、hexo g和hexo s指令,还是会加载qiniu插件,因此总是会报错:ERROR Plugin load failed: hexo-qiniu-sync

hexo clean也执行过,还是报错。

请问如何解决?谢谢!

不知道怎么得我不小心把hexo给弄崩溃了但是不知道为什恶魔找不到qnimg..

ypeError: Cannot read property 'secret_file' of undefined
at Object. (F:\src\git_project\website2\node_modules\hexo-qiniu-sync\config.js:8:21)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (F:\src\git_project\website2\node_modules\hexo\lib\hexo\index.js:214:21)
at F:\src\git_project\website2\node_modules\hexo-qiniu-sync\index.js:9:14
at F:\src\git_project\website2\node_modules\hexo\lib\hexo\index.js:230:12
at tryCatcher (F:\src\git_project\website2\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler (F:\src\git_project\website2\node_modules\bluebird\js\release\promise.js:512:31)
at Promise._settlePromise (F:\src\git_project\website2\node_modules\bluebird\js\release\promise.js:569:18)
at Promise._settlePromise0 (F:\src\git_project\website2\node_modules\bluebird\js\release\promise.js:614:10)
at Promise._settlePromises (F:\src\git_project\website2\node_modules\bluebird\js\release\promise.js:693:18)
at Promise._fulfill (F:\src\git_project\website2\node_modules\bluebird\js\release\promise.js:638:18)
at Promise._resolveCallback (F:\src\git_project\website2\node_modules\bluebird\js\release\promise.js:432:57)
at Promise._settlePromiseFromHandler (F:\src\git_project\website2\node_modules\bluebird\js\release\promise.js:524:17)
at Promise._settlePromise (F:\src\git_project\website2\node_modules\bluebird\js\release\promise.js:569:18)
at Promise._settlePromise0 (F:\src\git_project\website2\node_modules\bluebird\js\release\promise.js:614:10)
at Promise._settlePromises (F:\src\git_project\website2\node_modules\bluebird\js\release\promise.js:693:18)
at Promise._fulfill (F:\src\git_project\website2\node_modules\bluebird\js\release\promise.js:638:18)
INFO Start processing
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Template render error: (unknown path) [Line 10, Column 13]
unknown block tag: qnimg
at Object.exports.prettifyError (F:\src\git_project\website2\node_modules\nunjucks\src\lib.js:34:15)
at new_cls.render (F:\src\git_project\website2\node_modules\nunjucks\src\environment.js:469:27)
at new_cls.renderString (F:\src\git_project\website2\node_modules\nunjucks\src\environment.js:327:21)
at F:\src\git_project\website2\node_modules\hexo\lib\extend\tag.js:66:9
at Promise._execute (F:\src\git_project\website2\node_modules\bluebird\js\release\debuggability.js:300:9)
at Promise._resolveFromExecutor (F:\src\git_project\website2\node_modules\bluebird\js\release\promise.js:483:18)
at new Promise (F:\src\git_project\website2\node_modules\bluebird\js\release\promise.js:79:10)
at Tag.render (F:\src\git_project\website2\node_modules\hexo\lib\extend\tag.js:64:10)
at Object.tagFilter [as onRenderEnd] (F:\src\git_project\website2\node_modules\hexo\lib\hexo\post.js:253:16)
at F:\src\git_project\website2\node_modules\hexo\lib\hexo\render.js:65:19
at tryCatcher (F:\src\git_project\website2\node_modules\bluebird\js\release\util.js:16:23)
at Promise._settlePromiseFromHandler (F:\src\git_project\website2\node_modules\bluebird\js\release\promise.js:512:31)
at Promise._settlePromise (F:\src\git_project\website2\node_modules\bluebird\js\release\promise.js:569:18)
at Promise._settlePromise0 (F:\src\git_project\website2\node_modules\bluebird\js\release\promise.js:614:10)
at Promise._settlePromises (F:\src\git_project\website2\node_modules\bluebird\js\release\promise.js:693:18)
at Async._drainQueue (F:\src\git_project\website2\node_modules\bluebird\js\release\async.js:133:16)
at Async._drainQueues (F:\src\git_project\website2\node_modules\bluebird\js\release\async.js:143:10)
at Immediate.Async.drainQueues (F:\src\git_project\website2\node_modules\bluebird\js\release\async.js:17:14)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)
FATAL (unknown path) [Line 10, Column 13]
unknown block tag: qnimg

Mac OS X中,在离线模式下软连接有问题。

配置如下:

plugins:
  - hexo-qiniu-sync
qiniu:
  offline: true
  sync: true
  bucket: codingon
  access_key: 
  secret_key: 
  dirPrefix: static
  urlPrefix: https://dn-my.qbox.me/static
  local_dir: static
  update_exist: true
  image:
    folder: images
  js:
    folder: js
  css:
    folder: css

运行后报错

$ hexo s
INFO  -----------------------------------------------------------
INFO  qiniu state: offline
INFO  qiniu sync:  false
INFO  qiniu local dir:  static
INFO  qiniu url:   /static
INFO  -----------------------------------------------------------
WARN  qiniu sync is offline mode
ERROR Can't make link fail!
WARN  Maybe do not have permission.
INFO  Hexo is running at http://0.0.0.0:4000/. Press Ctrl+C to stop.
ERROR Can't make link fail!
WARN  Maybe do not have permission.

然后 sourcepublic 目录下各会创建一个如下的软连接,并且这两个软连接还都是有问题的(循环引用),

$ ll source
lrwxr-xr-x   1 yibo  staff     6B 12 10 11:17 static -> static
$ cd source/static
cd: too many levels of symbolic links: source/static

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.