Archive for the ‘Web Development’ Category

Finally! Nexty 1.01.A Released

Saturday, September 22nd, 2007

I have released Nexty 1.01.A. If you are a user of Nexty, I will recommend that you switch to the new version.

Changelog

Search
Search for tasks, projects and reminders
Next Action
Dedicated page for the next action - and only that
Inbox Feature
Add a lot of tasks in one go using the inbox
Linux Command Line
A script to control Nexty from the Linux command line.
Code uses iFrame
iFrame is my PHP framework
Bug Fixs
Too many to list
Better Installer
Will not overwrite the old data
Printing Support
Well, its better than before

To Learn more…

Seinfeld Calendar - Simple way to Force Yourself to Create Content Regularly

Sunday, September 16th, 2007

BinnyVA.com

I created an RSS aggregater for my site BinnyVA.com that aggregates the content from all my sites. The basic idea is to build a Seinfeld Calendar that will force me to continually publish posts - at least 1 per day.

It is very simple to create - whole system is contained in the following files…

fetcher.php

This will run once a day as a cron job. It downloads the feeds for all my sites, parses the XML and inserts the new posts into the database.

The download is done by my load PHP function. It uses the curl library.

The XML parsing uses the xml2array() PHP function. Currently I parse only the RSS format - I am completely ignoring the atom format.

Finally the data is inserted into the database - the following data is stored…

  • Title
  • Link
  • Date
  • Summary
  • Full Content
  • Categories/Tags

The full file is around 100 lines long.

index.php

This is a simple calendar scripts that lists all the posts of each days of one month. Includes a navigation to enable the visitor to go to the past months as well.

Other Files

There is a bit of mod_rewrite code that make sure that the URL are very clean. For example, the URL for April 2007 is http://www.binnyva.com/2007/04/.

The mod_rewrite for this is in the .htaccess file…


RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)/([0-9]+) index.php?year=$1&month=$2

Don’t Break the Chain

Now all you have to do is make sure that each day has at least one post in it. This system had me creating content continually for the last two months.

If you are looking for an easier way to create the calendar, try out Don’t break the chain.

LinDesk - Linux on the Desktop

Saturday, September 1st, 2007

LinDesk

I have a new blog - LinDesk. LinDesk concentrates on the use of Linux on the Desktop. I am trying to keep it distro agnostic - but there is a slight leaning towards Fedora - as it is the distro I am using. Also, you might find a disproportionate amount of articles about KDE.

Actually this blog has been around for some time. The first article appeared on April 8. But I did not announce it so that there can be a build up of articles before it goes public.

Take a look at LinDesk - and if you are a fan of the Linux operating system, subscribe.

Some Popular Posts

So what do you guys think of the new blog? Is it a good move? Or am I moving towards an early burnout?

Between Web Application and Desktop Applications

Sunday, August 26th, 2007

There is a distinct line between web application and desktop applications. But over the last few years, this line is becoming thinner. Due to faster internet connection and technologies like ajax, web applications are becoming much faster and more responsive. And, if you have a local web server installed, a ‘web’ application can become desktop application.

I have a web server(Apache), and a database server(MySQL) running at all times on my local system. Since LAMP is my preferred platform of development, if I need a new software, I will create it on LAMP. A good example of this is Nexty. Over time, I have discovered that web application can be used as desktop applications. All you need is a web server, a database server and a browser.

There must be some changes to the current model to make this system work. These are a few I could think of…

  • Web Server must run as the current user. That way, you can read/write to any file using PHP(or equivalent).
  • The application must not be available over the network. Or, the web server must only accept connections from 127.0.0.1
  • An installer for these kind of applications must be made.

Advantages

  • Familiarity: People are already used to web applications - so it will be easy to switch.
  • User Customizable: Users can change the appearance of the application(user stylesheets), and to a limited extent, the functionality(GreaseMonkey).
  • Open Source: If the code is in PHP or Ruby on Rails, or anything similar, the code will be available for study or even modification.
  • Cross Platform: The same program can be installed in Windows or Linux or whatever - as long as it has a Web server.

