Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
1,673 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require 'rubygems' | ||
require 'hpricot' | ||
require 'fileutils' | ||
require 'time' | ||
|
||
# This importer takes a wordpress.xml file, | ||
# which can be exported from your | ||
# wordpress.com blog (/wp-admin/export.php) | ||
|
||
module Jekyll | ||
module WordpressDotCom | ||
def self.process(filename = "wordpress.xml") | ||
FileUtils.mkdir_p "_posts" | ||
posts = 0 | ||
|
||
doc = Hpricot::XML(File.read(filename)) | ||
|
||
(doc/:channel/:item).each do |item| | ||
title = item.at(:title).inner_text | ||
name = "#{Date.parse((doc/:channel/:item).first.at(:pubDate).inner_text).to_s("%Y-%m-%d")}-#{title.downcase.gsub('[^a-z0-9]', '-')}.html" | ||
|
||
File.open("_posts/#{name}", "w") do |f| | ||
f.puts <<-HEADER | ||
--- | ||
layout: post | ||
title: #{title} | ||
--- | ||
HEADER | ||
f.puts item.at('content:encoded').inner_text | ||
end | ||
|
||
posts += 1 | ||
end | ||
|
||
"Imported #{posts} posts" | ||
end | ||
end | ||
end |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# coding: utf-8 | ||
|
||
require 'rubygems' | ||
require 'hpricot' | ||
require 'fileutils' | ||
require 'yaml' | ||
require 'time' | ||
|
||
module Jekyll | ||
# This importer takes a wordpress.xml file, which can be exported from your | ||
# wordpress.com blog (/wp-admin/export.php). | ||
module WordpressDotCom | ||
def self.process(filename = "wordpress.xml") | ||
import_count = Hash.new(0) | ||
doc = Hpricot::XML(File.read(filename)) | ||
|
||
(doc/:channel/:item).each do |item| | ||
title = item.at(:title).inner_text.strip | ||
permalink_title = item.at('wp:post_name').inner_text | ||
# Fallback to "prettified" title if post_name is empty (can happen) | ||
if permalink_title == "" | ||
permalink_title = title.downcase.split.join('-') | ||
end | ||
|
||
date = Time.parse(item.at('wp:post_date').inner_text) | ||
status = item.at('wp:status').inner_text | ||
|
||
if status == "publish" | ||
published = true | ||
else | ||
published = false | ||
end | ||
|
||
type = item.at('wp:post_type').inner_text | ||
tags = (item/:category).map{|c| c.inner_text}.reject{|c| c == 'Uncategorized'}.uniq | ||
|
||
metas = Hash.new | ||
item.search("wp:postmeta").each do |meta| | ||
key = meta.at('wp:meta_key').inner_text | ||
value = meta.at('wp:meta_value').inner_text | ||
metas[key] = value; | ||
end | ||
|
||
name = "#{date.strftime('%Y-%m-%d')}-#{permalink_title}.html" | ||
header = { | ||
'layout' => type, | ||
'title' => title, | ||
'tags' => tags, | ||
'status' => status, | ||
'type' => type, | ||
'published' => published, | ||
'meta' => metas | ||
} | ||
|
||
FileUtils.mkdir_p "_#{type}s" | ||
File.open("_#{type}s/#{name}", "w") do |f| | ||
f.puts header.to_yaml | ||
f.puts '---' | ||
f.puts item.at('content:encoded').inner_text | ||
end | ||
|
||
import_count[type] += 1 | ||
end | ||
|
||
import_count.each do |key, value| | ||
puts "Imported #{value} #{key}s" | ||
end | ||
end | ||
end | ||
end |
124 changes: 124 additions & 0 deletions
124
...ts/2010-11-16-apache-%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%8f%98%e9%87%8f%e4%bb%8b%e7%bb%8d.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
--- | ||
layout: post | ||
title: !binary | | ||
QXBhY2hlIOacjeWKoeWZqOWPmOmHj+S7i+e7jQ== | ||
|
||
published: true | ||
meta: | ||
_edit_last: "1" | ||
_wp_old_slug: "" | ||
tags: | ||
- Apache | ||
type: post | ||
status: publish | ||
--- | ||
名称: HTTP_USER_AGENT | ||
说明: 相当于PHP中的服务器参数: $_SERVER["HTTP_USER_AGENT"] | ||
|
||
名称: HTTP_REFERER | ||
说明: 相当于PHP中的服务器参数: _SERVER["HTTP_REFERER"] | ||
|
||
名称: HTTP_COOKIE | ||
说明: 相当于PHP中的服务器参数: $_SERVER["HTTP_COOKIE"] | ||
|
||
名称: HTTP_FORWARDED | ||
说明: 相当于PHP中的服务器参数: $_SERVER["HTTP_FORWARDED"] | ||
|
||
名称: HTTP_HOST | ||
说明: 相当于PHP中的服务器参数: $_SERVER["HTTP_HOST"] | ||
|
||
名称: HTTP_PROXY_CONNECTION | ||
说明: PHP中貌似未提供这样的服务器信息值. 如果又的话可能等值于: $_SERVER["HTTP_PROXY_CONNECTION"] | ||
|
||
名称: HTTP_ACCEPT | ||
说明: 相当于PHP中的服务器参数: $_SERVER["HTTP_ACCEPT"] | ||
|
||
名称: DOCUMENT_ROOT | ||
说明: 相当于PHP中的服务器参数: $_SERVER["DOCUMENT_ROOT"] | ||
|
||
名称: SERVER_ADMIN | ||
说明: 相当于PHP中的服务器参数: $_SERVER["SERVER_ADMIN"] | ||
|
||
名称: SERVER_NAME | ||
说明: 相当于PHP中的服务器参数: $_SERVER["SERVER_NAME"] | ||
|
||
名称: SERVER_ADDR | ||
说明: 相当于PHP中的服务器参数: $_SERVER["SERVER_ADDR"] | ||
|
||
名称: SERVER_PORT | ||
说明: 相当于PHP中的服务器参数: $_SERVER["SERVER_PORT"] | ||
|
||
名称: SERVER_PROTOCOL | ||
说明: 相当于PHP中的服务器参数: $_SERVER["SERVER_PROTOCOL"] | ||
|
||
名称: SERVER_SOFTWARE | ||
说明: 相当于PHP中的服务器参数: $_SERVER["SERVER_SOFTWARE"] | ||
|
||
名称: REMOTE_ADDR | ||
说明: 相当于PHP中的服务器参数: $_SERVER["REMOTE_ADDR"] | ||
|
||
名称: REMOTE_HOST | ||
说明: 相当于PHP中的服务器参数: $_SERVER["REMOTE_HOST"] | ||
|
||
名称: REMOTE_PORT | ||
说明: 相当于PHP中的服务器参数: $_SERVER["REMOTE_PORT"] | ||
|
||
名称: REMOTE_USER | ||
说明: PHP 好像未提供相关的$_SERVER值. | ||
|
||
名称: REMOTE_IDENT | ||
说明: PHP 好像未提供相关的$_SERVER值. | ||
|
||
名称: REQUEST_METHOD | ||
说明: 相当于PHP中的服务器参数: $_SERVER["REQUEST_METHOD"] | ||
|
||
名称: SCRIPT_FILENAME | ||
说明: 相当于PHP中的服务器参数: $_SERVER["SCRIPT_FILENAME"] | ||
|
||
名称: PATH_INFO | ||
说明: 相当于PHP中的服务器参数: $_REQUEST["PATH_INFO"] | ||
|
||
名称: QUERY_STRING | ||
说明: 相当于PHP中的服务器参数: $_SERVER["QUERY_STRING"] | ||
|
||
名称: AUTH_TYPE | ||
说明: 相当于PHP中的服务器参数: $_SERVER["AUTH_TYPE"] | ||
|
||
名称: TIME_YEAR | ||
说明: 服务器获取当前的年份值 | ||
|
||
名称: TIME_MON | ||
说明: 服务器获取当前的月份值 | ||
|
||
名称: TIME_DAY | ||
说明: 服务器获取当前的日值 | ||
|
||
名称: TIME_HOUR | ||
说明: 服务器获取当前时间的小时 | ||
|
||
名称: TIME_MIN | ||
说明: 服务器获取当前时间的分钟 | ||
|
||
名称: TIME_SEC | ||
说明: 服务器获取当前时间的秒 | ||
|
||
名称: TIME_WDAY | ||
说明: 服务器获取当天是星期几, 从星期日-星期六, 数字从 0-6 | ||
|
||
名称: TIME | ||
说明: 服务器获取当前的时间, 格式为: 年月日时分秒 | ||
|
||
名称: API_VERSION | ||
说明: apache 的 API 版本信息. | ||
|
||
名称: THE_REQUEST | ||
说明: 浏览器发给服务器的请求值. 不包括其他的头信息. | ||
|
||
名称: REQUEST_URI | ||
说明: 浏览器请求的资源信息. | ||
|
||
名称: REQUEST_FILENAME | ||
说明: 被请求的资源的在磁盘的物理地址. | ||
|
||
名称: IS_SUBREQ | ||
说明: 如果是 sub-request 则显示为 true, 否则为 false. |
57 changes: 57 additions & 0 deletions
57
_posts/2010-11-19-%e4%bd%bf%e7%94%a8ec2%e6%90%ad%e5%bb%ba%e5%85%8d%e8%b4%b9vpn.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
layout: post | ||
title: !binary | | ||
5L2/55SoRUMy5pCt5bu65YWN6LS5VlBO | ||
|
||
published: true | ||
meta: | ||
_edit_last: "1" | ||
_wp_old_slug: "%e4%ba%9a%e9%a9%ac%e9%80%8a%e4%b8%8a%e6%90%ad%e5%bb%ba%e5%85%8d%e8%b4%b9%e7%9a%84vpn" | ||
tags: | ||
- VPN | ||
type: post | ||
status: publish | ||
--- | ||
1. 安装软件包 | ||
<pre> | ||
<div id="LC2">$ sudo apt-get update</div> | ||
|
||
|
||
<div id="LC3">$ sudo apt-get install pptpd</div> | ||
|
||
</pre> | ||
2. 配置 | ||
|
||
1) 设置/etc/pptpd.conf | ||
在打开的pptpd.conf文件中修改如下 | ||
localip 192.168.0.1 | ||
remoteip 192.168.0.234-238,192.168.0.245 | ||
把着两行的注解#号去掉 然后保存 | ||
2) 设置/etc/ppp/pptpd-options | ||
在打开的pptpd-options 文件中修改如下 | ||
#ms-dns 10.0.0.1 | ||
#ms-dns 10.0.0.2 | ||
改成 | ||
ms-dns 208.67.222.222 | ||
ms-dns 8.8.8.8 | ||
|
||
一个是opendns 一个是谷歌的dns 然后保存 | ||
3) 设置 /etc/ppp/chap-secrets | ||
name pptpd passwd * | ||
|
||
这里是设置vpn登录的用户名密码的 name 是你的登录用户名 password 是你的vpn登录密码 | ||
|
||
3 然后重启pptpd | ||
sudo /etc/init.d/pptpd restart | ||
|
||
4 设置打开转发 | ||
echo "1">/proc/sys/net/ipv4/ip_forward | ||
|
||
修改/etc/sysctl.conf | ||
net.ipv4.ip_forward=1 去掉注释 | ||
然后 sudo sysctl -p | ||
|
||
sudo iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE | ||
<div>现在你还是链接不上vpn 因为亚马逊的防火墙 还要把端口 1723 打开</div> | ||
<div><a href="../wp-content/uploads/2010/11/amazon_29.png"><img title="amazon_29" src="../wp-content/uploads/2010/11/amazon_29-1024x626.png" alt="" width="640" height="391" /></a></div> | ||
<div>到这里设置vpn 就完成了 现在你可以用vpn翻墙了。</div> |
27 changes: 27 additions & 0 deletions
27
...%e7%9c%8b%e5%99%a8%e7%9a%84%e7%9f%ad%e4%bb%a3%e7%a0%81-create-a-pdf-viewer-shortcode.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
layout: post | ||
title: !binary | | ||
5Yib5bu65LiA5LiqUERG5p+l55yL5Zmo55qE55+t5Luj56CBIENyZWF0ZSBh | ||
IFBERiB2aWV3ZXIgc2hvcnRjb2Rl | ||
|
||
published: true | ||
meta: | ||
_edit_last: "1" | ||
_wp_old_slug: "" | ||
tags: [] | ||
|
||
type: post | ||
status: publish | ||
--- | ||
The first step is to paste the following code into your <em>functions.php</em> file: | ||
|
||
第一步你要添加下面的代码到你的<em>functions.php文件</em> | ||
<pre>function pdflink($attr, $content) { | ||
return '<a href="http://docs.google.com/viewer?url=' . $attr['href'] . '">'.$content.'</a>'; | ||
} | ||
add_shortcode('pdf', 'pdflink'); | ||
</pre> | ||
Once you saved the file, you'll be able to use the shortcode on your posts and page. Here is the syntax: | ||
|
||
你能用类似下面的短代码添加到你的文章 或者页面。 | ||
<pre>[pdf href="http://yoursite.com/linktoyour/file.pdf"]View PDF[/pdf]</pre> |
25 changes: 25 additions & 0 deletions
25
...1%e6%9c%89%e7%94%a8%e7%9a%84%e7%9f%ad%e4%bb%a3%e7%a0%81-get-rid-of-unused-shortcodes.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
layout: post | ||
title: !binary | | ||
5Y676Zmk5rKh5pyJ55So55qE55+t5Luj56CBIEdldCByaWQgb2YgdW51c2Vk | ||
IHNob3J0Y29kZXM= | ||
|
||
published: true | ||
meta: | ||
_edit_last: "1" | ||
_wp_old_slug: "%e5%8e%bb%e9%99%a4%e6%9c%aa%e4%bd%bf%e7%94%a8%e7%9a%84%e7%9f%ad%e4%bb%a3%e7%a0%81-get-rid-of-unused-shortcodes" | ||
tags: | ||
- !binary | | ||
V29yZHByZXNzIOenmOivgA== | ||
|
||
type: post | ||
status: publish | ||
--- | ||
Simply run the following SQL query on your WordPress database, using the command line client or PhpMyAdmin. In this example, I assume the unused shortcode is <em>[tweet]</em>. | ||
<strong>Don't forget to backup your database before using this query.</strong> | ||
|
||
<strong>只需要用mysql命令行或者</strong>PhpMyAdmin <strong>去运行下面的sql代码 。</strong> | ||
|
||
<strong>在这个例子假设你有[tweet]</strong>短代码需要去除 | ||
<pre>UPDATE wp_post SET post_content = replace(post_content, '[tweet]', '' ) ; | ||
</pre> |
29 changes: 29 additions & 0 deletions
29
...a1%e6%9c%89%e7%94%a8%e7%9a%84post%e7%89%88%e6%9c%ac-get-rid-of-unused-post-revisions.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
layout: post | ||
title: !binary | | ||
5Y676Zmk5rKh5pyJ55So55qEcG9zdOeJiOacrCBHZXQgcmlkIG9mIHVudXNl | ||
ZCBwb3N0IHJldmlzaW9ucw== | ||
|
||
published: true | ||
meta: | ||
_edit_last: "1" | ||
_wp_old_slug: "" | ||
tags: | ||
- !binary | | ||
V29yZHByZXNzIOenmOivgA== | ||
|
||
type: post | ||
status: publish | ||
--- | ||
Just run the following query on your WordPress database, and all revisions (As well as meta associated with it) will be deleted from your database. | ||
Of course, do not forget to make a backup of your database before running the code. | ||
|
||
只需要在你的Wordpress 数据库执行下面的sql语句。 所有的文章版本 都会 从你的数据库去除掉 | ||
<pre>DELETE a,b,c | ||
FROM wp_posts a | ||
WHERE a.post_type = 'revision' | ||
LEFT JOIN wp_term_relationships b | ||
ON (a.ID = b.object_id) | ||
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id); | ||
</pre> | ||
<strong><em> </em></strong> |
Oops, something went wrong.