rejetto forum

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Unknown8063

Pages: 1
1
RAWR-Designs / IP Detection
« on: January 31, 2009, 10:07:12 PM »
TSG/Giant Eagle

I'm in the process of moving my HFS server onto a different machine and will be using my Apache server to reverse proxy user connections over to it.  This means that every user who connects to my server is seen by HFS as having a local LAN IP, and triggering RAWR template features geared toward an administrative user such as the Update panel.  In future releases can you add a variable at the top of the template to disable this just like you did for the IP display?

Thanks much, 8063

2
HTML & templates / Content negotiation for HFS templates
« on: January 16, 2009, 05:57:08 AM »
I've been using a content negotiation script in PHP on my main server so I decided to get working on one for HFS.  This script will check the Accept header of the user-agent to determine if it can accept pages served as application/xhtml+xml.  If it cannot, it will fallback on text/html.  There is also an if block to serve pages as application/xhtml+xml if the user agent happens to be a validator.

To use it, simply place it anywhere in the page you want negotiated.  An obvious place is a header section included in all pages.

Warning! When pages are served as real XHTML they are parsed by the browser using stricter rules than HTML soup.  The RAWR template I use crashes on a parse error and I suspect most of the available templates will.

Code: [Select]
{.comment |
{.set |MIME_TYPE|text/html.}
{.if | {.count substring |application/xhtml+xml|{.header|Accept.}.}
  | {: {.if not |{.count substring |application/xhtml+xml;q=0|{.header|Accept.}.}
          | {: {.set |MIME_TYPE|application/xhtml+xml.} :}
          | {: {.if | {.count substring |application/xhtml+xml;q=0.|{.header|Accept.}.}
                  | {: {.set |MIME_TYPE|application/xhtml+xml.} :}
                .} :}
        .} :}
.}
{.if | {.or
        | {.count substring |W3C_Validator|{.header|User-Agent.}.}
        | {.count substring |WDG_SiteValidator|{.header|User-Agent.}.}
        | {.count substring |W3C-checklink|{.header|User-Agent.}.}
        | {.count substring |Web-Sniffer|{.header|User-Agent.}.}
        | {.count substring |FeedValidator|{.header|User-Agent.}.}
        | {.count substring |Poodle predictor|{.header|User-Agent.}.}
        | {.count substring |Leknor.com gzip tester|{.header|User-Agent.}.}
      .}
  | {: {.set |MIME_TYPE|application/xhtml+xml.} :}
.}
{.add header |Vary: Accept.}
{.add header |Content-type: {.call |MIME_TYPE.}; charset=UTF-8.}
.}

This is my first time using macros, so please let me know if I made a mistake :D It seemed to work in my testing.

8063

3
HTML & templates / Macros and white space
« on: January 16, 2009, 04:35:58 AM »
I'm finally getting around to playing with template macros and noticed that white space tends to grow very rapidly around complex if structures.  That is white space that appears when I view source in my browser that is left behind from my macro indenting.

Because HFS interprets all macros before anything is sent to the browser this isn't an issue, I suppose.  I'm used to PHP and I was worried the excess white space would prevent my add header macro - but that wasn't the case.  HFS executes everything before it releases the buffer so you can actually use {.add header.} in the footer if you want to.

However, is there a way to contain macro scripts so they don't output anything to the browser?

EDIT: Oh! I just realized the {.comment.} macro can be used for this

Pages: 1