switching external content between http and https?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

switching external content between http and https?

samhamilton
Hi Guys,

Is there a freemarker template tag that would automatically switch
between http and https depending how the page has been loaded?

I want to use an external image server for hosting images but when
switching to the checkout all the urls should also switch over to https.

p.s. is there a big list of template tags that work in ofbiz somewhere?


Cheers
Sam
Reply | Threaded
Open this post in threaded view
|

Re: switching external content between http and https?

Michał Cukierman
Can you create two pages based on one template and then checks if the
parameter is set? You can also create a servlet that filters for the url
and checks the same.

then, if parameter is set - you can redirect to https or no.

Dnia 2010-08-21, sob o godzinie 16:43 +0800, Sam Hamilton pisze:

> Hi Guys,
>
> Is there a freemarker template tag that would automatically switch
> between http and https depending how the page has been loaded?
>
> I want to use an external image server for hosting images but when
> switching to the checkout all the urls should also switch over to https.
>
> p.s. is there a big list of template tags that work in ofbiz somewhere?
>
>
> Cheers
> Sam

Reply | Threaded
Open this post in threaded view
|

Re: switching external content between http and https?

BJ Freeman
In reply to this post by samhamilton
same this is pretty much standard.
you will get browser errors if you have http links in an Https URL.
The whole purpose of the Https URL is to be encrypted.
your only two choices are not to use HTTPS or to convert the images
repository to HTTPS
if you switch the Cart to HTTP, you would do this in the controller.



Sam Hamilton sent the following on 8/21/2010 1:43 AM:

> Hi Guys,
>
> Is there a freemarker template tag that would automatically switch
> between http and https depending how the page has been loaded?
>
> I want to use an external image server for hosting images but when
> switching to the checkout all the urls should also switch over to https.
>
> p.s. is there a big list of template tags that work in ofbiz somewhere?
>
>
> Cheers
> Sam
>
Reply | Threaded
Open this post in threaded view
|

Re: switching external content between http and https?

samhamilton
Sorry guys perhaps I am not being clear I was looking for a tag that
when interpreted in ftl it switches between http and https automatically

so in the ftl some tag other than ofbizUrl could be replaced and then
this image works both on http and https ftl pages

in headerHead.ftl the javascript is called from
<script type="text/javascript"
src="<@ofbizContentUrl>${StringUtil.wrapString(javaScript)}</@ofbizContentUrl>"
type="text/javascript"></script>

but this always seems to point to the ofbiz server and I want to be able
to point it to an totally different domain (think Amazon CDN that allows
http and https)

So rather than using <@ofbizContentUrl> is there another tag that just
changes between http and https?

Thanks
Sam



On 21/08/2010 17:09, BJ Freeman wrote:

> same this is pretty much standard.
> you will get browser errors if you have http links in an Https URL.
> The whole purpose of the Https URL is to be encrypted.
> your only two choices are not to use HTTPS or to convert the images
> repository to HTTPS
> if you switch the Cart to HTTP, you would do this in the controller.
>
>
>
> Sam Hamilton sent the following on 8/21/2010 1:43 AM:
>> Hi Guys,
>>
>> Is there a freemarker template tag that would automatically switch
>> between http and https depending how the page has been loaded?
>>
>> I want to use an external image server for hosting images but when
>> switching to the checkout all the urls should also switch over to https.
>>
>> p.s. is there a big list of template tags that work in ofbiz somewhere?
>>
>>
>> Cheers
>> Sam
>>

Reply | Threaded
Open this post in threaded view
|

Re: switching external content between http and https?

Scott Gray-2
Hi Sam,

The ofbizContentUrl directive should work for this, have you tried setting the content prefix properties either in url.properties or on the WebSite entity itself?

Regards
Scott

HotWax Media
http://www.hotwaxmedia.com

On 21/08/2010, at 9:28 PM, Sam Hamilton wrote:

