Textpattern Forum

You are not logged in. Register | Login | Help

#41 2010-07-28 12:04:00

makss
Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 249
Website

Re: aks_header : Compress your pages on the fly. Strip white spaces + gzip

Bloke, thanks for feedback. Now this bug fixed. :)

New version aks_header 0.3.6

  • Fixed bug in strip function.

aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_meta | aks_header : Compress your pages on the fly

Offline

#42 2010-09-30 06:36:43

visualpeople
Member
From: Corvallis, Oregon - USA
Registered: 2005-11-16
Posts: 70
Website

Re: aks_header : Compress your pages on the fly. Strip white spaces + gzip

Maybe I’m not using this in the way it was intended or possibly just plain wrong but what I want it to do is redirect the main /subscribe page to a different url (which works great) but any other existing pages should not be redirected.

<txp:aks_301 start="/subscribe" ignore="/subscribe/" url="/members/signup.php" />

This produces the correct behavior for url.com/subscribe (redirects) and url.com /subscribe/ (doesn’t redirect) but not for url.com/subscribe/policies (redirects this page)

I’ve eve tried this (ignoring a specific already existing url) but it still redirects the policies page:

<txp:aks_301 start="/subscribe" ignore="/subscribe/policies" url="/members/signup.php" />

Any thoughts on what I’m doing wrong?

Edit — it appears to have been a weird caching issue, not sure if it was my browser or Textpattern, but it’s resolved itself and the <txp:aks_301 start="/subscribe" ignore="/subscribe/" url="/members/signup.php" /> is working as expected.

Last edited by visualpeople (2010-09-30 07:33:43)

Offline

#43 2010-10-18 13:49:19

element
Member
Registered: 2009-11-18
Posts: 81

Re: aks_header : Compress your pages on the fly. Strip white spaces + gzip

Not sure if it fits here but is there a way to properly do a 301 redirect from www to non-www with textpattern?
If I change my .htaccess I get weird results like index.php getting added to the url.

Offline

#44 2010-10-18 17:02:40

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 4,933
Website

Re: aks_header : Compress your pages on the fly. Strip white spaces + gzip

element wrote:

Not sure if it fits here but is there a way to properly do a 301 redirect from www to non-www with textpattern?
If I change my .htaccess I get weird results like index.php getting added to the url.

doesn’t fit in this thread:) Did you try…

# Redirect www to non-www
RewriteCond %{HTTP_HOST} ^www\.(.*)
RewriteRule (.*) http://%1/$1 [R=301,L]

or

RewriteEngine On
RewriteCond %{HTTP_HOST} !^your-site.com$ [NC]
RewriteRule ^(.*)$ http://your-site.com/$1 [L,R=301]

Yiannis
——————————
neme.org | neme-imca.org | hblack.net | LABS

Offline

#45 2010-10-19 08:57:40

element
Member
Registered: 2009-11-18
Posts: 81

Re: aks_header : Compress your pages on the fly. Strip white spaces + gzip

Of course I tried. Why does index.php get added when it converts from www to no www?

Don’t want to hijack the thread, so I started a new one here: http://forum.textpattern.com/viewtopic.php?id=34809

Last edited by element (2010-10-19 09:18:31)

Offline

#46 2012-08-21 17:16:52

mrdale
Moderator
From: Walla Walla
Registered: 2004-11-19
Posts: 2,053
Website

Re: aks_header : Compress your pages on the fly. Strip white spaces + gzip

I have a section that outputs an ical file. Right now it just wants to save the file with the section name; “ical”. What I’d like it to do is save the file with the name “calendar.ics”.

Here’s my code.

<txp:aks_header file="1" name="Content-Type" value="text/calendar" strip="0" gzip="0" nodebug="0" />

I hacked the plugin to add the line 'ics' => 'text/calendar' in $ext=array(

Any ideas people?

Last edited by mrdale (2012-08-21 17:24:47)

Offline

#47 2012-08-21 19:18:37

Gocom
Developer
Registered: 2006-07-14
Posts: 4,471
Website

Re: aks_header : Compress your pages on the fly. Strip white spaces + gzip

mrdale wrote:

I hacked the plugin to add the line ‘ics’ => ‘text/calendar’ in $ext=array(

I don’t think such hack is doing much of anything. Since you are already setting the content-type header in the tag itself, that addition will not add anything new to the game, and the extension to header mapping is deployed when the page’s URL ends with an extension.

While undocumented, it seems that the extension mapping only works for individual articles. The plugin uses article’s URL title field to get the requested locations “file extension”. Which is all fine, but this URL title is only available for articles. I’m not entirely sure if that is intentional behavior. I can say the regular expression that is used for picking the extension isn’t, and doesn’t seem right. The plugin would be better off with pathinfo which is also offers significantly better performance compared to a regular expression.

Any ideas people?

Most browsers use as or suggest as the file name either:

  • Requested resource’s name which in your case is ical (the name of the section).
  • Content-Disposition HTTP header’s filename field.

To offer a calendar.ics as the “file’s” name, set a Content-Disposition header’s filename field. You should be able to do that with aks_header as you did with the Content-type header. It’s just a header where the rest of them:

<txp:aks_header name="Content-Disposition" value="attachment; filename=""calendar.ics""" />

Note the quotes and the value escaping. Looks funky, but it’s intentional.

Alternatively you can set such headers and generate those files using other tools. Plain PHP is always an option, these thing are not impressively complicated and sending HTTP headers requires just a line of code. Since the code is simple it can be wrapped in rah_function too, offering very much XML like presentation. If you are already using rah_external_output’s, you could also use it’s form partial (snippet) to generate and deliver the iCal file:

; Content-Type: text/calendar
; Content-Disposition: attachment; filename="calendar.ics"

<txp:hide>
	Any markup here that generates the iCal's calender file
</txp:hide>

Things are simple in raw PHP too. The following offers the same functionality as these plugins when used in the page template:

<txp:php>
	header('Content-type: text/calendar');
	header('Content-Disposition: attachment; filename="calendar.ics"');
</txp:php>

The above can be wrapped in a rah_function:

<txp:rah_function call="header" header="Content-type: text/calendar" />
<txp:rah_function call="header" header="Content-Disposition: attachment; filename=""calendar.ics""" />

Last edited by Gocom (2012-08-21 19:19:17)


Rah-plugins | What? I’m a little confused… again :-) <txp:is_god />

Offline

#48 2012-08-21 20:02:13

mrdale
Moderator
From: Walla Walla
Registered: 2004-11-19
Posts: 2,053
Website

Re: aks_header : Compress your pages on the fly. Strip white spaces + gzip

Thanks… does that mean I should do that in addition to my original call?

nevermind. I just used the php snippet.

Last edited by mrdale (2012-08-21 20:29:42)

Offline

#49 2012-10-24 04:21:33

nardo
Member
From: tuvalahiti
Registered: 2004-04-22
Posts: 739

Re: aks_header : Compress your pages on the fly. Strip white spaces + gzip

How would you set “charset=UTF-8”?

Offline

#50 2012-10-25 09:18:13

makss
Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 249
Website

Re: aks_header : Compress your pages on the fly. Strip white spaces + gzip

nardo wrote:

How would you set “charset=UTF-8”?

<txp:aks_header name="Content-Type" value="text/html; charset=utf-8" />


aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_meta | aks_header : Compress your pages on the fly

Offline

Board footer

Powered by FluxBB