Skip to content

Commit

Permalink
functions updated
Browse files Browse the repository at this point in the history
  • Loading branch information
goody-h committed Oct 22, 2018
1 parent cdd2e49 commit 170b6fc
Show file tree
Hide file tree
Showing 11 changed files with 167 additions and 101 deletions.
12 changes: 12 additions & 0 deletions Firebase Hosting/.firebase/hosting.0.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
404.html,1526589291891,b7bab6b83fa074653ff28c8d2a64135d3434575f70a12ab3d3ba8080461b9537
favicon.png,1539889144976,e897b793266fcb6c0ad80d280462a1248853348066c9a33e8eba95064a89cd4c
orsteg_apps_harold_og_image.png,1539889145004,6f110f19678772f87b42a9a4191a0dcc2f3a0f91342f61ff1c84ddeb05698771
privacy_policy.html,1538443743080,35143676d4faa6f14acb49e7b1efbc79fef7af53b2b1d49ca27142f758bb3ebf
privacy_policy.txt,1538445275217,3f4b2d3b9a4672948c3b5a77af7b6b90b439d4f5da75d9313c3e140bbe4d2e75
sitemap.xml,1540020198278,9170fd01fe0fedf999cdbdf2e0c93e9877eafdde03eb20423483b659bbda7268
terms_and_conditions.html,1538443847592,b1deeae6b7ffb7a2c662460461fe97710e82979bfa5e3fb7e259ea0a641da604
terms_and_conditions.txt,1538445397943,825a811236b1a4ba9937b3129d58054a8fba83c4e70cb0198cedc4bd399166da
featured_banner.png,1539889145000,92e6c05e89126e0d83dd787efd9231bfe576bd2c7e03aa3a429387de73e1db19
index.html,1540155730858,5259b026cb212f9c0ead72150a72dee3e112ce2367e04443dcc017a5efd637dc
robots.txt,1540155820134,dec531097d819a68e5faac5e5c7bf59d1850b4a915b25e0347a04a34b616c3c0
store/index.html,1540155782388,90afceed24d7a283233f1cbdca43498500f33c9930f17b3370cf6b2e4ce93d00
42 changes: 37 additions & 5 deletions Firebase Hosting/database.rules.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
{
"rules": {
".read": true,
".write": true
}
}
"rules": {
".read": false,
".write": false,
"DepartmentList": {
".read": true,
".write": "auth !== null"
},
"InstitutionList": {
".read": true,
".write": "auth !== null"
},
"Institutions": {
".read": true
},
"Eds": {
".read": true
},
"CourseTemplates": {
".read": true,
".indexOn": ["edKey", "ownerId"],
"$id": {
".write": "!data.exists() || data.child('ownerId').val() == auth.uid"
}
},
"Users": {
"$uid": {
".read": "$uid === auth.uid",
".write": "$uid === auth.uid"
}
},
"Requests": {
"$id": {
".write": "auth !== null && !data.exists()"
}
}
}
}
39 changes: 15 additions & 24 deletions Firebase Hosting/functions/index.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
/* Harold firebase cloud functions for checking database state and changes */

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);

// // Create and Deploy Your First Cloud Functions
// // https://firebase.google.com/docs/functions/write-firebase-functions
//
exports.helloWorld = functions.https.onRequest((request, response) => {
response.send("Hello from Firebase!");
});
admin.initializeApp();

