martes, 30 de marzo de 2010

How to start publishing your project in sourceforge

How to start publishing your project in sourceforge

This article is a step/by/step guide to those who want to maintain their development projects in sourceforge.net, with svn support for sharing their source code and a project web site.

First of all I suppose you have already created a new project in sourceforge.net. The important thing to remember is the project's unix name. In the following examples, my sourceforge.net user name is cancerbero_sgx and my project unix name is yui4java. As an administrator of your new project, using a linux shell, you can do the following activities:

copy files and directories with rsync:

# rsync -avP -e ssh foo.txt cancerbero_sgx,yui4java@web.sourceforge.net:htdocs/
# rsync -avP -e ssh /home/sgurin/dir1 cancerbero_sgx,yui4java@web.sourceforge.net:htdocs/

those will copy (synchronize) the file foo.txt and the directory /home/sgurin/dir1 to project's htdocs directory.

conecting using sftp:

sftp cancerbero_sgx,yui4java@web.sourceforge.net

Getting a web shell with ssh

with this option you will have access to a remote terminal in sf.net and there execute commands, access files ,etc
for connecting I use:

ssh -t cancerbero_sgx,yui4java@shell.sourceforge.net create


Publish your source code using svn

This will create a svn repository from a local source directory. Be carefull when typing commands when creating a new repository! Once this is done, you can svn checkout your own source files. Then you can work with svn (svn update, svn commit) in your own local working copy.

first you need to create a repository. for this you have to:

1)
connect via ssh as explained beore

2)
type the command :
adminrepo --checkout svn
(this will create a clone copy of your repository in /svnroot/yui4java.
* Use adminrepo --help for further information.)

3)
type the following commands (be carefull!)
rm -rf /svnroot/yui4java/*
# (Remove the clone copy of your repo)
create /svnroot/PROJECT
# (Create a new repository)

4)
type the following commands
cd
adminrepo --save svn


that operation can take some seconds... Once it is done, you can use your new svn repository. With the following command we will import a local source code directory into the svn repository:

svn import /home/sgurin/my/local/src/folder https://yui4java.svn.sourceforge.net/svnroot/yui4java/trunk

web page

The last thing we will create for our new project is its web page in sourceforge.net. In our project's main folder, we have the directory htdocs and this is the directory that is exposed to the web. In my example, this diretory is located at /home/groups/y/yu/yui4java/htdocs. This means that a file there, for example, /home/groups/y/yu/yui4java/htdocs/example.html can be navigated from http://yui4java.sourceforge.net/example.html.

it is important that all directory accesible from the web (for example, directories with javascript, css, images, etc), to contain a file .htaccess with the following content:

Options +Indexes
that's all. I hope this can be usefull to new sourceforge users.

miércoles, 3 de marzo de 2010

Problem with SVG feConvolveMatrix filter with kernel which sum is zero

Here I will document an issue that I had working with SVG feConvolveMatrix primitive filter that was a really pain for me but has a simple solution.

My problem was using feConvolveMatrix filter primitive to apply operations like blur, sharp, edge detection, etc to images. Everything works OK, except for kernel matrix which elements sum equals 0.

For example, the following filters works as spected:


<filter id="vstripe">
<feConvolveMatrix order="3"
kernelMatrix="
2 -1 2
-1 2 -1
2 -1 2"
/>
</filter>


but the following filter (with a kernel which elements sum equals 0) won't work ( will show an empty rectangle):


<filter id="vstripe">
<feConvolveMatrix order="3"
kernelMatrix="
-1 -1 -1
-1 8 -1
-1 -1 -1"
/>
</filter>


This problem manifest only for svg elements and in all svg user agents (mozilla, webkit, opera, inskape, etc). This problem is very frustrating because, there are a lot of convolution filters that use kernels which element sum must be 0 (specially edge detector filters).

The problem was because of the alpha channel of images. In most images, the alpha channel has a constant value for all pixels in a region and so, a convolution using these kernels will give 0 (totally transparent) and that is the reason for the empty rectangle.

The solution is setting the parameter preserveAlpha="true" so the alpha channel is not processed in the convolution:


<filter id="vstripe">
<feConvolveMatrix order="3" preserveAlpha="true"
kernelMatrix="
-1 -1 -1
-1 8 -1
-1 -1 -1"
/>
</filter>


I hope this article can help those poor souls that, like me, are stagnant with this problem.