Opened on 06/28/2018 at 10:40:58 AM
Closed on 09/25/2018 at 03:04:31 PM
#6769 closed change (fixed)
Set and make use of siteurl in testpages.adblockplus.org
Reported by: | Ross | Assignee: | kzar |
---|---|---|---|
Priority: | P2 | Milestone: | |
Module: | Unknown | Keywords: | testpages |
Cc: | kzar, sebastian | Blocked By: | |
Blocking: | Platform: | Unknown / Cross platform | |
Ready: | yes | Confidential: | no |
Tester: | Unknown | Verified working: | no |
Review URL(s): |
Description (last modified by kzar)
Background
The testpages currently have hard coded urls in several places:
- The subscription link.
- The filters displayed under each test case.
- The filters contained inside of the subscription.
This means to test/develop the testpages you must redirect the testpages.adblockplus.org domain in your hosts file to your local machine and run the cms server on port 80.
It would be useful/easier if the base/site url was set in one place such as the settings.ini file.
What to change
- Add siteurl = https://testpages.adblockplus.org to settings.ini.
- Instead of hardcoding that elsewhere use the site_url variable: {{ site_url }}.
- Have abp-testcases-subscription.txt generated by the CMS too, instead of being a static file, so that the site_url variable can be used for it too.
- Revise the usage instructions, so that we no longer mention messing with the hosts file nor specifying port 80.
Attachments (0)
Change History (9)
comment:1 Changed on 06/28/2018 at 10:46:55 AM by Ross
comment:2 Changed on 07/04/2018 at 05:59:20 PM by kzar
- Cc sebastian added
- Description modified (diff)
comment:4 Changed on 07/04/2018 at 06:01:21 PM by kzar
- Summary changed from Set base/site url in settings.ini for testpages to Set and make use of siteurl in testpages.adblockplus.org
comment:5 Changed on 09/04/2018 at 10:36:44 AM by Ross
I've tried to implement this several times. Getting URL's for use in the filters listed on the page as the documentation part/for copy paste is easy enough:
{% macro siteurl_full() -%} {{config.get("general", "siteurl")}} {%- endmacro %}
{% macro siteurl_noprotocol() -%} {% set v = config.get("general", "siteurl").split('://') %} {{v[1]}} {%- endmacro %}
{% from 'macros/siteurl' import siteurl_noprotocol with context %} ||{{siteurl_noprotocol()}}##.examplefilter
But I haven't been able to figure out how to use these in the subscription itself. Currently the subscription file is in /static/ which means it's just a non-transformed text file and the macro cannot be used there. I attmpted to make a "raw" template like so:
{{ body }}
and then have the subscription file like so:
template = raw {% from 'macros/siteurl' import siteurl_noprotocol with context %} [Adblock Plus 2.0] ! filters/blocking ||{{siteurl_noprotocol()}}/testcasefiles/blocking/addresscomplete/image.jpg /testcasefiles/blocking/addresspart/abptestcasepath/ ||{{siteurl_noprotocol()}}/testcasefiles/blocking/wildcard/*/image.jpg
However this still outputs with HTML and ABP refuses to accept it as a valid subscription file. I don't have enough cms project knowledge to figure out a way around this.
Essentially, what we want is the ability to output a text/.txt file that can use the macros to get the URL (I think). Although any solution that works is welcome.
comment:6 Changed on 09/04/2018 at 02:46:40 PM by kzar
- Owner set to kzar
- Priority changed from Unknown to P2
- Ready set
comment:7 Changed on 09/04/2018 at 04:25:52 PM by kzar
- Review URL(s) modified (diff)
- Status changed from new to reviewing
comment:8 Changed on 09/25/2018 at 03:00:57 PM by abpbot
A commit referencing this issue has landed:
Issue 6769 - Avoid hardcoding the URL
comment:9 Changed on 09/25/2018 at 03:04:31 PM by kzar
- Resolution set to fixed
- Status changed from reviewing to closed
I've played around with various methods of doing this (such as a global python function, adding a jinja filter, using a macro) and in my opinion using a macro seems to be easiest.
A macro imported with context could access the config.get() function and then perform the string replace on the url.