> Sorry guys perhaps I am not being clear I was looking for a tag that
> when interpreted in ftl it switches between http and https automatically
>
> so in the ftl some tag other than ofbizUrl could be replaced and then
> this image works both on http and https ftl pages
>
> in headerHead.ftl the javascript is called from
> <script type="text/javascript"
> src="<@ofbizContentUrl>${StringUtil.wrapString(javaScript)}</@ofbizContentUrl>"
> type="text/javascript"></script>
>
> but this always seems to point to the ofbiz server and I want to be able
> to point it to an totally different domain (think Amazon CDN that allows
> http and https)
>
> So rather than using <@ofbizContentUrl> is there another tag that just
> changes between http and https?
>
> Thanks
> Sam
>
>
>
> On 21/08/2010 17:09, BJ Freeman wrote:
>> same this is pretty much standard.
>> you will get browser errors if you have http links in an Https URL.
>> The whole purpose of the Https URL is to be encrypted.
>> your only two choices are not to use HTTPS or to convert the images
>> repository to HTTPS
>> if you switch the Cart to HTTP, you would do this in the controller.
>>
>>
>>
>> Sam Hamilton sent the following on 8/21/2010 1:43 AM:
>>> Hi Guys,
>>>
>>> Is there a freemarker template tag that would automatically switch
>>> between http and https depending how the page has been loaded?
>>>
>>> I want to use an external image server for hosting images but when
>>> switching to the checkout all the urls should also switch over to https.
>>>
>>> p.s. is there a big list of template tags that work in ofbiz somewhere?
>>>
>>>
>>> Cheers
>>> Sam
>>>
>


smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: switching external content between http and https?

samhamilton
Hi Scott - thanks for the tip, it might just do the job nicely if there
was not one weird side effect - if you set it for only one ecommerce
application it then changes the all the back end themes too!

Just try updating the demo ecommerce store -
https://demo-trunk.ofbiz.apache.org:8443/content/control/EditWebSite?webSiteId=WebStore
with a secure content prefix of https://images.apache.org and then the
whole theme breaks even if you have selected "Themes to be used for
Ecommerce applications" - I think this is an unintended bug. Where as
really it should have only broken the website.

Cheers
Sam



On 21/08/2010 18:17, Scott Gray wrote:

> Hi Sam,
>
> The ofbizContentUrl directive should work for this, have you tried setting the content prefix properties either in url.properties or on the WebSite entity itself?
>
> Regards
> Scott
>
> HotWax Media
> http://www.hotwaxmedia.com
>
> On 21/08/2010, at 9:28 PM, Sam Hamilton wrote:
>
>> Sorry guys perhaps I am not being clear I was looking for a tag that
>> when interpreted in ftl it switches between http and https automatically
>>
>> so in the ftl some tag other than ofbizUrl could be replaced and then
>> this image works both on http and https ftl pages
>>
>> in headerHead.ftl the javascript is called from
>> <script type="text/javascript"
>> src="<@ofbizContentUrl>${StringUtil.wrapString(javaScript)}</@ofbizContentUrl>"
>> type="text/javascript"></script>
>>
>> but this always seems to point to the ofbiz server and I want to be able
>> to point it to an totally different domain (think Amazon CDN that allows
>> http and https)
>>
>> So rather than using <@ofbizContentUrl> is there another tag that just
>> changes between http and https?
>>
>> Thanks
>> Sam
>>
>>
>>
>> On 21/08/2010 17:09, BJ Freeman wrote:
>>> same this is pretty much standard.
>>> you will get browser errors if you have http links in an Https URL.
>>> The whole purpose of the Https URL is to be encrypted.
>>> your only two choices are not to use HTTPS or to convert the images
>>> repository to HTTPS
>>> if you switch the Cart to HTTP, you would do this in the controller.
>>>
>>>
>>>
>>> Sam Hamilton sent the following on 8/21/2010 1:43 AM:
>>>> Hi Guys,
>>>>
>>>> Is there a freemarker template tag that would automatically switch
>>>> between http and https depending how the page has been loaded?
>>>>
>>>> I want to use an external image server for hosting images but when
>>>> switching to the checkout all the urls should also switch over to https.
>>>>
>>>> p.s. is there a big list of template tags that work in ofbiz somewhere?
>>>>
>>>>
>>>> Cheers
>>>> Sam
>>>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Visible screen error on trunk demo and related question

