drupal 快速入门
Author: Infong Date: 16 Nov 2012 Category: spl Comments
http://drupal.org/node/322506
A good memory as bad written.
Author: Infong Date: 22 Oct 2012 Category: spl Comments
在新版的 zencart 中,上传的图片不会被命名成其它文件,从而导致后台上传的图片都是原始的文件名称,一来不安全,二来经常会跟现有的图片冲突,三来又会有一些带有 urlcode 的文件名不能正常访问。
所以就想对它的文件名进行重命名:
修改 ADMIN/includes/classes/upload.php
类。在第约 72 行:
- $this->set_filename($file['name']);
+ $this->set_filename(md5(time()).'.'.end(explode('.',$file['name'])));
如果想连上传目录也一起改掉的话,可以在 ADMIN/includes/modules/new_product_preview.php
的第 15 行插入:
// 上传目录的变更
+ if(empty($_POST['img_dir'])) {
+ $_POST['img_dir'] = date('Ym') . '/';
+ }
+ if(!is_dir(DIR_FS_CATALOG_IMAGES . $_POST['img_dir'])) {
+ mkdir(DIR_FS_CATALOG_IMAGES . $_POST['img_dir']);
+ }
$products_image->set_destination(DIR_FS_CATALOG_IMAGES . $_POST['img_dir']);
如果有用到 Image_Handler 的话,也要进行相应的更改,ADMIN/includes/ih_manager.php
约 90 行:
if ( $_POST['imgNewBaseDir'] != '') {
$data['imgBaseDir'] = $_POST['imgNewBaseDir'];
} else {
+ if(empty($_POST['imgBaseDir'])) {
+ $_POST['imgBaseDir'] = date('Ym') . '/';
+ }
$data['imgBaseDir'] = $_POST['imgBaseDir'];
}
这样,上传图片的时候,就会按像 images/201210/64c15fdbab0ccaa5f79875381ffccf86.jpg
形式进行重命名了。
Author: Infong Date: 04 Sep 2012 Category: spl Comments
之前有用 Nginx + passenger 作为 Ruby on Rails的服务器,但因为我的 Ruby 是用 rvm 装的,所以,每次都得重新编译 Nginx,显得比较麻烦。
所以打算试试用 Unicorn 来作为 ror 的后端。
安装unicorn:
sudo gem install unicorn
创建网站配置文件(myproject是项目名称):
sudo mkdir /etc/unicorn
cd /etc/unicorn/
sudo nano /etc/unicorn/myproject.conf
在网站里再创建一个unicorn配置文件
nano /www/myproject/config/unicorn.rb
内容如下:
# Minimal sample configuration file for Unicorn (not Rack) when used
# with daemonization (unicorn -D) started in your working directory.
#
# See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete
# documentation.
# See also http://unicorn.bogomips.org/examples/unicorn.conf.rb for
# a more verbose configuration using more features.
app_path = "/www/myproject"
listen 8080 # by default Unicorn listens on port 8080
worker_processes 2 # this should be >= nr_cpus
pid "#{app_path}/tmp/pids/unicorn.pid"
stderr_path "#{app_path}/log/unicorn.log"
stdout_path "#{app_path}/log/unicorn.log"
设置unicorn启动脚本:
可以参考官方的示例
启动unicron/path/to/init.sh start
修改nginx的配置文件,加入unicorn的代理设置:
可以参考官方的示例
Author: Infong Date: 19 Nov 2011 Category: code Comments
I’m using Jekyll to convert my markdown and Pygments for syntax highlighting.
Here is the error maruku displays:
Liquid error: undefined method `join' for "\n song_info = []\n for song in songs:\n song_info.append(song.name) \n":String
The markup is as follows:
song_info = []
for song in songs:
song_info.append(song.name)
Testing Pygments in iPython produces no errors.
So I reverted the liquid gem to version 2.2.2 as a workaround. Seems like a bug in the 2.3.0 version’s pygments support, or Jekyll’s use of it.
$ sudo gem uninstall liquid
$ sudo gem install liquid --version '2.2.2'
Author: Infong Date: 18 Nov 2011 Category: uncategorized Comments
最近也看了一些 markdown 的东西,同时也试着写了几个文档,感觉它写文档、日志之类的确实很舒服。
正好,之前也在一个同事那里看到用 Jekyll 架 Blog 所以我也干脆弄个试试。
唔,这个模板是 clone 了同事的,所以。。。有空了弄一个咯~呵呵。