opoo / opoopress

OpooPress framework is a java based blog aware static site generator.
http://www.opoopress.com/
Apache License 2.0
113 stars 31 forks source link

Linux 下创建新文章不指定 -Dname 出错 #5

Open VilenEera opened 10 years ago

VilenEera commented 10 years ago

-Dtitle英文,不指定 -Dname 成功 -Dtitle中文,指定 -Dname 成功 -Dtitle中文,不指定 -Dname 出错

linux-9mbz:~/Documents/myBlog> mvn op:new-post -Dtitle="测试"
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building My OpooPress.com site 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- opoopress-maven-plugin:1.0.3:new-post (default-cli) @ my-opoopress-site ---
[INFO] The site directory is : /home/star/Documents/myBlog/site
[INFO] Skipping install, site already installed.
[INFO] Using title as post name.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.939s
[INFO] Finished at: Mon Nov 25 09:46:45 CST 2013
[INFO] Final Memory: 10M/105M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.opoo.press.maven.plugins:opoopress-maven-plugin:1.0.3:new-post (default-cli) on project my-opoopress-site: String index out of range: 0 -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

我猜会不会是编码的原因,命令行改成 GBK 就成功了

linux-9mbz:~/Documents/myBlog> mvn op:new-post -Dtitle=你�"
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building My OpooPress.com site 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- opoopress-maven-plugin:1.0.3:new-post (default-cli) @ my-opoopress-site ---
[INFO] The site directory is : /home/star/Documents/myBlog/site
[INFO] Skipping install, site already installed.
[INFO] Using title as post name.
[INFO] Write to file /home/star/Documents/myBlog/site/source/article/2013-11-25-le.markdown
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.746s
[INFO] Finished at: Mon Nov 25 09:54:59 CST 2013
[INFO] Final Memory: 10M/105M
[INFO] ------------------------------------------------------------------------
opoo commented 10 years ago

谢谢你提出这个问题。Linux 的编码处理可能是个大问题。

目前我在 LANG=en_US.UTF-8 的 CentOS 下测试,使用 SSH 远程登录。不指定 -Dname 参数时的确报错,即使 -Dname -Dtitle 参数完整,生成的源文件中也会乱码,VI 编辑源文件也会乱码。中文编码的问题还有待继续深入研究。

如果文件在别的系统中(如 Windows)被存储为 UTF-8 格式,即使包含中文,复制到 LANG=en_US.UTF-8 的 Linux 下也不会乱码。

opoo commented 10 years ago

最新发现,在使用 koding 的 vm(Ubuntu, en_US.UTF-8)下是支持中文的。

@vm-0:~/Documents/opoo.org$ mvn op:new-post -Dtitle=整理 -Dname=zhengli                                                                                                            
[INFO] Scanning for projects...
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Opoo.org - An OpooPress.com website 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- opoopress-maven-plugin:1.0.3:new-post (default-cli) @ opoo-org-website ---
[INFO] The site directory is : /home/oporg/Documents/opoo.org/site
[INFO] Skipping install, site already installed.
[INFO] Add auto include: macros.ftl
[INFO] Write to file /home/oporg/Documents/opoo.org/site/source/article/2014-03-06-zhengli.markdown
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.263 s
[INFO] Finished at: 2014-03-06T09:11:38+00:00
[INFO] Final Memory: 8M/303M
[INFO] ------------------------------------------------------------------------

不带 -Dname

@vm-0:~/Documents/opoo.org$ mvn op:new-post -Dtitle=整理zhongwen                                                                                                                   
[INFO] Scanning for projects...
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Opoo.org - An OpooPress.com website 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- opoopress-maven-plugin:1.0.3:new-post (default-cli) @ opoo-org-website ---
[INFO] The site directory is : /home/oporg/Documents/opoo.org/site
[INFO] Skipping install, site already installed.
[INFO] Add auto include: macros.ftl
[INFO] Using title as post name.
[INFO] Write to file /home/oporg/Documents/opoo.org/site/source/article/2014-03-06-zheng-li-zhongwen.markdown
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.852 s
[INFO] Finished at: 2014-03-06T09:17:12+00:00
[INFO] Final Memory: 11M/303M
[INFO] ------------------------------------------------------------------------