Matt Warnock
When I go to the latest trunk demo, ecommerce store page, in the "browse
forums" section on the left side bottom, there is an error that starts
with "Expression forum.contentName is undefined on line 26".

Is there a way to set OFBiz so that debugging info like this appears in
the logs, but DOESN'T appear on customer-facing pages?  Seems like that
would be part of the usual production setup docs, but maybe I missed
something.
--
Matt Warnock <[hidden email]>
RidgeCrest Herbals, Inc.



Reply | Threaded
Open this post in threaded view
|

Re: switching external content between http and https?

samhamilton
In reply to this post by samhamilton
Now the really weird thing is that it only messes up the theme for that
specific page - the other pages seem unaffected say in catalog or even
in other parts on content?

On 21/08/2010 19:56, Sam Hamilton wrote:

> Hi Scott - thanks for the tip, it might just do the job nicely if there
> was not one weird side effect - if you set it for only one ecommerce
> application it then changes the all the back end themes too!
>
> Just try updating the demo ecommerce store -
> https://demo-trunk.ofbiz.apache.org:8443/content/control/EditWebSite?webSiteId=WebStore
> with a secure content prefix of https://images.apache.org and then the
> whole theme breaks even if you have selected "Themes to be used for
> Ecommerce applications" - I think this is an unintended bug. Where as
> really it should have only broken the website.
>
> Cheers
> Sam
>
>
>
> On 21/08/2010 18:17, Scott Gray wrote:
>> Hi Sam,
>>
>> The ofbizContentUrl directive should work for this, have you tried setting the content prefix properties either in url.properties or on the WebSite entity itself?
>>
>> Regards
>> Scott
>>
>> HotWax Media
>> http://www.hotwaxmedia.com
>>
>> On 21/08/2010, at 9:28 PM, Sam Hamilton wrote:
>>
>>> Sorry guys perhaps I am not being clear I was looking for a tag that
>>> when interpreted in ftl it switches between http and https automatically
>>>
>>> so in the ftl some tag other than ofbizUrl could be replaced and then
>>> this image works both on http and https ftl pages
>>>
>>> in headerHead.ftl the javascript is called from
>>> <script type="text/javascript"
>>> src="<@ofbizContentUrl>${StringUtil.wrapString(javaScript)}</@ofbizContentUrl>"
>>> type="text/javascript"></script>
>>>
>>> but this always seems to point to the ofbiz server and I want to be able
>>> to point it to an totally different domain (think Amazon CDN that allows
>>> http and https)
>>>
>>> So rather than using <@ofbizContentUrl> is there another tag that just
>>> changes between http and https?
>>>
>>> Thanks
>>> Sam
>>>
>>>
>>>
>>> On 21/08/2010 17:09, BJ Freeman wrote:
>>>> same this is pretty much standard.
>>>> you will get browser errors if you have http links in an Https URL.
>>>> The whole purpose of the Https URL is to be encrypted.
>>>> your only two choices are not to use HTTPS or to convert the images
>>>> repository to HTTPS
>>>> if you switch the Cart to HTTP, you would do this in the controller.
>>>>
>>>>
>>>>
>>>> Sam Hamilton sent the following on 8/21/2010 1:43 AM:
>>>>> Hi Guys,
>>>>>
>>>>> Is there a freemarker template tag that would automatically switch
>>>>> between http and https depending how the page has been loaded?
>>>>>
>>>>> I want to use an external image server for hosting images but when
>>>>> switching to the checkout all the urls should also switch over to https.
>>>>>
>>>>> p.s. is there a big list of template tags that work in ofbiz somewhere?
>>>>>
>>>>>
>>>>> Cheers
>>>>> Sam
>>>>>
>>>
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: Visible screen error on trunk demo and related question

