a simple blog system, by dorainm
dorainm@gmail.com
C语言编写的blog程序,会让读者感到惊异吧?
dorainm既不会jsp,又不擅长php,但是有个域名和一台24小时在线的主机
不要浪费不要浪费
于是就依靠自己仅有的一点点HTML知识,制作一个blog程序,发布资料
看看程序
引用:
[dorainm@localhost www]$ ls
html_add.h html_contact.h html_function.o image
html_add.o html_contact.o html_index.h main.c
html_config.h html_function.h html_index.o readme.txt
[dorainm@localhost www]$
提供这么多亏 .o, html_config.h 是配置文件,
大家可以根据自己需求,来修改
[dorainm@localhost www]$ more html_config.h
复制内容到剪贴板
代码:
#ifndef __HTML_CONFIG
#define __HTML_CONFIG
/* system */
#define HTML_LIST "list"
#define HTML_LIST_TEMP "list.temp"
#define HTML_BKCOLOR "#3A5777"
#define HTML_TXCOLOR "#FFFFFF"
#define HTML_MARGIN "20"
#define HTML_FONT "Courier New"
#define HTML_FSIZE "2"
/* domain */
#define HTML_HOMEPAGE "www.dorainm.org"
/* url */
#define HTML_HOME "index.html"
#define HTML_CONTACT "contact.html"
/* contact */
#define HTML_AUTHOR "dorainm"
#define HTML_EMAIL "dorainm@gmail.com"
#define HTML_IMAGE "./image/dorainm.gif"
#endif由于程序在utf-8写的,不好做中文注释,dorainm的E文就不拿出来贻笑大方了!
现在我们来编译主程序
引用:
[dorainm@localhost www]$ gcc -o simpleblog main.c html_add.o html_function.o html_contact.o html_index.o
[dorainm@localhost www]$ ls
html_add.h html_contact.h html_function.o image simpleblog
html_add.o html_contact.o html_index.h main.c
html_config.h html_function.h html_index.o readme.txt
[dorainm@localhost www]$
编译好了,我们运行看看语法:
引用:
[dorainm@localhost www]$ ./simpleblog
simple blog maker by dorainm, dorainm@gmail.com
usage :
./simpleblog [options] [arg...]
option:
--add [content_file] [title] [html_file]
add a new html
--check check whether items live, or delete
--clear clear all the items in [ list ]
--contact update the [ contact.html ] them file
--index update the [ index.html ] html file
--version display the version of this program
arg...:
content_file a text file for the content of new html
title the title of the new html
html_file file name for the new html
[dorainm@localhost www]$
我们给blog撰写第一篇文章吧
引用:
[dorainm@localhost www]$ echo "i am the first, have you see?" >> first.txt
[dorainm@localhost www]$ ./simpleblog --add first.txt "first comes" first.html
simple blog maker by dorainm, dorainm@gmail.com
create first.html html file ... successfully
update list list file ... successfully
update index.html html file ... successfully
[dorainm@localhost www]$
生成了第一篇文章,我们继续做一篇吧
引用:
[dorainm@localhost www]$ echo "i am the first, have you see?" >> first.txt
[dorainm@localhost www]$ ./simpleblog --add first.txt FirstComes first.html
simple blog maker by dorainm, dorainm@gmail.com
create first.html html file ... successfully
update list list file ... successfully
update index.html html file ... successfully
[dorainm@localhost www]$ clear
[dorainm@localhost www]$ echo "am i late? no, i am the second" >> second.txt
[dorainm@localhost www]$ ./simpleblog --add second.txt NotLate second.html simple blog maker by dorainm, dorainm@gmail.com
create second.html html file ... successfully
update list list file ... successfully
update index.html html file ... successfully
[dorainm@localhost www]$ ls
first.html html_config.h html_function.o index.html second.html
first.txt html_contact.h html_index.h list second.txt
html_add.h html_contact.o html_index.o main.c simpleblog
html_add.o html_function.h image readme.txt
[dorainm@localhost www]$
看到没有,blog的主页 index.html 和 我们添加的 2篇 first.html second.html 都已经存在了
我们浏览主页看看:
引用:
[dorainm@localhost www]$ lynx index.html
dorainm's homepage
dorainm's homepage
home contact
---------------------------------------
NotLate 03-05-2007
FirstComes 03-05-2007
by dorainm, dorainm@gmail.com
---------------------------------------
power by dorainm
Commands: Use arrow keys to move, '?' for help, 'q' to quit, '<-' to go back.
Arrow keys: Up and Down to move. Right to follow a link; Left to go back.
H)elp O)ptions P)rint G)o M)ain screen Q)uit /=search [delete]=history list
进入第一篇文章
引用:
<<< not late
not late
--------
am i late? no, i am the second
by dorainm, dorainm@gmail.com 03-05-2007
---------------------------------------
power by dorainm
Commands: Use arrow keys to move, '?' for help, 'q' to quit, '<-' to go back.
Arrow keys: Up and Down to move. Right to follow a link; Left to go back.
H)elp O)ptions P)rint G)o M)ain screen Q)uit /=search [delete]=history list
我们的简易blog系统的信息发布功能就是这个样子咯
当然,主程序还有生成 contact.html 主页的主人的通讯方式的网页
清理旧帖子、更新主页等功能,实践所迫有些功能还没有完善 :)