This week I started on the user registration. At the moment, new users can register themselves with Crisoft, providing information like username and password and (if available) and email address, url and description. The email will become mandatory soon, because I want to build a email-based activation to prevent spam users to register. At the moment new users are marked as “inactive” in the database and they can not login yet.

I added a simple pagination component, that builds an alphabetical navigation for all the recipes in the database. It’s written by myself, because I had no access to the official pagination helper, but it does its job. ;-) Maybe I replace it with the official version soon.

Finally, I added the model Role that hopefully helps to give users a role and access rights. I don’t have a feeling how to code that yet, but I think having models like Role and Right will help with the setup.

In CakePHP it is really easy to force users to login before executing actions. I inserted this functionality today and I’m very happy that it is so flawless.

The class app_controller.php has a function now that checks the current session. The function is used in important actions to functions to protect the content from unregistered users. This content is the user list or the “add recipe” functionality. I consider actions that change content or reveal too much information as important and try to protect them.

The mechanism used to redirect a user to the login has a nice feature now: it allows the redirect target to be specified when checking the session information. So, after login the user will be redirected to the proper page again and continues it’s journey without being interrupted. I think this is important for the usability and the experience of Crisoft. I try to figure out how to manage those things with PHP and CakePHP, and maybe I find a new way to solve this in a few weeks. Until then, you can go check out the files in the CVS and maybe you have some comments and feedback on it. I’ll be happy to hear about your opinion!

This week I was able to add the first stub functionality for the login. I use a simple User model and a password that’s MD5ed. I need to secure the important Actions now. I hope to finish the login next week.

And I changed some of the relations between the models. I think I did a great mess when I created the model. Slowly, I get into the whole hasMany, belongsTo and hasAndBelongsToMany thing. ;-)

Due to SPAM issues I removed the wiki today. Maybe I start using the new sourceforge service to build a new wiki without spam, you never know…

Long time, no article. I was very busy and even more of a lazy bummer. I hadn’t worked on Crisoft for several month, but now I try to get back into it again. I travel a lot for some months now, so I have lots of time in the trains to get some things done.

I started with adding new views to add and edit recipes, a new reference to a class called Season, that is intended to provide localization later. I think I can add some more things like detailed pages to add and edit recipes, categories, types, comments and users. I try to read about how user management can be organized with CakePHP and implement a simple to use user management with access control. I imaging Crisoft to handle different roles with different rights, i.e. Administrator, Editor and User. But that’s -again- too much to talk about now.

What I want to achieve in, let’s say, 4 weeks is a first release of the CakePHP branch that allows user to convert the existing database and use it to browse, add and edit new recipes. Wish me luck! :-)

Today I added some more Views to the little set of already finished pages in my long-taking journey to replace all scaffolded pages with my own creations. I added a simple index page for the recipes that is showing a random recipe at the moment. It could need some more tweaking, as I’m getting all recipes from the database and only using 1 to display its contents… this should be moved into a specific query to the SQL database to avoid the creation of many PHP variables.

Another View that is already in the creation process is the index page for categories and a simple view/edit combination. This is very easy because a category entry has only two fields: ID and category. So it isn’t too hard to create a page. :-) I added a basic validation using CakePHPs mechanisms and it is working fine. The result page when saving the edit is just a flash message that you have to click to continue, but I try to add some more AJAX style with a fading message box later.

I think I can work on CR2.0 in the next days, so there will be more change to come! Check the CVS repository for code updates.

Today I added some little files to add first XML export support to the new, cakephp-based Crisoft Ricette 2.0 branch. It is a stupid little layout file and a very basic function in the recipes controller to display the recipe as a pure XML page. It is based on RecipeML, but not on the full specification yet. Maybe I can blow it up this evening to support the complete RecipeML schema, but I’d be happy to go with just the sections head, ingredients and description.

The split of single ingredients and description steps makes it neccessary to have a format convention on the input fields of ingredients and description: Only one ingredient on a single line, only one step of description on a single line, each terminated with \n. Maybe this could be solved via multiple input fields for the ingredients, with an AJAX-style + button to add a new ingredient. This would lead to an AJAX autocomplete on that inputfield on already entered ingredients. That leads to a new database table, holding all entered ingredients or just their names. This would lead to another table with amount and ingredient connections… that would lead to a major stuck in my progress. :-) I think I’d go with the format convention of \n terminated lines for now.

