đŸ’Ÿ Archived View for gemini.ctrl-c.club â€ș ~ssb22 â€ș adjuster.gmi captured on 2023-01-29 at 03:24:57. Gemini links have been rewritten to link to archived content

View Raw

More Information

âŹ…ïž Previous capture (2022-07-16)

âžĄïž Next capture (2023-05-24)

🚧 View Differences

-=-=-=-=-=-=-

Web Adjuster

Web Adjuster is a Tornado-based, domain-rewriting proxy for applying custom processing to Web pages. It is particularly meant for users of smartphones etc as these might not support browser extensions. Web Adjuster can:

Domain rewriting means you do not need to be able to change the device’s proxy settings—you simply go to a different address. However, only the domain part is different, so most in-site scripting should work as-is, without needing delicate alterations to its URI handling. For example, if you have a server called adjuster.example.org and you want to see www.example.com, simply go to www.example.com.adjuster.example.org. Your server ideally needs a wildcard domain, but you can manage without one in some cases, and Web Adjuster can also be a “real” HTTP proxy for local use on a desktop etc.

Because it is based on a single-threaded event-driven Tornado server, Web Adjuster can efficiently handle connections even on a low-power machine like the original Raspberry Pi. (Add-on programs run in other threads, but this is seldom a slow-down in practice.) Tornado also makes Web Adjuster easier to set up: it is a separate, self-contained server that doesn’t need to be worked into the configuration of another one—it can listen on an alternate port (and can be password protected)—but if you prefer you *can* configure it to share port 80 with another server.

Installation

1. Make sure Python and Tornado are on the system. (Web Adjuster has been tested in both Python 2 and Python 3, and with Tornado versions between 2.x and 6.x.)

2. Download adjuster.py

3. Run it with the appropriate options (see below), or use it in a WSGI application.

adjuster.py

Options for Web Adjuster v3.222

General options

Network listening and security settings

DNS and website settings

General adjustment options

External processing options

Javascript execution options

Server control options

Media conversion options

Character rendering options

Dynamic DNS options

Speedup options

Logging options

Tornado-provided logging options are not listed above because they might vary across Tornado versions; run python adjuster.py --help to see a full list of the ones available on your setup. They typically include log_file_max_size, log_file_num_backups, log_file_prefix and log_to_stderr.

WSGI mode

Web Adjuster is best run as a standalone server (see above) or behind a proxy like nginx, but if you must use WSGI then you can do it like this:

1. In your wrapper Python script, import adjuster

2. Set options via adjuster.options. optionName = value (remembering to set port to 80; options are as above, but some of them, such as server control options, do not apply to WSGI mode)

3. Do myApp = adjuster.make_WSGI_application()

4. Do something with myApp, according to whatever WSGI framework you are using.

4.1. Make an app.yaml file like:

runtime: python27
api_version: 1
threadsafe: true
automatic_scaling:
  max_instances: 1
  min_instances: 0
handlers:
- url: .*
  script: wrapper.myApp

where wrapper is the name of your wrapper script

4.2. Place and/or symlink this app.yaml along with adjuster.py and your wrapper script, and also the tornado subdirectory from a download of Tornado version 5.1.1 or below (version 6 dropped this functionality). You might also need to create an empty “placeholder” version of fcntl.py (Tornado 3 also needs an empty ssl.py but this shouldn’t be done if you downloaded Tornado 5)

4.3. Deploy via gcloud app deploy app.yaml --project followed by the app ID you registered. (Be warned: after the 2020 removal of appcfg, all updates must use gcloud which means a payment method must be entered even if you use only the “free tier”. Google said the above setting of max_instances: 1 “usually keeps your instance hour usage within the free tier” but the word “usually” implies it’s not guaranteed, and they now know where your bank is!)

Options that call external programs are unlikely to work in AppEngine but you can use htmlFilter with Python functions (see above; if you have large modules not always used then you might want to import these *on demand*). If your settings need PIL or LXML, you can also add these to app.yaml e.g.

libraries:
- name: PIL
  version: "1.1.7"
- name: lxml
  version: "2.3.5"
ErrorDocument 404 /wrapper.cgi
Options -Indexes
ErrorDocument 403 /wrapper.cgi

in .htaccess (and ensure AllowOverride All is set in the config files) to send all requests to the CGI, which should then import adjuster from outside the webspace (e.g. by adding to sys.path first)—but it’s not necessary to send other requests to the CGI if you set submitPath to the CGI’s path plus ? and want only the ‘enter your own text’ functionality.

To-do list

When dealing with a very slow site, it would be nice if Web Adjuster could start sending text to the browser *before* the upstream fetch has completed.

License

Web Adjuster is free software licensed under the Apache License, Version 2.0 (this is also the license used by Tornado itself). If you use it in a good project, I’d appreciate hearing about it.

Citation

If you need to cite a peer-reviewed paper:

Silas S. Brown.  Web Annotation with Modified-Yarowsky and Other Algorithms.  Overload 112 (December 2012) pp.4-7

Legal

All material © Silas S. Brown unless otherwise stated. Android is a trademark of Google LLC. Apache is a registered trademark of The Apache Software Foundation. AppEngine is possibly a trademark of Google LLC. Energenie is a trademark of Sandal Plc. Firefox is a registered trademark of The Mozilla Foundation. Google is a trademark of Google LLC. iPhone is a trademark of Apple in some countries. Javascript is a trademark of Oracle Corporation in the US. Linux is the registered trademark of Linus Torvalds in the U.S. and other countries. Mac is a trademark of Apple Inc. MP3 is a trademark that was registered in Europe to Hypermedia GmbH Webcasting but I was unable to confirm its current holder. Post Office is a registered trademark of Post Office Limited. Python is a trademark of the Python Software Foundation. Raspberry Pi is a trademark of the Raspberry Pi Foundation. Unicode is a registered trademark of Unicode, Inc. in the United States and other countries. Unix is a trademark of The Open Group. Windows is a registered trademark of Microsoft Corp. Any other trademarks I mentioned without realising are trademarks of their respective holders.