Jacques Le Roux
Administrator
In reply to this post by Matt Warnock
Thanks for the report Matt,

I commited a quick workaround in trunk at r987813. I will not propagate it because it does not fix the reason which is somewhere
upstream in the forum definition I guess (Expression for instance is not from demo data)

This kind of errors in Freemarker template can't be trapped if the code has not been correctly written intially.
It's a kind of NPE, easily handled with the old "?default ()" expresion or rather the newer "!" And actually it's easier to stop on
screen than in log, since it's easy to fix I prefer this way.

Jacques

From: "Matt Warnock" <[hidden email]>

> When I go to the latest trunk demo, ecommerce store page, in the "browse
> forums" section on the left side bottom, there is an error that starts
> with "Expression forum.contentName is undefined on line 26".
>
> Is there a way to set OFBiz so that debugging info like this appears in
> the logs, but DOESN'T appear on customer-facing pages?  Seems like that
> would be part of the usual production setup docs, but maybe I missed
> something.
> --
> Matt Warnock <[hidden email]>
> RidgeCrest Herbals, Inc.
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Visible screen error on trunk demo and related question

Jacques Le Roux
Administrator
Matt,

We *rely on* Freemarker, so I can't see a way to avoid it.
Else sure it would have been done before (OFBiz is using Freemarker for years)
It's like testing for a NPE in java code, you can't avoid it.
It does not need to be on each field but when they are chances that a null value appears.

We might trapp the error in the stream and "cosmetize" it on screen (like some 404 pages are doing).
But as I said before it will not change much things: there is a bug there and it needs to be solved!

There are 1385 ?default(... in FTL files and 243 !}
I did no count the !... because it's a bit harder to do.... and maybe why people are reluctant to use ! instead of ?default()

Jacques

From: "Matt Warnock" <[hidden email]>

> Thanks for the quick response Jacques.
>
> So if I understand you correctly, you are saying that if the Freemarker
> code is correctly written, that is, to explicitly test for the null
> pointer condition, then the error message is caught by that test code,
> and does not make it to the screen.  So you are suggesting that all
> templates should contain such tests at every field?
>
> That seems like a lot of work and code to trap a (hopefully infrequent)
> data error.  Surely there must be some easier way?
>
> --
> Matt Warnock <[hidden email]>
> RidgeCrest Herbals, Inc.
>
> On Sat, 2010-08-21 at 20:59 +0200, Jacques Le Roux wrote:
>> Thanks for the report Matt,
>>
>> I commited a quick workaround in trunk at r987813. I will not propagate it because it does not fix the reason which is somewhere
>> upstream in the forum definition I guess (Expression for instance is not from demo data)
>>
>> This kind of errors in Freemarker template can't be trapped if the code has not been correctly written intially.
>> It's a kind of NPE, easily handled with the old "?default ()" expresion or rather the newer "!" And actually it's easier to stop
>> on
>> screen than in log, since it's easy to fix I prefer this way.
>>
>> Jacques
>>
>> From: "Matt Warnock" <[hidden email]>
>> > When I go to the latest trunk demo, ecommerce store page, in the "browse
>> > forums" section on the left side bottom, there is an error that starts
>> > with "Expression forum.contentName is undefined on line 26".
>> >
>> > Is there a way to set OFBiz so that debugging info like this appears in
>> > the logs, but DOESN'T appear on customer-facing pages?  Seems like that
>> > would be part of the usual production setup docs, but maybe I missed
>> > something.
>> > --
>> > Matt Warnock <[hidden email]>
>> > RidgeCrest Herbals, Inc.
>> >
>> >
>> >
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: Visible screen error on trunk demo and related question

Jacques Le Roux
Administrator
Hi Matt,

From: "Matt Warnock" <[hidden email]>
> Thanks Jacques.
>
> Null pointers in data, or NULL values in persistence entities are always
> a possibility, though they really should be caught by data integrity
> checks when the data is created or stored.

