Posted April 3, 2011
URLs are the addresses of the internet.
Each URL points to a location and your user can go there. However on the
internet the addresses are not that important to the users and browsers.
Especially since we can read almost any page on such a location. So the
location doesn't matter as long as we find what we expect.
The URL and the link text both build an expectation in us. The text and the URL
will imply what we will find after we click the link. I think it makes sense to
write links without showing the URL.
For example when I wrote some code and pushed it to
GitHub, I could write it like this:
I posted my new code to GitHub: http://github.com/pstuifzand/pompiedom-river.
Or I could write:
I just released a new of version of Pompiedom, an rssCloud-enabled realtime
river.
The second example explains what you will find when you click the link. Another
reason for writing text instead of URLs is that the layout engine has more to
work with when breaking lines, especially when using justified text.
Posted February 13, 2010
Jeff on Coding Horror writes:
Among programmers of any experience, it is generally regarded as A Bad Idea (tm)
to attempt to parse HTML with regular expressions.
You should read the rest of the article. I'm mostly of the same opinion about
this as Jeff. Additionally I think that parsing HTML is a bad idea in the first
place.
One of the examples Jeff gives for parsing HTML is sanitizing user input. The
user input will be used on the website as comments for example. I think allowing
people to write HTML and putting it on a webpage is the wrong way to go.
If you want to include user input in a web page there are only two ways to do it:
Encode all special HTML characters. You can start with <, >, &, "
and '. If you encode these then people can send all the HTML they want, but
it's encoded and will not affect your web page. For Perl I recommend the
HTML::Entities module.
The other way to allow HTML is, on a page, where it is their own. If they
want to break their own web page, they should be allowed to do that. This
doesn't mean profiles on websites, but actual websites that are completly their
own.. So you say it is HTML and then use the input verbatim.
If you want to include some kind of formatting for the input, you can use a
markup language. Use a markup language that allows to specify as much
formatting as you like, this could be a HTML-like language, that only
transforms the tags that you want. Therest of the text should be HTML encoded.
Posted May 15, 2008
I'm trying Haskell for writing Web applications. It should be really easy, but
at the moment I'm missing the examples. The documentation doesn't really help
for generating the XHtml.
The following bit of code is something that I found: Haskell and Web
applications. The article
contains a simple example. I changed the code in the example to use a table
instead of the spans. This turned out to be really easy to do.
renderData :: (Data a) => a -> Html
renderData i = table << mapFields renderField i
where renderField (name, val) =
tr << [ (th << renderFieldName (name ++ ":")) ! [ align "left" ]
, td << (read val :: String)
]
I added the call to read to remove the quotes around the values. The <<
operator adds the objects to the right as the children of the object to the
left. Because of the way this is specified this can a list or a single object.
The ! operator adds an attribute to the object on the left.
There need to be more examples for Haskell that are easy to understand and
change, because it is hard to understand the ways that functions work from the
documentation (types and functions) alone.
I hope this will help some of you trying to write some Haskell code.