Blog

2007 posts (53)

Pages: < Previous 1–10 11–20 21–30 31–40 41–50 51–60 Next >
Ordering: Ascending Descending

11. DIY Framework v0.3 released

2007-10-12 11:08:01 by Martynas Jusevičius

We are pleased to finally announce the release of the new version 0.3 of our DIY Framework. As promised, it includes new features and solves several issues:

To demonstrate features of the framework, we also release version 0.1 of DIY Blog, an open-source blog/content management engine, on which this website is running, too.

For easier distribution, we have moved our code to SourceForge.

So here come the links:

DIY Framework 0.3

DIY Blog 0.1

Happy hacking! Please provide feedback and spread the word :)

Add a comment Comments (256)

12. PHP 5 tips: DateTime class

2007-10-07 11:56:01 by Martynas Jusevičius

PHP 5.2 introduced new DateTime and DateTimeZone classes, which obsolete the datetime functions. They offer a convenient way to store dates and time as objects, instead of strings or integers. Classes also have a better time zone support as well as support for dates outside of the Unix epoch.
But the API, while useful, is rather over-simplified and under-documentented. Here is a good introduction to the API with lots of examples: Looking at PHP5’s DateTime and DateTimeZone by Laughing Meme.

Add a comment Comments (2)

13. Namespaces already in PHP 5.3

2007-09-29 16:35:28 by Martynas Jusevičius

As some people have already reported, PHP 5.3 has namespace support already submitted to its codebase. This is great news, since PHP was really lacking this feature.

Add a comment Comments (4)

14. DIY tips: Inheriting Resources

2007-09-24 18:08:08 by Martynas Jusevičius

Often you have a situation where many Resources have to share the same properties and/or behavior. For example, all Resources in a backend administration application should deny access to users that are not logged on.
A nice and simple solution is to create a parent Resource for the whole application and let all the specific backend Resources to inherit it.

Here is an example. BackEndResource is a general Resource for the whole backend application:

class BackEndResource extends BaseBackEndResource
{
	public function doGet(Request $request, Response $response)
	{
		$view = parent::doGet($request, $response);

		if ($request->getSession()->getAttribute("user") instanceof GuestUser) $view = new ForbiddenView($this);

		return $view;
	}
}

Other backend Resources inherit it:

class AdminResource extends BackEndResource
{
	public function doGet(Request $request, Response $response)
	{
		$view = null;
		$parent = parent::doGet($request, $response);

		if ($parent != null) $view = $parent;
		else $view = new AdminView($this);

		return $view;
	}
}

If a user is accessing AdminResource or any other backend Resource and is not logged on (i. e. user object in the session is an instance of GuestUser), ForbiddenView is displayed with an appropriate message. Otherwise, AdminView is displayed as normally.
In such a way a single line of code allows you to control access to the whole application.

Add a comment Comments (12)

15. Open-source PHP profiler

2007-09-18 20:57:33 by Martynas Jusevičius

We were looking for a simple open-source PHP profiler, without any fancy IDEs like Zend bundled together. After a little search, we found one: Xdebug, debugger and profiler tool for PHP. It installs as a PHP extension. When you execute your scripts, it simply writes debug information into a file. You can later open and analyze it with a special viewer: KCachegrind for Linux or WinCacheGrind for Windows.

Add a comment Comments (16)

16. How to Publish Linked Data on the Web

2007-09-14 18:21:36 by Martynas Jusevičius

We came across a great read by Ch. Bizer, R. Cyganiak, T. Heath: How to Publish Linked Data on the Web. In a nice and simple manner it describes the basic things you need to know before implementing some practical Semantic Web applications. The abstract goes like this:

This document provides a tutorial on how to publish Linked Data on the Web. After a general overview of the concept of Linked Data, we describe several practical recipes for publishing information as Linked Data on the Web.

Add a comment Comments (12)

17. Escaped slash bug in Apache

2007-09-13 20:23:30 by Martynas Jusevičius

We encoutered an apparently 6-year-old bug in Apache, which might as well be a security feature: it treats escaped (URL-encoded) slashes (which become %2F) as normal slashes / in a URL and returns 404 Not Found if such a URL is requested. It does not even come to PHP.

UPDATE: Fortunately, it seems that it actually is a security feature and there is Apache's AllowEncodedSlashes directive to turn it off. There is also a hack by Frédérick Giasson.

Add a comment Comments (1)

18. DIY tips: XSLT template modes

2007-09-10 11:09:33 by Martynas Jusevičius

Working with Views, sometimes you need the same kind of objects rendered in different ways, depending on the situation. For example, you might want to be able to display an array of products as a list as well as a table. That means each product item should be rendered either as a list item or as a table row.
As you define templates for product items in XSLT, you need a way to differentiate between the two kinds. Here is where template modes come in handy. You can define templates with the same match but different modes, and choose the mode later when applying them. That is excatly what we need — product item templates with list and table modes:

<xsl:template match="Product" mode="list">
	<li>
		<a href="{@resource}{$query-string}">
			<xsl:value-of select="Title"/> (<xsl:value-of select="@price"/>)
		</a>
	</li>
</xsl:template>

<xsl:template match="Product" mode="table">
	<tr>
		<td>
			<xsl:value-of select="@code"/>
		</td>
		<td>
			<a href="{@resource}{$query-string}">
				<xsl:value-of select="Title"/>
			</a>
		</td>
		<td>
			<xsl:value-of select="@price"/>
		</td>
	</tr>
</xsl:template>

They can be applied as follows:

<ul>
	<xsl:apply-templates select="/Products/Product" mode="list"/>
</ul>

<tbody>
	<xsl:apply-templates select="/Products/Product" mode="table"/>
</tbody>

Add a comment Comments (1)

19. OOXML drama

2007-09-07 18:00:44 by Martynas Jusevičius

This week, there was a lot attention to ISO (International Standards Organization) as it voted whether to approve Microsoft's OOXML (Open Office XML) format as a standard for office applications. To make it happen, 75% of ISO members countries had to vote for.

There is already one standard for that — ODF (OpenDocument Format), which is favored by the open-source community. There were a lot of debates and objections as to whether another standard is necessary, especially given that it is built on Microsoft's proprietary format. Moreover, there has been controversy about Microsoft pushing the national standard bodies to approve OOXML. Swedish vote in favor of Microsoft's format was invalidated for that reason.

This time, ISO has not approved OOXML on a fast-track basis. However, Microsoft will get another try after it reviews the comments submitted by ISO member countries, most likely in February 2008.

Add a comment Comments (2)

20. Developers do not get GET

2007-09-04 15:32:12 by Martynas Jusevičius

It is becoming a worrying trend that developers (even those of the more popular services and frameworks) do not know or respect semantics of the HTTP protocol:

All of these examples are proposing URLs such as /users/delete/1 or /posts/add for editing or deleting resources via the HTTP GET method. While they probably pretend to be RESTful, they are in fact breaking HTTP and REST semantics. HTPP 1.1: Method Definitions states that GET and HEAD methods SHOULD NOT have the significance of taking an action other than retrieval. These methods ought to be considered "safe". and that GET is idempotent. In other words, sending GET request should not change server state.

UPDATE: Not Ruby on Rails itself, only a tutorial on it.

Add a comment Comments (5)

Pages: < Previous 1–10 11–20 21–30 31–40 41–50 51–60 Next >
Ordering: Ascending Descending