Disadvantages

  • Imaginary: As of yet no such system exists.
  • High Level: The system will not be able to do low level system operations.
  • Limited: There will be some very serious limitation to the application unless the current systems are modified. For example, the browser cannot read or write to the filesystem.

I have been using some web applications as desktop applications for a while now - these include WordPress(for keeping notes), activeCollab(project management), Nexty(to do list), and Tiker(time tracker).

Nexty Updates

Wednesday, August 22nd, 2007

Nexty Logo

I made some more updates to nexty. Still not packaged - give me a little more time. In the meantime, try out the demo

There is one really cool feature in this release - but it is for Linux Users only. I made a command line script that integrates with Nexty - you can add tasks directly from the console. It needs the curl command - so not available in windows.

But then again, who uses the terminal in windows?

Anyway this uses the concept I introduced in CLI Twitter. If you want to try it, login to Nexty and go to the settings page. If you are on a linux system, you will see a Download Nexty Shell Script section. Just follow the instructions there.

Demo for Nexty 1.01.A Uploaded

Thursday, August 16th, 2007

Nexty Logo

I uploaded the demo for the new beta version of Nexty today. The code is too ‘beta’ to be packaged and released - so I am just uploaded the demo. If the bugs are found and fixed soon, I will release the code into the wild. If you cannot wait for the code, it is available at the SVN repository.

Whats New…

A few new features are…

  • Search
  • Next Action
  • Inbox Feature
  • Code uses IFrame
  • And more…

Please try out the demo and let me know if you spot any errors. That is the whole point of uploaded the demo.

Nexty 1.01.A Demo

Nexty 2 will use PHP 5

Saturday, August 4th, 2007

GoPHP5

The next version of nexty is coming out very soon - and unlike the last version, Nexty 2 will require PHP 5.

The main reason behind this change is GoPHP5. Go PHP 5 is a movement to promote the use of PHP5 in hosting servers and for projects.

Another reason for this decision is that iFrame, the framework I used in Nexty, uses PHP 5.

If you are stuck with PHP 4, I cannot help it. You can still use the first version. But if you have a choice, PHP 4 is dead - move on.

More on GoPHP5

Keyboard Shortcuts JavaScript Library

Saturday, July 21st, 2007

I have created the second version of the JavaScript Shortcut Library. It is one of my more popular scripts. This script eases the work involved in making shortcuts in JavaScript.

Despite the many JavaScript libraries that are available today, I cannot find one that makes it easy to add keyboard shortcuts(or accelerators) to your javascript app. This is because keyboard shortcuts where only used in JavaScript games - no serious web application used keyboard shortcuts to navigate around its interface. But Google apps like Google Reader and Gmail changed that. So, I have created a function to make adding shortcuts to your application much easier.

Changelog

  • The single function method was abandoned for an object with two functions
  • Shortcut Remove function added
  • New option to disable shortcuts in textarea, input fields.

If you are using this script in any of your projects, please switch to the latest version.

Previous Version Documentation

Web Installer: The Code

Wednesday, July 11th, 2007

The last two posts on web installer did not include any code. I wanted to dump all code into one post - this is it. Please note that this is what I did - you don’t have to copy my code as it is. Just look at the code and modify it according to your needs.

Getting Database Details

The Form/Frontend

<form action="" method="post">
<h1>Installation : Step 1</h1>
Please provide the database connection details...
<fieldset>
<legend>Database Details</legend>

<label for='host'>Database Host</label><input type='text' name='host' value='localhost' /><br />
<label for='db_user'>Database User</label><input type='text' name='db_user' value='root' /><br />
<label for='password'>Database Password</label><input type='text' name='password' /><br />
<label for='database'>Database</label><input type='text' name='database' value='nexty' /><br />
</fieldset>

<input type="hidden" name="step" value="2" /><br />
<input type="submit" name="action" value="Continue >>" /><br />
</form>

Backend

Make sure that the given database details are correct.