In A Freemarker template it may come from a grovvy change

> It seems like checking at each point that a data value could possibly be
> NULL would be a lot of work with little benefit.  It might be easier to
> munge all NULL entity values into null strings when the record is read
> (or passed to a template), thus avoiding any possibility of displaying
> it with error messages. Of course you'd have to munge it back before
> storing the data again (if you do), but that is where the error checks
> should be anyway.

As I say, FTL files depend on groovy ahead

> But again, when NULL values do accidentally make their way into data,
> is there some way to trap the error traces in the logs and NOT send them
> to the screen?

I already explained for FTL files. That's why we prefer to use widget form. Of course in some case (eCommerce mostly) there are not
powerful/flexible enough

>And should that be part of the production guide
> somewhere?

Feel free to contribute in the open wiki if you have any idas

>I think most admins of *production* systems would probably
> prefer NOT to have customers see their debug traces.

If/when you have anything ready to conttribute kease feel free to open a Jira and create a patch

Thanks

Jacques
 --

> Matt Warnock <[hidden email]>
> RidgeCrest Herbals, Inc.
>
>
> On Sun, 2010-08-22 at 13:36 +0200, Jacques Le Roux wrote:
>> Matt,
>>
>> We *rely on* Freemarker, so I can't see a way to avoid it.
>> Else sure it would have been done before (OFBiz is using Freemarker for years)
>> It's like testing for a NPE in java code, you can't avoid it.
>> It does not need to be on each field but when they are chances that a null value appears.
>>
>> We might trapp the error in the stream and "cosmetize" it on screen (like some 404 pages are doing).
>> But as I said before it will not change much things: there is a bug there and it needs to be solved!
>>
>> There are 1385 ?default(... in FTL files and 243 !}
>> I did no count the !... because it's a bit harder to do.... and maybe why people are reluctant to use ! instead of ?default()
>>
>> Jacques
>>
>> From: "Matt Warnock" <[hidden email]>
>> > Thanks for the quick response Jacques.
>> >
>> > So if I understand you correctly, you are saying that if the Freemarker
>> > code is correctly written, that is, to explicitly test for the null
>> > pointer condition, then the error message is caught by that test code,
>> > and does not make it to the screen.  So you are suggesting that all
>> > templates should contain such tests at every field?
>> >
>> > That seems like a lot of work and code to trap a (hopefully infrequent)
>> > data error.  Surely there must be some easier way?
>> >
>> > --
>> > Matt Warnock <[hidden email]>
>> > RidgeCrest Herbals, Inc.
>> >
>> > On Sat, 2010-08-21 at 20:59 +0200, Jacques Le Roux wrote:
>> >> Thanks for the report Matt,
>> >>
>> >> I commited a quick workaround in trunk at r987813. I will not propagate it because it does not fix the reason which is
>> >> somewhere
>> >> upstream in the forum definition I guess (Expression for instance is not from demo data)
>> >>
>> >> This kind of errors in Freemarker template can't be trapped if the code has not been correctly written intially.
>> >> It's a kind of NPE, easily handled with the old "?default ()" expresion or rather the newer "!" And actually it's easier to
>> >> stop
>> >> on
>> >> screen than in log, since it's easy to fix I prefer this way.
>> >>
>> >> Jacques
>> >>
>> >> From: "Matt Warnock" <[hidden email]>
>> >> > When I go to the latest trunk demo, ecommerce store page, in the "browse
>> >> > forums" section on the left side bottom, there is an error that starts
>> >> > with "Expression forum.contentName is undefined on line 26".
>> >> >
>> >> > Is there a way to set OFBiz so that debugging info like this appears in
>> >> > the logs, but DOESN'T appear on customer-facing pages?  Seems like that
>> >> > would be part of the usual production setup docs, but maybe I missed
>> >> > something.
>> >> > --
>> >> > Matt Warnock <[hidden email]>
>> >> > RidgeCrest Herbals, Inc.
>> >> >
>> >> >
>> >> >
>> >>
>> >
>>
>