From 944ad8ff37a24546491357b2c7ad2d33acef4d25 Mon Sep 17 00:00:00 2001
From: Markus Birth
Date: Fri, 20 May 2016 23:34:50 +0200
Subject: [PATCH] Various improvements and additions.
---
.htaccess | 2 +-
css/frs.css | 24 +-
index.php | 68 +++++-
templates/faq_html.mustache | 21 ++
templates/index_html.mustache | 243 ++++---------------
templates/loggedin_html.mustache | 61 ++++-
templates/notverified_html.mustache | 21 ++
templates/partials/mdl_content_foot.mustache | 5 +-
templates/partials/mdl_head.mustache | 24 +-
9 files changed, 240 insertions(+), 229 deletions(-)
create mode 100644 templates/faq_html.mustache
create mode 100644 templates/notverified_html.mustache
diff --git a/.htaccess b/.htaccess
index d8b93ba..72c0dc4 100644
--- a/.htaccess
+++ b/.htaccess
@@ -3,4 +3,4 @@
RewriteEngine on
-RewriteRule ^([^.]+)/?$ index.php?action=$1 [L,NC]
+RewriteRule ^([^./]+)/?$ index.php?action=$1 [L,NC]
diff --git a/css/frs.css b/css/frs.css
index c81cc11..4c5b9bc 100644
--- a/css/frs.css
+++ b/css/frs.css
@@ -66,6 +66,24 @@
}
.mdl-layout a {
- color: inherit !important;
- text-decoration: inherit !important;
-}
\ No newline at end of file
+ color: inherit !important;
+ text-decoration: inherit !important;
+}
+
+.mdl-list__item-avatar {
+ background-color: transparent !important;
+ color: rgb(117, 117, 117) !important;
+}
+
+.frs-selector li {
+ transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
+}
+
+.frs-selector li:hover {
+ background-color: rgb(238, 238, 238);
+ cursor: pointer;
+}
diff --git a/index.php b/index.php
index 69f617b..f24f568 100644
--- a/index.php
+++ b/index.php
@@ -39,22 +39,70 @@ if (isset($_GET['code']) && $_GET['code']) {
exit(0);
}
-if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
+$tpl_done = false;
+
+// route pages that work with and without login
+if (isset($_GET['action'])) {
+ switch ($_GET['action']) {
+ case 'faq':
+ $tpl = $m->loadTemplate('faq_html');
+ $tpl_done = true;
+ break;
+ }
+}
+
+if (!$tpl_done && isset($_SESSION['access_token']) && $_SESSION['access_token']) {
// Authenticated
- $client->setAccessToken($_SESSION['access_token']);
+ try {
+ $created = $_SESSION['access_token']['created'];
+ $expires = $_SESSION['access_token']['expires_in'];
+ $expire_stamp = intval($created) + intval($expires);
+ $data['session_created'] = $created;
+ $data['session_expires'] = $expires;
+ $data['session_time_left'] = ($expire_stamp) - time();
+ $client->setAccessToken($_SESSION['access_token']);
+ } catch (Exception $e) {
+ print_r($e);
+ $_SESSION['access_token'] = $client->refreshToken(null);
+ print_r($_SESSION['access_token']);
+ }
$data['auth_needed'] = false;
- $oauth = new Google_Service_Oauth2($client);
- $userdata = $oauth->userinfo->get();
- $data['user']['name_first'] = $userdata->givenName;
- $data['userdata'] = print_r($userdata, true);
+ try {
+ $oauth = new Google_Service_Oauth2($client);
+ $userdata = $oauth->userinfo->get();
+ } catch (Exception $e) {
+ print_r($e);
+ die();
+ }
+ $data['user'] = array(
+ 'name_first' => $userdata->givenName,
+ 'name_last' => $userdata->familyName,
+ 'name' => $userdata->name,
+ 'picture' => $userdata->picture,
+ 'email' => $userdata->email,
+ 'gender' => $userdata->gender,
+ );
+ // Check $userdata->verifiedEmail and deny if not verified.
+ if (!$userdata->verifiedEmail) {
+ $tpl = $m->loadTemplate('notverified_html');
+ $tpl_done = true;
+ }
- // TODO: Check $userdata->verifiedEmail and deny if not verified.
-
- $tpl = $m->loadTemplate('loggedin_html');
-} else {
+ switch ($_GET['action']) {
+ case 'faq':
+ $tpl = $m->loadTemplate('faq_html');
+ break;
+ default:
+ if (!$tpl_done) {
+ $tpl = $m->loadTemplate('loggedin_html');
+ $tpl_done = true;
+ }
+ break;
+ }
+} elseif (!$tpl_done) {
// Not authenticated
$data['auth_needed'] = true;
$data['auth_url'] = $client->createAuthUrl();
diff --git a/templates/faq_html.mustache b/templates/faq_html.mustache
new file mode 100644
index 0000000..1940fe0
--- /dev/null
+++ b/templates/faq_html.mustache
@@ -0,0 +1,21 @@
+{{> html_head}}
+{{> mdl_head}}
+{{> mdl_content_head}}
+
+
+
+Frequently Asked Questions
+
+What happens to my data?
+
+
+Your data won't be stored on our servers. It is solely used to compose the mail.
+After the mail is sent, your data is deleted from our servers.
+
+
+
+{{> mdl_content_foot}}
+{{> mdl_foot}}
+{{> html_foot}}
diff --git a/templates/index_html.mustache b/templates/index_html.mustache
index 8f0db43..dee56d2 100644
--- a/templates/index_html.mustache
+++ b/templates/index_html.mustache
@@ -3,215 +3,54 @@
{{> mdl_content_head}}
- Not Google > Not Google Now > Fake Reservation System
+
Fake Reservation System > Welcome
What is this?
-{{# auth_needed}}
+Some time ago, Google introduced features to highlight special items from your
+mails, like hotel reservations, event tickets, car rentals and more.
+
+
+
+Later, they added features to Google Now on Android smartphones so that you
+get notified when to leave to catch your flight or event … or how to get to
+your booked hotel and when the checkin opens.
+
+
+
+And recently, they even added a feature to Google Search, that shows your
+booked items when you search for similar things. All that from a mail in your
+inbox.
+
+
+
+A nice overview with sample images can be found on Google's Developer pages:
+https://developers.google.com/gmail/markup/ .
+
+
+
+But while the needed data is easy to be added to confirmation mails, many
+companies didn't do this yet. And sometimes, you don't even get any confirmation
+by email. To make those things show up in Google Now, I made this tool.
+
+
+
+What does it do?
+
+
+After login with your Google account, you can select a type of reservation,
+fill in all your details and send it to the mail address of your account.
+We will add all the neccessary markup to the mail so that Google Now can
+recognise it. This will make the events/reservations show up when you need
+them.
+
+
+
+To begin, please sign in:
-{{/ auth_needed}}
-
-{{# userdata}}
-
-
{{userdata}}
-
-{{/ userdata}}
-
-
- Hello, world! ({{action}})
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
-
- Hello, world!
-
{{> mdl_content_foot}}
{{> mdl_foot}}
diff --git a/templates/loggedin_html.mustache b/templates/loggedin_html.mustache
index 5322f86..8808f36 100644
--- a/templates/loggedin_html.mustache
+++ b/templates/loggedin_html.mustache
@@ -3,19 +3,62 @@
{{> mdl_content_head}}
- Not Google > Not Google Now > Fake Reservation System
+
Fake Reservation System > Logged in
-What is this?
-
-{{# userdata}}
-
-
{{userdata}}
-
-{{/ userdata}}
+Select the type of reservation you want to create
- Welcome, to the Fake Reservation System . Where you can book travels you'll never attend.
+
+
+
+ event
+ Generic Event
+
+ Use this type to declare a reservation for one or more guests at an event.
+ Tickets may be declared as well.
+
+
+
+
+
+ flight_takeoff
+ Flight Reservation
+
+ Use this type to declare a reservation for air travel.
+
+
+
+
+
+ hotel
+ Hotel Reservation
+
+ Use this type to declare a reservation for one or more guests at a hotel
+ or place of lodging.
+
+
+
+
+
+ directions_car
+ Rental Car Reservation
+
+ Use this type to declare a reservation for a rental car.
+
+
+
+
+
+ restaurant
+ Restaurant Reservation
+
+ Use this type to declare a reservation for one or more guests at a
+ restaurant or other food establishment.
+
+
+
+
{{> mdl_content_foot}}
diff --git a/templates/notverified_html.mustache b/templates/notverified_html.mustache
new file mode 100644
index 0000000..93bdaa0
--- /dev/null
+++ b/templates/notverified_html.mustache
@@ -0,0 +1,21 @@
+{{> html_head}}
+{{> mdl_head}}
+{{> mdl_content_head}}
+
+
+
+Your email address is not verified!
+
+ To use this system, you must verify your Google email address first!
+
+
+
+ You can find more information at this address:
+ https://support.google.com/accounts/answer/63950 .
+
+
+{{> mdl_content_foot}}
+{{> mdl_foot}}
+{{> html_foot}}
diff --git a/templates/partials/mdl_content_foot.mustache b/templates/partials/mdl_content_foot.mustache
index 01c7101..04391f4 100644
--- a/templates/partials/mdl_content_foot.mustache
+++ b/templates/partials/mdl_content_foot.mustache
@@ -3,9 +3,8 @@
diff --git a/templates/partials/mdl_head.mustache b/templates/partials/mdl_head.mustache
index 213e7e3..2ea4a84 100644
--- a/templates/partials/mdl_head.mustache
+++ b/templates/partials/mdl_head.mustache
@@ -6,7 +6,7 @@
{{# user.name_first}}
- Hello, {{user.name_first}}!
+ Hello, {{user.name_first}}!
{{/ user.name_first}}