I’d even like to have the recipes export themselves to RSS so anyone can include them in a feed or another mashup application. We’ll see how this will end.

Additionally I added a few layout pages, so the default scaffolding look of CakePHP is no more. :-) I try to setup a basic theme again, like the silverish slick I did while working on the pre1.0 version of Crisoft Ricette. It will be fully styleable via CSS too, to allow all users to adopt it to their own websites.

I connected Images to Recipes in my CakePHP models now, so if you open the recipe details page you can see all attached images. I want to use phpthumb to generated thumbnail for all images so I added the package to the vendor directory. The workflow for this should enable the user to upload an image while editing recipe details and phpthumbnail should then generate the thumbnail on the fly. This is only possible if the GD library is installed, so the user should disable this feature from the configuration page if neccessary. If it is turned off, the recipe details page could show the full image or just links to the image files.

Today I had an issue with my installation of CakePHP on my local XAMPP development installation. The prototype of the new Crisoft won’t show up! I had no idea of what was going wrong, so I took a deep look in my httpd.conf, the error.log and the .htaccess of CakePHP. And now Crisoft is up and running.

Here is what I my configuration files look like:

httpd.conf

You have to load the Module mod_rewrite (and perhaps the mod_cache) to enable CakePHPs scaffolding magic. After that I created an Alias to make my project directory available to XAMPP. This enables me to load the URL http://localhost/crisoft in my webbrowser and have access to the XAMPP tools in the default DocumentRoot, too. You should do that too if you want to develop with XAMPP.

...
LoadModule cache_module modules/mod_cache.so
LoadModule rewrite_module modules/mod_rewrite.so
...
<IfModule alias_module>
ScriptAlias /cgi-bin/ "C:/Programme/xampp/cgi-bin/"
Alias /crisoft "C:/enter/your/path/to/crisoftricette/"
</IfModule>
...
<Directory "C:/enter/your/path/to/crisoftricette/">
    Options FollowSymLinks Includes
    AllowOverride All
	Order allow,deny
	Allow from all
</Directory>

core.php

Next was the $CAKEPHP/app/config/core.php from CakePHP. The default setting should work, but be sure to check if this line in your file:

...
//    define ('BASE_URL', env('SCRIPT_NAME'));
...

.htaccess

What I didn’t understand was the need of a new line in all .htaccess files. I had to tell Apache to apply the RewriteRules to my Alias directory. This was a bit hard, but the CakePHP Google Group is a good place to search for help.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /crisoft
RewriteRule    ^$    webroot/    [L]
RewriteRule    (.*) webroot/$1    [L]
</IfModule>

So this was my little fight with XAMPP and CakePHP. I will include this in a small document and upload it to the CVS branch. If you’re interested in the current state, please feel free to checkout the current dev snapshot. But don’t expect it to run. And if you don’t know if it is worth the pain, here are 2 screenshots of the current state:

Current development screenshot

This is the “recipe details” page, automagicall created by CakePHP. I will design a better one later, but having CakePHP generating the page is so comfortable for development, because you don’t have to change the page for every little change in the source code.

Current development screenshot

This is the best at all: Relations! You can tell CakePHP that your model Recipe hasMany Comments and belongsTo Category. And so you click around the pages that are already LINKED TO EACH OTHER! :-)

Yesterday I branched Crisoft in the CVS tree to allow some tests for the 2.0 update. It will be based completly on CakePHP, a great framework for rapid application development and I finally made it to import old recipes into the new database structure. I have to improve the script db_upgrade.php which will handle the process to convert all fields into the correct new values. When I finish the upgrade script, I will release a very-very-early-alpha of the new Crisoft 2.0, but it will come without any plugins and extra stuff - just the plain view/edit/delete pages for the recipes, comments, categories and users.

I hope you’re all back then to give me feedback in our bug and feature tracker. :-)

Next Page »