Skip to content

Commit 56946cd

Browse files
author
Nicolas Garnier
committed
Switched samples with a web component to use implicit Web init
Change-Id: I841ef7dc4b86292ecdbe3ebd9295eade84d15058
1 parent cd436c5 commit 56946cd

File tree

20 files changed

+97
-158
lines changed

20 files changed

+97
-158
lines changed

authorized-https-endpoint/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ This sample comes with a simple web-based UI which code is in [public](public) d
1616
1. Create a Firebase Project using the [Firebase Console](https://console.firebase.google.com).
1717
1. Enable the **Google** Provider in the **Auth** section.
1818
1. Clone or download this repo and open the `authenticated-https-endpoint` directory.
19-
1. Paste the Web initialization snippet from: **Firebase Console > Overview > Add Firebase to your web app** in the `public/index.html` where the `TODO` is located.
2019
1. You must have the Firebase CLI installed. If you don't have it install it with `npm install -g firebase-tools` and then configure it with `firebase login`.
2120
1. Configure the CLI locally by using `firebase use --add` and select your project in the list.
2221
1. Install dependencies locally by running: `cd functions; npm install; cd -`

authorized-https-endpoint/public/index.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ <h3>Authorized HTTP Function demo</h3>
6868
</div>
6969

7070
<!-- Firebase -->
71-
<!-- ***********************************************************************************************************************
72-
* TODO(DEVELOPER): Paste the initialization snippet from: Firebase Console > Overview > Add Firebase to your web app. *
73-
*********************************************************************************************************************** -->
71+
<script src="/__/firebase/3.7.4/firebase-app.js"></script>
72+
<script src="/__/firebase/3.7.4/firebase-auth.js"></script>
73+
<script src="/__/firebase/init.js"></script>
7474

7575
<script src="main.js"></script>
7676
</body>

authorized-https-endpoint/public/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function Demo() {
2323
this.signOutButton = document.getElementById('demo-sign-out-button');
2424
this.responseContainer = document.getElementById('demo-response');
2525
this.urlContainer = document.getElementById('demo-url');
26-
this.helloFunctionUrl = 'https://us-central1-' + config.authDomain.split('.')[0] + '.cloudfunctions.net/authorizedHello/';
26+
this.helloFunctionUrl = 'https://us-central1-' + firebase.app().options.authDomain.split('.')[0] + '.cloudfunctions.net/authorizedHello/';
2727
this.signedOutCard = document.getElementById('demo-signed-out-card');
2828
this.signedInCard = document.getElementById('demo-signed-in-card');
2929

email-confirmation/README.md

+13-14
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,21 @@ The function triggers on changes to `/users/$uid` and exits if there are no chan
3434

3535
## Setting up the sample
3636

37-
Set the `gmail.email` and `gmail.password` Google Cloud environment variables to match the email and password of the Gmail account used to send emails. For this use:
38-
39-
```bash
40-
firebase functions:config:set gmail.email="[email protected]" gmail.password="secretpassword"
41-
```
42-
43-
This sample comes with a web-based UI for testing the function. To set it up:
44-
45-
- Create a Firebase Project using the [Firebase Developer Console](https://console.firebase.google.com)
46-
- Enable Google Provider in the [Auth section](https://console.firebase.google.com/project/_/authentication/providers)
47-
- Import and configure Firebase in the `public/index.html` where the `TODO` is located
48-
37+
1. Create a Firebase Project using the [Firebase Console](https://console.firebase.google.com).
38+
1. Enable the **Google** Provider in the **Auth** section.
39+
1. Clone or download this repo and open the `email-confirmation` directory.
40+
1. You must have the Firebase CLI installed. If you don't have it install it with `npm install -g firebase-tools` and then configure it with `firebase login`.
41+
1. Configure the CLI locally by using `firebase use --add` and select your project in the list.
42+
1. Install dependencies locally by running: `cd functions; npm install; cd -`
43+
1. Set the `gmail.email` and `gmail.password` Google Cloud environment variables to match the email and password of the Gmail account used to send emails. For this use:
44+
```bash
45+
firebase functions:config:set gmail.email="[email protected]" gmail.password="secretpassword"
46+
```
4947

5048
## Deploy and test
5149

5250
This sample comes with a web-based UI for testing the function. To test it out:
5351

54-
- Deploy your project using `firebase deploy`
55-
- Open the app using `firebase open`, Sign in using Google Sign-In and subscribe/unsubscribe to the newsletter and you should receive email confirmations
52+
1. Deploy your project using `firebase deploy`
53+
1. Open the app using `firebase open hosting:site`, this will open a browser.
54+
1. Sign in the web app in the browser using Google Sign-In and delete your account using the button on the web app. You should receive email confirmations for each actions.

email-confirmation/main.css

-62
This file was deleted.

email-confirmation/public/index.html

+4-3
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,10 @@ <h3>Very interesting website with Newsletter</h3>
9797
</div>
9898

9999
<!-- Firebase -->
100-
<!-- ***********************************************************************************************************************
101-
* TODO(DEVELOPER): Paste the initialization snippet from: Firebase Console > Overview > Add Firebase to your web app. *
102-
*********************************************************************************************************************** -->
100+
<script src="/__/firebase/3.7.4/firebase-app.js"></script>
101+
<script src="/__/firebase/3.7.4/firebase-auth.js"></script>
102+
<script src="/__/firebase/3.7.4/firebase-database.js"></script>
103+
<script src="/__/firebase/init.js"></script>
103104

104105
<script src="main.js"></script>
105106
</body>

exif-images/README.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,19 @@ For example the metadata for the file at path `/1477402116302/mypic.jpg` will be
2828

2929
This sample comes with a Function and web-based UI for testing the function. To configure it:
3030

31-
- Create a Firebase project on the [Firebase Console](https://console.firebase.google.com)
32-
- Enable Anonymous sign in the Auth section
33-
- Import and configure Firebase in the `index.html` where the `TODO` is located
31+
1. Create a Firebase Project using the [Firebase Console](https://console.firebase.google.com).
32+
1. Enable the **Anonymous** sign-in in the **Auth** section.
33+
1. Clone or download this repo and open the `exif-image` directory.
34+
1. You must have the Firebase CLI installed. If you don't have it install it with `npm install -g firebase-tools` and then configure it with `firebase login`.
35+
1. Configure the CLI locally by using `firebase use --add` and select your project in the list.
36+
1. Install dependencies locally by running: `cd functions; npm install; cd -`
3437

3538

3639
## Deploy and test
3740

3841
To test the sample:
3942

40-
- Deploy your project using `firebase deploy`
41-
- Open the Deploy Web UI using `firebase open`, typically at the URL `https://<projectID>.firebaseapp.com`
42-
- Upload an image using the Web UI.
43-
- You should see the metadata displayed below after a bit.
43+
1. Deploy your project using `firebase deploy`
44+
1. Open the app using `firebase open hosting:site`, this will open a browser.
45+
1. Upload an image using the Web UI.
46+
1. You should see the metadata displayed below after a bit.

exif-images/public/index.html

+8-13
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,6 @@
2626
<script defer src="https://code.getmdl.io/1.1.3/material.min.js"></script>
2727

2828
<link rel="stylesheet" href="main.css">
29-
30-
<!-- Firebase -->
31-
<!-- *******************************************************************************
32-
* TODO(DEVELOPER): Paste the initialization snippet by navigating to:
33-
34-
https://console.firebase.google.com
35-
36-
and choosing a project you've created. Then click the red HTML logo at the top
37-
right of the page with the caption "Add Firebase to your web app".
38-
39-
Copy the snippet that appears in place of this comment.
40-
*************************************************************************** -->
41-
4229
</head>
4330
<body>
4431
<div class="demo-layout mdl-layout mdl-js-layout mdl-layout--fixed-header">
@@ -73,6 +60,14 @@ <h6>Image Metadata:</h6>
7360
</div>
7461
</main>
7562
</div>
63+
64+
<!-- Firebase -->
65+
<script src="/__/firebase/3.7.4/firebase-app.js"></script>
66+
<script src="/__/firebase/3.7.4/firebase-auth.js"></script>
67+
<script src="/__/firebase/3.7.4/firebase-storage.js"></script>
68+
<script src="/__/firebase/3.7.4/firebase-database.js"></script>
69+
<script src="/__/firebase/init.js"></script>
70+
7671
<script src="main.js"></script>
7772
</body>
7873
</html>

fcm-notifications/README.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,12 @@ The function triggers every time the value of a follow flag changes at `/followe
5353

5454
This sample comes with a web-based UI for testing the function. To test it out:
5555

56-
- Create a Firebase Project using the [Firebase Developer Console](https://console.firebase.google.com)
57-
- Enable **Google Provider** in the [Auth section](https://console.firebase.google.com/project/_/authentication/providers)
58-
- Import and configure Firebase in `public/index.html` where the `TODO` is located
59-
- Install the required dependencies by running `npm install` in the `functions` directory
60-
- Deploy your project using `firebase deploy`
61-
- Open the app and start following a user, this will send a notification to him.
56+
1. Create a Firebase Project using the [Firebase Console](https://console.firebase.google.com).
57+
1. Enable **Google Provider** in the [Auth section](https://console.firebase.google.com/project/_/authentication/providers)
58+
1. Clone or download this repo and open the `fcm-notification` directory.
59+
1. You must have the Firebase CLI installed. If you don't have it install it with `npm install -g firebase-tools` and then configure it with `firebase login`.
60+
1. Configure the CLI locally by using `firebase use --add` and select your project in the list.
61+
1. Install dependencies locally by running: `cd functions; npm install; cd -`
62+
1. Deploy your project using `firebase deploy`
63+
1. Open the app using `firebase open hosting:site`, this will open a browser.
64+
1. Start following a user, this will send a notification to him.

fcm-notifications/public/index.html

+5-3
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,11 @@ <h3>Send FCM notifications demo</h3>
8383
</div>
8484

8585
<!-- Firebase -->
86-
<!-- ***********************************************************************************************************************
87-
* TODO(DEVELOPER): Paste the initialization snippet from: Firebase Console > Overview > Add Firebase to your web app. *
88-
*********************************************************************************************************************** -->
86+
<script src="/__/firebase/3.7.4/firebase-app.js"></script>
87+
<script src="/__/firebase/3.7.4/firebase-auth.js"></script>
88+
<script src="/__/firebase/3.7.4/firebase-messaging.js"></script>
89+
<script src="/__/firebase/3.7.4/firebase-database.js"></script>
90+
<script src="/__/firebase/init.js"></script>
8991

9092
<script src="main.js"></script>
9193
</body>

instagram-auth/README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ This sample shows how to authenticate using Instagram Sign-In on Firebase. In th
88
Create and setup the Firebase project:
99
1. Create a Firebase project using the [Firebase Developer Console](https://console.firebase.google.com).
1010
1. Enable Billing on your Firebase the project by switching to the **Blaze** plan, this is currently needed to be able to perform HTTP requests to external services from a Cloud Function.
11-
1. Copy the Web initialisation snippet from **Firebase Console > Overview > Add Firebase to your web app** and paste it in `public/index.html` and `public/popup.html` in lieu of the placeholders (where the `TODO(DEVELOPER)` are located).
1211

1312
Create and provide a Service Account's credentials:
1413
1. Create a Service Accounts file as described in the [Server SDK setup instructions](https://firebase.google.com/docs/server/setup#add_firebase_to_your_app).
@@ -19,9 +18,9 @@ Create and setup your Instagram app:
1918
1. Once Your app is created make sure you specify your app's callback URL in the list of **Valid redirect URIs** of your Instagram app. You should whitelist `https://localhost:5000/popup.html` for local development and if you deploy on App Engine (See Deploy section below) you should whitelist the URL `https://<application-id>.firebaseapp.com/popup.html`.
2019
1. Copy the **Client ID** and **Client Secret** of your Instagram app and use them to set the `instagram.client_id` and `instagram.client_secret` Google Cloud environment variables. For this use:
2120

22-
```bash
23-
firebase functions:config:set instagram.client_id="yourClientID" instagram.client_secret="yourClientSecret"
24-
```
21+
```bash
22+
firebase functions:config:set instagram.client_id="yourClientID" instagram.client_secret="yourClientSecret"
23+
```
2524

2625
> Make sure the Instagram Client Secret is always kept secret. For instance do not save it in your version control system.
2726

instagram-auth/public/index.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ <h3>Sign in with Instagram demo</h3>
6868
</div>
6969

7070
<!-- Firebase -->
71-
<!-- ***********************************************************************************************************************
72-
* TODO(DEVELOPER): Paste the initialization snippet from: Firebase Console > Overview > Add Firebase to your web app. *
73-
*********************************************************************************************************************** -->
71+
<script src="/__/firebase/3.7.4/firebase-app.js"></script>
72+
<script src="/__/firebase/3.7.4/firebase-auth.js"></script>
73+
<script src="/__/firebase/init.js"></script>
7474

7575
<script src="main.js"></script>
7676
</body>

instagram-auth/public/popup.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
Please wait...
2525

2626
<!-- Firebase -->
27-
<!-- ***********************************************************************************************************************
28-
* TODO(DEVELOPER): Paste the initialization snippet from: Firebase Console > Overview > Add Firebase to your web app. *
29-
*********************************************************************************************************************** -->
27+
<script src="/__/firebase/3.7.4/firebase-app.js"></script>
28+
<script src="/__/firebase/3.7.4/firebase-auth.js"></script>
29+
<script src="/__/firebase/init.js"></script>
3030

3131
<script>
3232
/**

linkedin-auth/README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ This sample shows how to authenticate using LinkedIn Sign-In on Firebase. In thi
88
Create and setup the Firebase project:
99
1. Create a Firebase project using the [Firebase Developer Console](https://console.firebase.google.com).
1010
1. Enable Billing on your Firebase the project by switching to the **Blaze** plan, this is currently needed to be able to perform HTTP requests to external services from a Cloud Function.
11-
1. Copy the Web initialisation snippet from **Firebase Console > Overview > Add Firebase to your web app** and paste it in `public/index.html` and `public/popup.html` in lieu of the placeholders (where the `TODO(DEVELOPER)` are located).
1211

1312
Create and provide a Service Account's credentials:
1413
1. Create a Service Accounts file as described in the [Server SDK setup instructions](https://firebase.google.com/docs/server/setup#add_firebase_to_your_app).
@@ -20,9 +19,9 @@ Create and setup your LinkedIn app:
2019
**OAuth 2.0** > **Authorized Redirect URLs** of your LinkedIn app.
2120
1. Copy the **Client ID** and **Client Secret** of your LinkedIn app and use them to set the `linkedin.client_id` and `linkedin.client_secret` Google Cloud environment variables. For this use:
2221

23-
```bash
24-
firebase functions:config:set linkedin.client_id="yourClientID" linkedin.client_secret="yourClientSecret"
25-
```
22+
```bash
23+
firebase functions:config:set linkedin.client_id="yourClientID" linkedin.client_secret="yourClientSecret"
24+
```
2625

2726
> Make sure the LinkedIn Client Secret is always kept secret. For instance do not save this in your version control system.
2827

linkedin-auth/public/index.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ <h3>Sign in with LinkedIn demo</h3>
6969
</div>
7070

7171
<!-- Firebase -->
72-
<!-- ***********************************************************************************************************************
73-
* TODO(DEVELOPER): Paste the initialization snippet from: Firebase Console > Overview > Add Firebase to your web app. *
74-
*********************************************************************************************************************** -->
72+
<script src="/__/firebase/3.7.4/firebase-app.js"></script>
73+
<script src="/__/firebase/3.7.4/firebase-auth.js"></script>
74+
<script src="/__/firebase/init.js"></script>
7575

7676
<script src="main.js"></script>
7777
</body>

linkedin-auth/public/popup.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
Please wait...
2525

2626
<!-- Firebase -->
27-
<!-- ***********************************************************************************************************************
28-
* TODO(DEVELOPER): Paste the initialization snippet from: Firebase Console > Overview > Add Firebase to your web app. *
29-
*********************************************************************************************************************** -->
27+
<script src="/__/firebase/3.7.4/firebase-app.js"></script>
28+
<script src="/__/firebase/3.7.4/firebase-auth.js"></script>
29+
<script src="/__/firebase/init.js"></script>
3030

3131
<script>
3232
/**

text-moderation/README.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,13 @@ The security rules only allow users to create message but not edit them afterwar
5555

5656
## Deploy and test
5757

58-
This sample comes with a web-based UI for testing the function. To test it out:
59-
60-
- Create a Firebase Project using the [Firebase Developer Console](https://console.firebase.google.com)
61-
- Import and configure Firebase in `public/index.html` where the `TODO` is located
62-
- Install the required dependencies by running `npm install` in the `functions` directory
63-
- Deploy your project using `firebase deploy`
64-
- Open the app and add messages to the message board. Try to ad bad words into your message and they should get moderated.
58+
This sample comes with a Function and web-based UI for testing the function. To configure it:
59+
60+
1. Create a Firebase Project using the [Firebase Console](https://console.firebase.google.com).
61+
1. Clone or download this repo and open the `text-moderation` directory.
62+
1. You must have the Firebase CLI installed. If you don't have it install it with `npm install -g firebase-tools` and then configure it with `firebase login`.
63+
1. Configure the CLI locally by using `firebase use --add` and select your project in the list.
64+
1. Install dependencies locally by running: `cd functions; npm install; cd -`
65+
1. Deploy your project using `firebase deploy`
66+
1. Open the app using `firebase open hosting:site`, this will open a browser.
67+
1. Open the app and add messages to the message board. Try to ad bad words into your message and they should get moderated.

text-moderation/public/index.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ <h2 class="mdl-card__title-text">Last Guestbook's messages</h2>
9191
</div>
9292

9393
<!-- Firebase -->
94-
<!-- ***********************************************************************************************************************
95-
* TODO(DEVELOPER): Paste the initialization snippet from: Firebase Console > Overview > Add Firebase to your web app. *
96-
*********************************************************************************************************************** -->
94+
<script src="/__/firebase/3.7.4/firebase-app.js"></script>
95+
<script src="/__/firebase/3.7.4/firebase-database.js"></script>
96+
<script src="/__/firebase/init.js"></script>
9797

9898
<script src="main.js"></script>
9999
</body>

0 commit comments

Comments
 (0)