exports.templateChange = functions.database.ref('/CourseTemplates/{id}').onWrite(event => {
const template = (event.data.val()) ? event.data.val() : event.data.previous.val();
const pTemplate = event.data.previous.val();
exports.templateChange = functions.database.ref('/CourseTemplates/{id}').onWrite((change, context) => {
const template = (change.after.val()) ? change.after.val() : change.before.val();
const pTemplate = change.before.val();
const owner = template.ownerId;
const iName = template.edKey.replace(/%&[\s\S]*/, '');
const dName = template.edKey.replace(/[\s\S]*%&/, '');
const inst = iName.replace(/\s+/g, '_');
const dept = dName.replace(/\s+/g, '_');

if (event.data.previous.val() && event.data.current.val()) {
if (change.before.val() && change.after.val()) {
return console.log('This is an update');
}

Expand Down Expand Up @@ -78,11 +73,11 @@ exports.templateChange = functions.database.ref('/CourseTemplates/{id}').onWrite
});


exports.userNameChange = functions.database.ref('/Users/{id}/userName').onWrite(event => {
const userId = event.params.id;
const userName = event.data.val();
exports.userNameChange = functions.database.ref('/Users/{id}/userName').onWrite((change, context) => {
const userId = context.params.id;
const userName = change.after.val();

if (!event.data.previous.val()) {
if (!change.before.val()) {
return console.log('new userName');
}

Expand All @@ -99,10 +94,10 @@ exports.userNameChange = functions.database.ref('/Users/{id}/userName').onWrite(

});

exports.edKeyChanged = functions.database.ref('/Users/{id}').onWrite(event => {
const user = event.data.val();
const userId = event.params.id;
const pUser = event.data.previous.val();
exports.edKeyChanged = functions.database.ref('/Users/{id}').onWrite((change, context) => {
const user = change.after.val();
const userId = context.params.id;
const pUser = change.before.val();

if (!pUser) {
return console.log('new user');
Expand Down Expand Up @@ -190,8 +185,4 @@ exports.edKeyChanged = functions.database.ref('/Users/{id}').onWrite(event => {
});
});
});
});

exports.onRequest = functions.database.ref('/Requests/{id}').onWrite(event => {

});
4 changes: 2 additions & 2 deletions Firebase Hosting/functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"logs": "firebase functions:log"
},
"dependencies": {
"firebase-admin": "~6.0.0",
"firebase-admin": "6.0.0",
"firebase-functions": "^2.0.5"
},
"private": true
}
}
2 changes: 1 addition & 1 deletion Firebase Hosting/functions/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ [email protected]:
statuses "~1.4.0"
unpipe "~1.0.0"

firebase-admin@~6.0.0:
[email protected]:
version "6.0.0"
resolved "https://registry.yarnpkg.com/firebase-admin/-/firebase-admin-6.0.0.tgz#6a4be9e38b523ad7b4397b9b35853e4412e135ae"
dependencies:
Expand Down
Binary file added Firebase Hosting/public/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
97 changes: 43 additions & 54 deletions Firebase Hosting/public/index.html
Original file line number Diff line number Diff line change
@@ -1,65 +1,54 @@
<!DOCTYPE html>
<html>
<head>

<head>

<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Welcome to Firebase Hosting</title>
<title>Harold - CGPA &amp; GPA Calculator | Free download on play store</title>

<meta property="og:title" content="Harold - CGPA &amp; GPA Calculator" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="Feature rich and simple cgpa calculator with downloadable course lists" />
<meta property="og:description" content="Feature rich and simple cgpa calculator with downloadable course lists" />
<link rel="canonical" href="http://harold.apps.orsteg.com" />
<meta property="og:url" content="http://harold.apps.orsteg.com" />
<meta property="og:site_name" content="Harold.apps.Orsteg.com" />
<meta name="keywords" content="Harold - CGPA &amp; GPA Calculator, Harold - CGPA &amp; GPA Calculator for android, Harold - CGPA &amp; GPA Calculator android download, Harold - CGPA &amp; GPA Calculator apk, Harold - CGPA &amp; GPA Calculator android apk, Harold - CGPA &amp; GPA Calculator download, free download"
/>
<meta property="og:image" content="https://harold.apps.orsteg.com/orsteg_apps_harold_og_image.png" />

<!-- update the version number as needed -->
<script defer src="/__/firebase/4.13.0/firebase-app.js"></script>
<!-- include only the Firebase features as you need -->
<script defer src="/__/firebase/4.13.0/firebase-auth.js"></script>
<script defer src="/__/firebase/4.13.0/firebase-database.js"></script>
<script defer src="/__/firebase/4.13.0/firebase-messaging.js"></script>
<script defer src="/__/firebase/4.13.0/firebase-storage.js"></script>
<!-- initialize the SDK after all desired features are loaded -->
<script defer src="/__/firebase/init.js"></script>
<link rel="shortcut icon" href="/favicon.png" />

<style media="screen">
body { background: #ECEFF1; color: rgba(0,0,0,0.87); font-family: Roboto, Helvetica, Arial, sans-serif; margin: 0; padding: 0; }
#message { background: white; max-width: 360px; margin: 100px auto 16px; padding: 32px 24px; border-radius: 3px; }
#message h2 { color: #ffa100; font-weight: bold; font-size: 16px; margin: 0 0 8px; }
#message h1 { font-size: 22px; font-weight: 300; color: rgba(0,0,0,0.6); margin: 0 0 16px;}
#message p { line-height: 140%; margin: 16px 0 24px; font-size: 14px; }
#message a { display: block; text-align: center; background: #039be5; text-transform: uppercase; text-decoration: none; color: white; padding: 16px; border-radius: 4px; }
#message, #message a { box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24); }
#load { color: rgba(0,0,0,0.4); text-align: center; font-size: 13px; }
@media (max-width: 600px) {
body, #message { margin-top: 0; background: white; box-shadow: none; }
body { border-top: 16px solid #ffa100; }
}
</style>
</head>
<body>
<div id="message">
<h2>Welcome</h2>
<h1>Firebase Hosting Setup Complete</h1>
<p>You're seeing this because you've successfully setup Firebase Hosting. Now it's time to go build something extraordinary!</p>
<a target="_blank" href="https://firebase.google.com/docs/hosting/">Open Hosting Documentation</a>
</div>
<p id="load">Firebase SDK Loading&hellip;</p>
<script type="application/ld+json">
{
"name": "Harold",
"description": "Feature rich and simple cgpa calculator with downloadable course lists",
"@type": "WebSite",
"url": "http://harold.apps.orsteg.com",
"headline": "Harold - Timetable & (CGPA GPA) Calculator",
"@context": "http://schema.org"
}
</script>

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-125416356-2"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
// // 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥
// // The Firebase SDK is initialized and available here!
//
// firebase.auth().onAuthStateChanged(user => { });
// firebase.database().ref('/path/to/ref').on('value', snapshot => { });
// firebase.messaging().requestPermission().then(() => { });
// firebase.storage().ref('/path/to/ref').getDownloadURL().then(() => { });
//
// // 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥
window.dataLayer = window.dataLayer || [];

try {
let app = firebase.app();
let features = ['auth', 'database', 'messaging', 'storage'].filter(feature => typeof app[feature] === 'function');
document.getElementById('load').innerHTML = `Firebase SDK loaded with ${features.join(', ')}`;
} catch (e) {
console.error(e);
document.getElementById('load').innerHTML = 'Error loading the Firebase SDK, check the console.';
function gtag() {
dataLayer.push(arguments);
}
});
gtag('js', new Date());

gtag('config', 'UA-125416356-2');
</script>
</body>
</html>
</head>

<body>

</body>

</html>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions Firebase Hosting/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
User-agent: *
Disallow: /store

Sitemap: http://harold.apps.orsteg.com/sitemap.xml
11 changes: 11 additions & 0 deletions Firebase Hosting/public/sitemap.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://harold.apps.orsteg.com</loc>
<lastmod>2018-10-20</lastmod>
</url>
<url>
<loc>https://harold.apps.orsteg.com/store</loc>
<lastmod>2018-10-20</lastmod>
</url>
</urlset>
57 changes: 42 additions & 15 deletions Firebase Hosting/public/store/index.html
Original file line number Diff line number Diff line change
@@ -1,33 +1,60 @@
<!DOCTYPE html>
<html>
<head>


<head>

<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Harold - Timetable & (CGPA GPA) Calculator | Free download on play store</title>
<title>Harold - CGPA &amp; GPA Calculator | Free download on play store</title>

<meta property="og:title" content="Harold - Timetable &amp; (CGPA GPA) Calculator" />
<meta property="og:title" content="Harold - CGPA &amp; GPA Calculator | Free download on play store" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="Powerful cgpa calculator with a semester aware timetable" />
<meta property="og:description" content="Powerful cgpa calculator with a semester aware timetable" />
<meta name="description" content="Feature rich and simple cgpa calculator with downloadable course lists" />
<meta property="og:description" content="Feature rich and simple cgpa calculator with downloadable course lists" />
<link rel="canonical" href="http://harold.apps.orsteg.com/store" />
<meta property="og:url" content="http://harold.apps.orsteg.com/store" />
<meta property="og:site_name" content="Harold.apps.Orsteg.com" />
<meta name="keywords" content="Harold - Timetable &amp; (CGPA GPA) Calculator, Harold - Timetable &amp; (CGPA GPA) Calculator for android, Harold - Timetable &amp; (CGPA GPA) Calculator android download, Harold - Timetable &amp; (CGPA GPA) Calculator apk, Harold - Timetable &amp; (CGPA GPA) Calculator android apk, Harold - Timetable &amp; (CGPA GPA) Calculator download" />
<meta property="og:image" content="https://image.winudf.com/v2/image/Y29tLm9yc3RlZy5oYXJvbGRfc2NyZWVuXzBfMTUyNjY0MTMzNl8wNzY/screen-0.jpg?h=500&amp;fakeurl=1&amp;type=.jpg" />

<meta name="keywords" content="Harold - CGPA &amp; GPA Calculator, Harold - CGPA &amp; GPA Calculator for android, Harold - CGPA &amp; GPA Calculator android download, Harold - CGPA &amp; GPA Calculator apk, Harold - CGPA &amp; GPA Calculator android apk, Harold - CGPA &amp; GPA Calculator download, free download, play store"
/>
<meta property="og:image" content="https://harold.apps.orsteg.com/orsteg_apps_harold_og_image.png" />

<link rel="shortcut icon" href="/favicon.png" />

<script type="application/ld+json">
{"name":"Harold","description":"Timetable & (CGPA GPA) Calculator","@type":"WebSite","url":"http://harold.apps.orsteg.com/store","headline":"Harold - Timetable & (CGPA GPA) Calculator","@context":"http://schema.org"}
{
"name": "Harold",
"description": "Feature rich and simple cgpa calculator with downloadable course lists",
"@type": "WebSite",
"url": "http://harold.apps.orsteg.com/store",
"headline": "Harold - Timetable & (CGPA GPA) Calculator",
"@context": "http://schema.org"
}
</script>

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-125416356-2"></script>
<script>
window.dataLayer = window.dataLayer || [];

function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());

gtag('config', 'UA-125416356-2');
</script>

</head>
<body>

</head>

<body>

<script>
window.location.href = "https://ytu5t.app.goo.gl/home";
window.location.href = "https://ytu5t.app.goo.gl/home";
</script>

</body>
</html>
</body>

</html>

0 comments on commit 170b6fc

Please sign in to comment.