How to create an internal link to a directory ?

Hello,

I have the following site structure:

file1 file2 ...

Now I want to add an internal link directly to “folder1”, but this fails, since in FW I can just select files.

My workaround currently is to simply use a full URL (e.g. www.me.tld/folder1/), but this requires taking care when updating the site structure.

Is there a way to create internal links pointing to a folder instead of a file ? Or have I just overseen something ?

Looking forward to your help :slight_smile:


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Sometime around 13/7/08 (at 14:10 -0400) tobiaseichner said:

Is there a way to create internal links pointing to a folder instead
of a file ? Or have I just overseen something ?

You can simply type the relative path to the folder from wherever the
link is, instead of the absolute one. But that does still have the
problem of needing manual maintenance.

But why not just decide which page is to be the default one that’s
served when someone asks for the directory (the one that has
“index.html” as the filename, normally), and link to that? You’ll get
exactly the same behaviour as what you’re after, with the benefit of
having Freeay manage your links for you.

k


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

But why not just decide which page is to be the default one
that’s served when …

This is because I use a variant file determining the preferred user language. So let’s say I have these files in one folder:

index.var
index_de.html
index_en.html
index_fr.html

The webserver is configured to give index.var a higher priority when just calling the directory than alternative index files (like index.html).

So at the time linking to the page, I don’t know which language the user prefers, therefore I need a way to call the folder.

This is especially since I haven’t found a convenient solution to get my index.var files seamlessly integrated into FW.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Sometime around 13/7/08 (at 15:05 -0400) tobiaseichner said:

So at the time linking to the page, I don’t know which language the
user prefers, therefore I need a way to call the folder.

This is especially since I haven’t found a convenient solution to
get my index.var files seamlessly integrated into FW.

I see!

Perhaps you could use the appropriate PHP action to strip all the
normal structure and content from a page, leaving nothing but
whatever markup-inserted code you want in your index.var page? Then
use Freeway’s Inspector palette to change the filename to “index.var”?

It might just work… :slight_smile:

k


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

appropriate PHP action to strip all the normal structure and content from a page

I have tried this earlier shortly and will give it a closer look for this project again, since it seems to be the best solution. Thanks for noting about :slight_smile:

Anyway, the links would point to …/folder1/index.var which just looks a bit ugly (considering that finally we wanted to have links like www.me.tld/products/amazing/). But it should not matter as long as I haven’t go through dozens of pages and alter all links after applying one single change :wink:


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Select Command-K and type ‘foldername’ … it’s that easy.
If you want you can change folders as well; just type ‘…/foldername’


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

