Welcome
Hello all and welcome to my first post! I am excited to give you guys some insight into what I have been doing for the last week. Feel free to completely ignore this post if this is not your "cup of tea".
Two months ago I was asked by the MESH developer team to make a blog where we could post some updates; I silently hated the idea. I mean, why should I spend countless hours making something that would simply distract me from the actual project, but worse than that was the idea that it might never be used. (You might think it far fetched for me to make such assumptions, but I still had a sour taste from a previous experience. In my prior employment, I received countless requests to make a polling/voting system and after I made it, it was barely even used. Needless to say, I wasn't thrilled.) So then why did I change my mind?
Two weeks ago my boss approached me to start revamping the project website (this website) and after discussing some design aspects, my boss mentioned he wanted the website to have a way to post news updates. After some thinking I realized that the goal of a developer blog is very similar to a "news" section and although I had initially disliked the idea I started thinking one, I started thinking about it from technical standpoint. I mean what exactly would be required to do it?
Unbeknownst to me, I was trapped in my own curiosity.
How to start?
Needless to say, I started working on it. Obviously I couldn't simply write the blogs as static webpages, that was crude and more importantly it required that I be in "stand-by mode" to post new blog/news updates. Nope that was not acceptable. Then perhaps I should go the WordPress route? That peaked my interest a bit, but ultimately I decided against it. I won't explain why, but these guys share a similar opinion to my own. So then what should I do?
I decided to do it myself. Not only would this be funner than trying to learn an established CMS system, but it would also be educational as this would be the first time I created such a system.
Getting it done
The database
CREATE TABLE `user` ( `uid` int(11) NOT NULL, `email` varchar(255) NOT NULL, `fname` varchar(100) DEFAULT NULL, `lname` varchar(100) DEFAULT NULL, `access_level` int(11) NOT NULL, `password` varchar(60) );
ALTER TABLE `user` ADD PRIMARY KEY (`uid`);
CREATE TABLE `post_tags` ( `post_tag_id` int(11) NOT NULL, `tid` int(11) NOT NULL, `pid` int(11) NOT NULL );
ALTER TABLE `post_tags` ADD PRIMARY KEY (`post_tag_id`);
CREATE TABLE `post` ( `post_id` int(11) NOT NULL, `uid` int(11) NOT NULL, `title` varchar(255) NOT NULL, `content` longtext NOT NULL, `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `last_updated` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP );
ALTER TABLE `post` ADD PRIMARY KEY (`post_id`);
CREATE TABLE `tags` ( `tid` int(11) NOT NULL, `name` varchar(120) NOT NULL, `uid` int(11) NOT NULL )
ALTER TABLE `tags` ADD PRIMARY KEY (`tid`);
I know everything is far from perfect. (I mean I even ignored foreign keys).
The editor
The next step was actually being able to insert the required information into the database. The way I did this was simple, create a form which submits the data. However there was one small problem. How would I get all the fancy text we wanted? I decided to use a JS library called NicEdit. Not only was it simple to implement but it came with a sufficient amount of tools to use (Such as an image upload feature). NicEdit does just fine.
After uploading information and sanitizing it (against xss attacks etc...) , then it is stored into the database. There is one last part I want to mention, the tags.
Tags
Implementing the tagging part was actually alot easier than I though it would be. All it involved was searching to see if a tag was already inserted and if not creating a new tag. There may be better ways to do this, but this worked for me. Finally a made a filter to search posts based on their tags. It works, but it needs alot of work. Feel free to send me some feedback, under CONTACT if you have any questions.