// The First step is Setting up Database connection
//					   (the '2' is NOT a typo)
if($_REQUEST['step'] == 2) {
	//Save the data to the Session
	if(isset($_REQUEST['host'])) $_SESSION['host'] = $_REQUEST['host'];
	if(isset($_REQUEST['db_user'])) $_SESSION['db_user'] = $_REQUEST['db_user'];
	if(isset($_REQUEST['password'])) $_SESSION['password'] = $_REQUEST['password'];
	if(isset($_REQUEST['database'])) $_SESSION['database'] = $_REQUEST['database'];
	if(isset($_REQUEST['url'])) $_SESSION['url'] = $_REQUEST['url'];

	if(mysql_connect($_SESSION['host'],$_SESSION['db_user'],$_SESSION['password'])) { //Try to connect to the DB.
		$QUERY['success'][] = 'Connection to Database server successful';

		if(mysql_select_db($_SESSION['database'])) {//Select the provided database.
			$QUERY['success'][] = "Database '$_SESSION[database]' selected";

		} else {
			$QUERY['error'][] = 'The given database('.$_SESSION['database'].') does not exist. Please povide a valid database.';
			$_REQUEST['step'] = 1;
		}
	} else {
		$QUERY['error'][] = 'Unable to connect to the database. Make sure that the entered details are correct';
		$_REQUEST['step'] = 1;
	}
}

Notice the over use of $_SESSION? That will come in use if I decide to add a Back button that enables the users to modify the data entered previously.

Database Creation

//Create the database only if it does not exist
//See if the database exists
$tables_sql = mysql_query("SHOW TABLES") or die(mysql_error());
$necessary_tables = array('Context','Project','Reminder','Setting','Task','TaskContext','User');
while($table = mysql_fetch_row($tables_sql)) {
	$necessary_tables = array_diff($necessary_tables,array($table[0])); //Remove the table from the array if it exists
}

//If there are no tables in the array that means that the all the necessary tables are present in the Database
//If some tables are missing, that means we have to create those tables...
if($necessary_tables) {
	$quries = <<<END
-- Insert all the SQL to create the necessary tables here...
END;

	//Execute all the queries
	$all_quires = explode(";",$quries);
	$query_count = 0;
	foreach($all_quires as $query) {
		$query = trim($query);
		if($query) {
			@mysql_query($query);
			$query_count++;
		}
	}
	$QUERY['success'][] = "Database Populated.";
} else {
	$QUERY['error'][] = "Tables already in Database - I did not overwrite it. If you want to remove the old data, please delete the tables and run the installer script agian.";
}

Saving the Database connection details


//I don't know how to escape the $ charector in heredocs - so I did this...
$config = '$config';//Heh, Heh ;-)
$system_installed = '$system_installed';
$configuration = <<<END
<?php
//Configuration file for Nexty
$system_installed = true;
$config = array(
	'db_host'		=>	'$_SESSION[host]',
	'db_user'		=>	'$_SESSION[db_user]',
	'db_password'	=>	'$_SESSION[password]',
	'db_database'	=>	'$_SESSION[database]',
	'url'			=>	'$_SESSION[url]',
	'absolute_path'	=>	'$abs'
);

END;
if(is_writable('../configuration.php')) {
        // ...Write the $config text into the configuration.php file...

	$QUERY['success'][] = 'Saved the configuration file. <a href="'.$_REQUEST['url'].'">Go to Nexty</a>';
} else {
	$QUERY['error'][] = 'Configuration file (configuration.php) is not writable. Please copy the configuration code and enter it into the "configuration.php" file. Then press continue.';
}

See the install folder for Nexty in the Subversion server.

3 Simple Steps to create a Web Installer

Friday, July 6th, 2007

Creating a web installer is not hard - as a matter of fact - it is downright easy. You just have to know a few things. Get the database details, create the database, save the details. That’s it!

Getting Database Details

Nexty Installer Screenshot

A simple four field form will suffice. The important thing to remember is that the data must be saved as session variables - as we are using a multi-page form.

As soon as you get the DB details, try to connect to the database and confirm that the DB details is correct. If the connection attempt fails, take the user back to the DB details form. Else go to step two.

Insert Initial Data

This part is easy - just run a bunch of SQL statements to create the necessary table structure and insert the initial data.

Save the Details

This should be the last step of the installation. Just take all the data from the session variables and write it to a file, say ‘configuration.php’. Write the data as PHP code - so all you have to do to retrieve the data is include the file.

The code for the installer in the next post.

Subscribe to Feed