Changed mt2rest to hatena2rest¶
I released mt2rest at 30 March that is tool to convert(GEEK DAY TOKYOに参加しました。). It is to convert Hatena Diary exported into reST format. I had migrated from Hatena Diary to Tinkerer. But it was incomplete conversion with this tool, because I made improvised for that time event.
I rewrote this tool with using Hatena diary XML format instead of MovableType format as input. The two reason is as follows. Firstly it is too hard to distinguish the notation of Hatena Diary written in the code block to separate the entries of daily correctly. Secondary it is also hard to parse distinguish the code of blog-parts when I use the MovableType format as input file. I renamed a project name “hatena2rest. It is now not use MovableType format why “mt” of mt2rest is Abbreviation of “MovableType”.
Use this tool if you will migrate tinkerer from Hatena Diary. Usage is written in README.
I make a note that I had a hard time.
Detection of half-width characters and full-with characters¶
String must has border line as “=” * character length at section, subsection and simple table of Sphinx. Single-byte character is simple, so character length of border equals character length of string. String encoded with unicode is also the same.
>>> len(r"single")
6
>>> len(u"single")
6
But double-byte character is complicated. Character length of string is different with encoded with unicode and raw.
>>> len(r"全角")
6
>>> len(u"全角")
2
“Hankaku kana” is below
>>> len(r"テスト")
9
>>> len(u"テスト")
3
“Zenkaku” must be two or more characters, “Hankaku” must be at least one character when Sphinx border character. It is hard to detect with len(). So I used unixcodedata.east_asian_width().
unicodedata module is embedded with Python. east_asian_width() has next 6 values.
F: Fullwidth
H: Halfwidth
W: Wide
Na: Narrow
A: Ambiguous
N: Neutral
According to “WikiPedia”, “A” is processed as 1 or 2 characters, but Sphinx processes as like below probably.
F: 2 character width
H: 1 character width
W: 2 character width
Na: 1 character width
A: 1 character witdh
N: 1 character width
Then next code is enable to get width of string.
def length_str(string)
fwa = ['F', 'W', 'A']
hnna = ['H', 'N', 'Na']
if isinstance(string, unicode):
zenkaku = len([unicodedata.east_asian_width(c)
for c in string
if unicodedata.east_asian_width(c) in fwa])
hankaku = len([unicodedata.east_asian_width(c)
for c in string
if unicodedata.east_asian_width(c) in hnna])
return (zenkaku * 2 + hankaku)
elif isinstance(string, str):
return len(string)
https://github.com/mkouhei/hatena2rest/blob/master/src/hatena2rest/utils.py#L61
Exception occurs when use “&” in raw directive of html¶
“&” is disable to use in raw directive of html. Blog parts is converted to html raw directive. Then exception occurs when running build(tinker -b command)..
# Sphinx version: 1.1.3
# Python version: 2.7.3
# Docutils version: 0.8.1 release
# Jinja2 version: 2.6
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.7/sphinx/cmdline.py", line 189, in main
app.build(force_all, filenames)
File "/usr/lib/pymodules/python2.7/sphinx/application.py", line 204, in build
self.builder.build_update()
File "/usr/lib/pymodules/python2.7/sphinx/builders/__init__.py", line 196, in build_update
'out of date' % len(to_build))
File "/usr/lib/pymodules/python2.7/sphinx/builders/__init__.py", line 255, in build
self.finish()
File "/usr/lib/pymodules/python2.7/sphinx/builders/html.py", line 433, in finish
for pagename, context, template in pagelist:
File "/usr/lib/python2.7/dist-packages/tinkerer/ext/blog.py", line 85, in html_collect_pages
for name, context, template in rss.generate_feed(app):
File "/usr/lib/python2.7/dist-packages/tinkerer/ext/rss.py", line 54, in generate_feed
app.config.website + post[:11])),
File "/usr/lib/python2.7/dist-packages/tinkerer/ext/patch.py", line 91, in patch_links
doc = xml.dom.minidom.parseString(in_str)
File "/usr/lib/python2.7/xml/dom/minidom.py", line 1930, in parseString
return expatbuilder.parseString(string)
File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 940, in parseString
return builder.parseString(string)
File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 223, in parseString
parser.Parse(string, True)
ExpatError: not well-formed (invalid token): line 70, column 363
This problem is solved with escaping to character entity references, but there is no meaning as hyperlink. So I extracted URI as simple hyperlink.
Other¶
I spent a lot of regular expression.
See also¶
Disqus comment fail to appear¶
Tinkerer is enable to use disqus as comment plugin, but Chromiums blocks the reading third-party cookie. Disqus appear dialog that says you should allow third-party cookies, but at least I want to allow only necessary domain’s. So I have set up cookie of disqus “[*.]disqus.com” to exception of cookie and site data. You may set up with next list when you specify domains explicitly.
disqus.com
mediacdn.disqus.com
your-disqus-shortname.disqus.com (example mkouhei.disqus.com)
qq.disqus.com
securecdn.disqus.com
juggler.services.disqus.com
See also¶
Updated Tinkerer 0.4b¶
I updated Tinkerer from 0.3b to 0.4b. This update has a problem. 0.4b recommended using html_theme is modern5. I changed from modern to modern5, tried to run tinker -b. But building failed that exception occured jinja2.TemplateNotFound when modern5.
$ tinker -b -q
(snip)
Exception occurred:
File "/usr/lib/pymodules/python2.7/sphinx/builders/__init__.py", line 196, in build_update
'out of date' % len(to_build))
File "/usr/lib/pymodules/python2.7/sphinx/builders/__init__.py", line 255, in build
self.finish()
File "/usr/lib/pymodules/python2.7/sphinx/builders/html.py", line 438, in finish
self.write_genindex()
File "/usr/lib/pymodules/python2.7/sphinx/builders/html.py", line 495, in write_genindex
self.handle_page('genindex', genindexcontext, 'genindex.html')
File "/usr/lib/pymodules/python2.7/sphinx/builders/html.py", line 728, in handle_page
output = self.templates.render(templatename, ctx)
File "/usr/lib/pymodules/python2.7/sphinx/jinja2glue.py", line 128, in render
return self.environment.get_template(template).render(context)
File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 719, in get_template
return self._load_template(name, self.make_globals(globals))
File "/usr/lib/python2.7/dist-packages/jinja2/environment.py", line 693, in _load_template
template = self.loader.load(self, name, globals)
File "/usr/lib/python2.7/dist-packages/jinja2/loaders.py", line 115, in load
source, filename, uptodate = self.get_source(environment, name)
File "/usr/lib/pymodules/python2.7/sphinx/jinja2glue.py", line 149, in get_source
raise TemplateNotFound(template)
TemplateNotFound: genindex.html
The full traceback has been saved in /tmp/sphinx-err-hQwPgt.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
Either send bugs to the mailing list at <http://groups.google.com/group/sphinx-dev/>,
or report them in the tracker at <http://bitbucket.org/birkenfeld/sphinx/issues/>. Thanks!
This work around of problem is changed disable html_use_index.
diff --git a/conf.py b/conf.py
index c5ef69e..0950c51 100644
--- a/conf.py
+++ b/conf.py
@@ -81,6 +81,6 @@ master_doc = tinkerer.master_doc
version = tinkerer.__version__
release = tinkerer.__version__
html_title = project
-html_use_index = True
+html_use_index = False
html_show_sourcelink = True
html_add_permalinks = True
Replaced PoE switch¶
Recently, repeater hub that we were using to connect to the Internet at home was broken. The hub that had been prepared from the beginning at the time of purchase condominiums, had been placed under the floor of the closet. When I was calling the help desk of the provider, they said that the hub was not their asset, which is rather our asset. They said to me that the period a defect of the hub was finished, and I exchanged with myself. The hub had to ensure the power from the electrical outlet under the floor, but I want to operate switch without the AC adapter, so I bought a switch for PoE.
I purchased two kinds of intelligent switches. Those are GS108PEv2 and GS108Tv2 of NETGEAR. The former is for the power supply switch, switch for receiving the latter. In addition, I has used Plathome’s OpenMicroServeres are supporting for PoE, we decided to operate without AC adapter those as well.
After exchanging was to look like below.
Updating from 2.4.2 to 2.7.0 of GitLab¶
My colleague requested me to update GitLab from 2.4.2 to 2.7.0. Then I did it. The procedure is accoding to documents of GitLab, next links.
https://github.com/gitlabhq/gitlabhq/wiki/From-2.4.1-to-2.5.0
https://github.com/gitlabhq/gitlabhq/wiki/From-2.5.0-to-2.6.0
https://github.com/gitlabhq/gitlabhq/wiki/From-2.6.x-to-2.7.0
I upgraded from 2.4.2 to 2.7.0 without at once, it was upgraded in stages. I made the record to the following procedure.
from 2.4.2 to 2.5.0¶
$ sudo /etc/init.d/gitlab stop
$ sudo su - gitlab
$ cd gitlab
$ git remote update
$ git checkout v2.5.0
$ git checkout -b v2.5.0
$ bundle install --without development test
$ exit
$ sudo gem update --system
$ sudo su - gitlab
$ bundle exec rake db:migrate RAILS_ENV=production
$ exit
$ sudo /etc/init.d/gitlab start
from 2.5.0 to 2.6.0¶
$ sudo /etc/init.d/gitlab stop
$ sudo su - gitlab
$ git checkout v2.6.0
$ git checkout -b v2.6.0
$ bundle install --without development test
$ bundle exec rake db:migrate RAILS_ENV=production
$ exit
$ sudo /etc/init.d/gitlab start
from 2.6.0 to 2.7.0¶
$ sudo /etc/init.d/gitlab stop
$ sudo su - gitlab
$ git stash
$ git checkout v2.7.0
$ git checkout -b v2.7.0
$ cp -i config/gitlab.yml.example config/gitlab.yml
$ sed -i 's/localhost/gitlab.example.org/g' config/gitlab.yml
$ bundle install --without development test
$ bundle exec rake db:migrate RAILS_ENV=production
$ touch log/githost.log
$ exit
$ sudo /etc/init.d/gitlab start
If just copy config/gitlab.yml.example to config/gitlab.yml, it occurs problem in the WebUI that be ‘localhost’ instead of FQDN. This is as a previous article. See also “GitLabを導入してみた話。”.
If not touch log/githost.log, http 500 error occurs at Logs view of admin area.