@Richard van Heukelum:
While this works to select a folder (thank you for the hint :slight_smile: it does not automatically update links when renaming or moving folders. So the base problem remains the same…


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Let me see if I can clarify this, and then perhaps there’s a way to
do this in an Action.

You want to have any request for a default page (usually index.html)
to be changed so that it is a link to the folder itself (thereby
engaging the automatic content-negotiation behavior), right?

So if you were presented with a Folder Action that allowed you to
choose a particular default index page filename, and then would loop
through your site removing any reference to it from the published
code, that would do the trick, right?

Please let me know if this is the exact behavior you are looking for
here.

Walter

On Jul 14, 2008, at 1:21 PM, tobiaseichner wrote:

@Richard van Heukelum:
While this works to select a folder (thank you for the hint :slight_smile: it
does not automatically update links when renaming or moving
folders. So the base problem remains the same…


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I wrote an action for a fellow Freeway user a few years back (was it for Fred
Kylander? I really can’t recall at present!) called Cool URIs. The idea was the
same in that it would trawl the link directory stripping off all of the default
page details from the links.
For example a link like this;
http://mysite/myfolder/index.html
would become;
http://mysite/myfolder/
This allows the site to be updated (to shtml, php, asp, whatever, extensions)
without having to worry about people following old links.
I’ll see if I can dig the action out later when I get back home.
Regards,
Tim.

Quoting Walter Lee Davis email@hidden:

Let me see if I can clarify this, and then perhaps there’s a way to
do this in an Action.

You want to have any request for a default page (usually index.html)
to be changed so that it is a link to the folder itself (thereby
engaging the automatic content-negotiation behavior), right?

So if you were presented with a Folder Action that allowed you to
choose a particular default index page filename, and then would loop
through your site removing any reference to it from the published
code, that would do the trick, right?

Please let me know if this is the exact behavior you are looking for
here.

Walter


Extend Freeway the way you want with FreewayActions.com
http://www.freewayactions.com


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Well I dug that action out from my archive and it sort of did what I described but also hacked around with file extensions to allow extra file extensions to be used to denote the default language for the page. To cut long story short I took out the bit of the action that does the default file name removal and made a spin off action - Default file URLs.
You can download the action from the beta box page on FreewayActions.com at;
http://www.freewayactions.com/product.php?id=beta

To add the action to your site follow the folder action instructions;
http://www.freewayactions.com/product.php?id=applyfolder

I’ve tested the action on local and remote links including ones with anchors and query data and it appears to work as expected. If you spot anything, or another action, that breaks the links then please get in touch at;
http://www.freewayactions.com/product.php?id=con
Thanks,
Tim.

FreewayActions.com - Freeware and shareware actions for Freeway Express & Pro.

Protect your mailto links from being harvested by spambots with Anti Spam.
Only available at FreewayActions.com

http://www.freewayactions.com

@Tim Plumb: I’ll have a look at your action later today. Looks like it would solve my problem. Thank you so much :slight_smile:

@waltd:

You want to have any request for a default page (usually index.html) to be changed so
that it is a link to the folder itself (thereby engaging the automatic content-
negotiation behavior), right?

Yes, exactly. Just not sure how FW can handle this, ideally instead of selecting one of the index files (as placeholder), the folder itself should be selectable directly (but guess that the behaviour of selecting links is hardcoded in FW and cannot be influenced by an action).

So if you were presented with a Folder Action that allowed you to choose a particular
default index page filename, and then would loop through your site removing any
reference to it from the published code, that would do the trick, right?

Yes, this will work.

If you are really spending time in developing an action, how about to implement a solution that automatically creates a .var file from user input ? The user should be able to determine multiple language/filename pairs and the action automatically creates a index.var file according the following scheme:

URI: index_de.htm
Content-language: de
Content-type: text/html

I’m not sure about the conventions for these files (just can state that above scheme works on my server), so some basic investigation may be required.

Anyway, this could be surely a great project :slight_smile:


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

If you will do the investigating, I will see if I can add the Action
part.

Walter

On Jul 15, 2008, at 5:48 AM, tobiaseichner wrote:

If you are really spending time in developing an action, how about
to implement a solution that automatically creates a .var file from
user input ? The user should be able to determine multiple language/
filename pairs and the action automatically creates a index.var
file according the following scheme:

URI: index_de.htm
Content-language: de
Content-type: text/html

I’m not sure about the conventions for these files (just can state
that above scheme works on my server), so some basic investigation
may be required.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

@ waltd:

If you will do the investigating, I will see if I can add the
Action part.

Okay, give me two days to get familiar (again) with Apache and its way of content negotiation. I’ll then provide you with a sample .var file and some technical background.

Also let me know if you need something specific.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

@waltd:

Here is a short overview about language-based content negotiation:

Pre-requisites on the server-side (not related to FW):

  • module mod_negotiation available and active (should be the default).

  • In the config file, add a line like “AddHandler type-map var” to allow recognition of .var as a type-map. Alternatively it can be placed in a .htaccess file to limit this content negotiation to a given directory only.

  • When accessing directories without explicitly calling the .var file, then an index.var (or appropriate) must be set as one of the default filenames to look for when accessing a directory). In the following I assume that we use “index.var”.

Structure of an index.var file:


URI: RelFileToCall

Content-type: text/html

Content-language: LanguageShortRFC1766

URI: RelFileToCall

Content-type: text/html

(For any reason, the board software does not let me write the file correctly; there must be just an empty line between each entry, not between “URI/Content-type/Content-language”. Strange. Anyway, you find examples at the reference links below.)

** URI:

Contains the file being referred to relative from the location of the .var file. Since usually all files are in the same folder, just placing the filename there is sufficient.

The URI must point to a local file, so you cannot call an URL like http://www.other.tld this way (at least it is limited in Apache 1.3. and I feel we should do the most compatible way).

** Content-type:

The negotiation feature can be used for many other purposes, but for our application the line can be simply used as it is and does not need to be changed. Likely you could even skip it, but in all examples I reviewed, language-based negotiations had this line as well.

An example where it changes could be allowing text-based browsers like Lynx to show an ASCII art instead of a JPEG file. Then of course, you would need to adjust this line pointing to an image type at one entry and to a text file for the other entry.

** Content-language:

Here we place the language shortcut according RFC 1766. This is the most important line, since it makes Apache to decide which file to call for which language. Typical values are “de”, “en”, “fr” (German, English, French). You can also go more into details like “de-ch” (Swiss-German), but not sure if this is really useful.

An important thing to mention is the last entry in my sample file above, which does not have a content-language line. Consider that you allow decision between German, English and French - but a Japanese user may get a 406 error message that there is no appropriate content for him. While he will see the available options, it is bad behaviour. You either may catch the error on the server by implementing an error redirect, but it is better to have this line which is used if no other one matches.

A sample index.var file:


URI: index_de.html

Content-type: text/html

Content-language: de

URI: index_en.html

Content-type: text/html

Content-language: en

URI: index_fr.html

Content-type: text/html

Content-language: fr

URI: index_alternative.html

Content-type: text/html

Freeway action:

I could imagine that we have the following GUI for this folder action:

  • An edit field that allows to type in the name of the .var file being used (maybe good idea to have “index.var” being the default).

  • Two drop-down boxes and an file button forming one entry: “Content-type” selector (you may provide a list of MIME types or simply just text/html or even skip this and hardcode text/html at all), “Language selector” showing the language codes, “File selector” button to choose a file.

More additions:

Content negotiation also provides some other features like using a quality factor for each content type; this would make sense not for language-based negotiation (at least in my mind), but more when having different content types available. For example, there is a decision made between a GIF, a JPEG and an ASCII art. If a browser can show all three types, the quality factor could be used to prefer the JPEG and - if this is not available - use the GIF instead.

The quality factor ranges between 0.000 and 1.000; variants using a factor of 0 are never chosen however.

A short example:

URI: image.jpeg

Content-type: image/jpeg; qs=0.9

URI: image.gif

Content-type: image/gif; qs=0.5

URI: alternative.txt

Content-type: text/plan; qs=0.1

I found no guidelines about how to use the quality factor, neither on Apache’s official documentation nor anywhere else. Guess you a have to play with the values :wink: Anyway, the definitively can be above 1 in total (so it is not a percentage based scheme).

Not sure if you want to include this; languages are definitively selected not in this way, since even your browser is set to accept English and German and you have both entries in the .var file, the browser decides which to use according the priority set at software preferences.

Let me know if anything is unclear and needs more discussion. You may also find the following resources helpful:

http://httpd.apache.org/docs/1.3/content-negotiation.html

http://httpd.apache.org/docs/1.3/mod/mod_negotiation.html

http://www.cs.tut.fi/~jkorpela/multi/6-en.htm


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Two errors found in my text (of course, after posting it :wink:

  1. “Content-type: text/plan; qs=0.1” must be “Content-type: text/plain; qs=0.1”, of course.

  2. I noted that the board software does not let me format the .var file correctly; I played a bit with HTML formats and made it looking well… but I forgot to remove my comment. So the .var file samples are exactly shown as they should be.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

If you want to format the var file contents as code on the Web, put four spaces at the beginning of each line. This will give the clue that the following is code:

code starts here
and continues here
no <br /> tags needed

Walter


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Thanks for the tip, will remember for next time :slight_smile:

Is the info I provided sufficient for you (assumed you are still interested in writing an action for this task) ?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

It seems to have all the details I need. I’ll try to attack this at
the weekend.

Walter

On Jul 18, 2008, at 5:22 AM, tobiaseichner wrote:

Thanks for the tip, will remember for next time :slight_smile:

Is the info I provided sufficient for you (assumed you are still
interested in writing an action for this task) ?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I have made a quick Action to create this file. It does quite a bit
less than you described, but hopefully it makes up for that by being
very simple to use.

http://freewaypro.com/actions/downloads/ContentNegotiation.fwaction

###How To Use It:

This is a Folder Action. Apply it to the root folder of your site, or
if you only want this behavior in a single folder, apply it only to
that folder in your Freeway document. (Click on the folder in the
Site pane, then click the [+] button in the Actions palette.)

For simplicity’s sake, there is little or no UI, only the text field
where you name the Type Map file. Everything else depends on actions
you take in Freeway when naming your pages.

You may have as many different language index pages as you like. Each
one must be named precisely like this:

index_es.html
index_da.html
index_de.html
index_alternative.html

So that’s the word ‘index’, an underscore, the two-letter code for
the language or the word ‘alternative’ and then the file-type
extension. You may only have more than one dot in the filename, but
there must be a dot immediately following the language code. So
index_fr.extra.php would work, but index_fi_alt.html would not. (The
language would be set to fi_alt rather than fi.)

You may put the various indices in any order you like within the
Freeway folder, but you must make sure that the index_alternative is
the very last index in the folder.

Once you have applied the Action to the folder and published, you
will find a new index.var (or whatever else you named it) in the same
folder as the index_language pages. If you have more than one folder
in the site, you will find a separate index.var file in each folder
that also contains files named index_something.extension. If the
folder does not have any pages named according to this scheme, then
no var file will be generated.

Hope this helps, please let me know if you find a problem or it
doesn’t work for you.

Walter

On Jul 18, 2008, at 5:22 AM, tobiaseichner wrote:

Thanks for the tip, will remember for next time :slight_smile:

Is the info I provided sufficient for you (assumed you are still
interested in writing an action for this task) ?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Amazing, looks really great so far and is easy to use (easier than my UI suggestions since there is no hardcoded language list).

However I found a bug when later adding another page to the folder, this will create a new .var file, but using the name indexa.var (guess this is the FW renaming behaviour when having two equally labelled files in place). So you should ensure to delete the old one before.

I gave it a try using index_de.html and index_en-us.html (localized languages), which also works well.

On Monday I’ll create a small demo website and set it up online this way to ensure that the .var file also is accepted by the server (not that we have any strange whitespace or something like that).

Anyway, so far, it seems that this action will make my live much easier and I hope that many other people think so, too :slight_smile:


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options