diff --git a/xwords4/android/scripts/and_index.php b/xwords4/android/scripts/and_index.php deleted file mode 100644 index affecb246..000000000 --- a/xwords4/android/scripts/and_index.php +++ /dev/null @@ -1,111 +0,0 @@ - - - - - CrossWords Invite redirect - - -
- -
-EOF; -} - -function printTail() { -print << - -EOF; -} - -function printNonAndroid($agent) { - $subject = "Android device not identified"; - - $body = htmlentities("My browser is running on an android device but" - . " says its user agent is: \"$agent\"." - . " Please fix your website to recognize" - . " this as an Android browser."); - print << -

This page is meant to be viewed on an Android device.

-
-

(If you are viewing this on an Android device, - you've found a bug! Please email me - (and be sure to leave the user agent string in the email body.) -

- - -EOF; -} - -function printAndroid() { -print << -

You'll have come here after clicking a link in an email or - text inviting you to a CrossWords game. But you should not be seeing - this page.

- -

If you got this page on your device, it means either -

    -
  • You don't have CrossWords installed
  • -
  • OR
  • -
  • that when you clicked on the link and were asked to choose between a - browser and CrossWords you chose the browser.
  • -

- -

In the first case, install the latest CrossWords, -either via -the Google Play store or -(sideloading) via -Sourceforge.net. After the install is finished go back to the -invite email (or text) and tap the link again.

- -

In the second case, hit your browser's back button, click the -link in your invite email (or text) again, and this time let -CrossWords handle it.

- -

(If you get tired of having to having to make that choice, Android -will allow you to make CrossWords the default. If you do that -CrossWords will be given control of all URLs that start with -"http://eehouse.org/and/" -- not all URLs of any type.)

- -

Have fun. And as always, let -me know if you have problems or suggestions.

- -
- -
-EOF; -} - - -/********************************************************************** - * Main() - **********************************************************************/ -$agent = $_SERVER['HTTP_USER_AGENT']; -$onAndroid = false; -for ( $ii = 0; $ii < count($g_androidStrings) && !$onAndroid; ++$ii ) { - $needle = $g_androidStrings[$ii]; - $onAndroid = false !== stripos( $agent, $needle ); -} -$onFire = false !== stripos( $agent, 'silk' ); - -printHead(); -if ( /*true || */ $onFire || $onAndroid ) { - printAndroid(); -} else { - printNonAndroid($agent); -} -printTail(); - - -?> diff --git a/xwords4/android/scripts/and_index.py b/xwords4/android/scripts/and_index.py new file mode 100755 index 000000000..4d707b1ab --- /dev/null +++ b/xwords4/android/scripts/and_index.py @@ -0,0 +1,82 @@ +#!/usr/bin/python3 + +try: + from mod_python import apache + apacheAvailable = True +except ImportError: + apacheAvailable = False + +def printHead(): + return """ + + + + CrossWords Invite redirect + + +""" + +def printTail(): + return '' + +def printAndroid(): + return """ +
+ +

You should not be seeing this page.

+ +

One of two things went wrong: +

• You don't have CrossWords installed
+
OR
+
• When you clicked on a link and were asked to choose between a + browser and CrossWords you chose the browser.
+

+ +

In the first case, install the latest CrossWords, either via the Google +Play store or directly +from the author's site (sideloading). After the install is +finished go back to the invite email (or text) and tap the link +again.

+ +

Otherwise, hit your browser's back button, click the +invitation link again, and this time choose CrossWords to handle +it.

+ +

(If you get tired of having to having to make that choice, Android +will allow you to make CrossWords the default. If you do that +CrossWords will be launched for all URLs that start with +"https://eehouse.org/and/" -- not all URLs of any type.)

+ +

Have fun. And as always, let +me know if you have problems or suggestions.

+
+""" + +def printNonAndroid(agent): + subject = 'Android device not identified' + body = 'My browser is running on an android device but says its' \ + + ' user agent is: \"{agent}\". Please fix your website' \ + + ' to recognize this as an Android browser'.format(agent=agent) + fmt = """ +
+

This page is meant to be viewed on an Android device.

+
+

(If you are viewing this on an Android device, + you've found a bug! Please email me. +

+
+""" + return fmt.format(subject=subject, body=body) + + +def index(req): + str = printHead() + agent = req.headers_in.get('User-Agent', None) + if agent and 'Android' in agent: + str += printAndroid() + else: + str += printNonAndroid(agent) + str += printTail() + return str