From e7d64e97a5267d285225986e6273a7a1b301d7b9 Mon Sep 17 00:00:00 2001 From: Fellyph Cintra Date: Mon, 29 Jan 2024 15:52:37 +0000 Subject: [PATCH 1/4] adding base markup for internal pages --- src/common/internal-page/footer.ejs | 2 ++ src/common/internal-page/header.ejs | 7 +++++++ 2 files changed, 9 insertions(+) create mode 100644 src/common/internal-page/footer.ejs create mode 100644 src/common/internal-page/header.ejs diff --git a/src/common/internal-page/footer.ejs b/src/common/internal-page/footer.ejs new file mode 100644 index 0000000..86995c4 --- /dev/null +++ b/src/common/internal-page/footer.ejs @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/src/common/internal-page/header.ejs b/src/common/internal-page/header.ejs new file mode 100644 index 0000000..fcdb62b --- /dev/null +++ b/src/common/internal-page/header.ejs @@ -0,0 +1,7 @@ +
+ <% if (title) { %> +
+

<%= title %>

+
+ <% } %> +
\ No newline at end of file From 7ea7ffe6fd45c362eceec2f738134251983e75bf Mon Sep 17 00:00:00 2001 From: Fellyph Cintra Date: Mon, 29 Jan 2024 15:53:05 +0000 Subject: [PATCH 2/4] reusing internal page markup --- public/assets/styles/style.css | 4 ---- src/demos/chips/analytics-first-party.ejs | 7 ++----- src/demos/chips/analytics-third-party.ejs | 7 ++----- src/demos/chips/index.ejs | 7 ++----- src/scenarios/analytics/index.ejs | 19 ++++++++----------- src/scenarios/ecommerce/index.ejs | 7 ++----- src/scenarios/ecommerce/routes.js | 4 +++- src/scenarios/embedded-video/index.ejs | 7 ++----- src/scenarios/payment-gateway/checkout.ejs | 7 ++----- src/scenarios/payment-gateway/routes.js | 2 +- src/scenarios/single-sign-on/login.ejs | 7 ++----- src/scenarios/single-sign-on/profile.ejs | 7 ++----- src/scenarios/single-sign-on/routes.js | 13 ++++--------- src/scenarios/single-sign-on/signin.ejs | 5 ++--- 14 files changed, 34 insertions(+), 69 deletions(-) diff --git a/public/assets/styles/style.css b/public/assets/styles/style.css index 8f51a5a..fe1b862 100644 --- a/public/assets/styles/style.css +++ b/public/assets/styles/style.css @@ -626,10 +626,6 @@ video { margin-bottom: 0.5rem; } -.mb-3 { - margin-bottom: 0.75rem; -} - .mb-4 { margin-bottom: 1rem; } diff --git a/src/demos/chips/analytics-first-party.ejs b/src/demos/chips/analytics-first-party.ejs index b666fed..1951ec2 100644 --- a/src/demos/chips/analytics-first-party.ejs +++ b/src/demos/chips/analytics-first-party.ejs @@ -1,8 +1,6 @@ <%- include(commonPath + '/header.ejs') %> -
-

<%= title %>

-
+ <%- include(commonPath + '/internal-page/header.ejs') %>

Track user interactions using the analytics code provided below:

-
-
+ <%- include(commonPath + '/internal-page/footer.ejs') %> diff --git a/src/demos/chips/analytics-third-party.ejs b/src/demos/chips/analytics-third-party.ejs index eca191a..39b9151 100644 --- a/src/demos/chips/analytics-third-party.ejs +++ b/src/demos/chips/analytics-third-party.ejs @@ -1,8 +1,6 @@ <%- include(commonPath + '/header.ejs') %> -
-

<%= title %>

-
+ <%- include(commonPath + '/internal-page/header.ejs') %>

Track user interactions using the analytics code provided below:

@@ -14,8 +12,7 @@
-
-
+ <%- include(commonPath + '/internal-page/footer.ejs') %> diff --git a/src/demos/chips/index.ejs b/src/demos/chips/index.ejs index fe48fcd..3bc0c14 100644 --- a/src/demos/chips/index.ejs +++ b/src/demos/chips/index.ejs @@ -1,8 +1,6 @@ <%- include(commonPath + '/header.ejs') %> -
-

CHIPS

-
+ <%- include(commonPath + '/internal-page/header.ejs') %>

Cookies Having Independent Partitioned State

-
-
+ <%- include(commonPath + '/internal-page/footer.ejs') %> <%- include(commonPath + '/footer.ejs') %> diff --git a/src/scenarios/analytics/index.ejs b/src/scenarios/analytics/index.ejs index 7fa3320..77b23e1 100644 --- a/src/scenarios/analytics/index.ejs +++ b/src/scenarios/analytics/index.ejs @@ -1,18 +1,15 @@ <%- include(commonPath + '/header.ejs') %> -
-

Analytics

-
-

Here is a button that tracks clicks using a third-party analytics service; check if it works.

+ <%- include(commonPath + '/internal-page/header.ejs') %> +

Here is a button that tracks clicks using a third-party analytics service; check if it works.

-
- -
-
+
+
-
+
+ <%- include(commonPath + '/internal-page/footer.ejs') %> diff --git a/src/scenarios/ecommerce/index.ejs b/src/scenarios/ecommerce/index.ejs index 03cfe3e..a88fb61 100644 --- a/src/scenarios/ecommerce/index.ejs +++ b/src/scenarios/ecommerce/index.ejs @@ -1,13 +1,10 @@ <%- include(commonPath + '/header.ejs') %> -
-

E-Commerce

-
+ <%- include(commonPath + '/internal-page/header.ejs') %>

Here is an embedded Third-Party e-commerce site, check if you can add products to cart.

-
-
+ <%- include(commonPath + '/internal-page/footer.ejs') %> <%- include(commonPath + '/footer.ejs') %> diff --git a/src/scenarios/ecommerce/routes.js b/src/scenarios/ecommerce/routes.js index c7c68c5..4eb9524 100644 --- a/src/scenarios/ecommerce/routes.js +++ b/src/scenarios/ecommerce/routes.js @@ -13,7 +13,9 @@ router.use((req, res, next) => { // Route to serve the home page router.get('/', (req, res) => { // Render the index view (homepage) - res.render(path.join(__dirname,'index')); + res.render(path.join(__dirname,'index'), { + title: 'E-commerce' + }); }); // Route to serve the products page diff --git a/src/scenarios/embedded-video/index.ejs b/src/scenarios/embedded-video/index.ejs index bf4cb88..2b6deb1 100644 --- a/src/scenarios/embedded-video/index.ejs +++ b/src/scenarios/embedded-video/index.ejs @@ -1,8 +1,6 @@ <%- include(commonPath + '/header.ejs') %> -
-

Embedded Video

-
+ <%- include(commonPath + '/internal-page/footer.ejs') %> <%- include(commonPath + '/footer.ejs') %> \ No newline at end of file diff --git a/src/scenarios/payment-gateway/checkout.ejs b/src/scenarios/payment-gateway/checkout.ejs index 67beeec..33efff4 100644 --- a/src/scenarios/payment-gateway/checkout.ejs +++ b/src/scenarios/payment-gateway/checkout.ejs @@ -1,13 +1,10 @@ <%- include(commonPath + '/header.ejs') %> -
-

Checkout

-
+ <%- include(commonPath + '/internal-page/header.ejs') %>

Item: <%= item %> - $<%= price %>

-
-
+ <%- include(commonPath + '/internal-page/footer.ejs') %> <%- include(commonPath + '/footer.ejs') %> diff --git a/src/scenarios/payment-gateway/routes.js b/src/scenarios/payment-gateway/routes.js index 4cbd73e..ceed45b 100644 --- a/src/scenarios/payment-gateway/routes.js +++ b/src/scenarios/payment-gateway/routes.js @@ -5,7 +5,7 @@ const router = express.Router(); router.get( '/', ( req, res ) => { res.render( path.join( __dirname, 'checkout' ), { - title: 'Payment Gateway', + title: 'Checkout', item: "Virtual Badge for testing the site", price: 10, } ); diff --git a/src/scenarios/single-sign-on/login.ejs b/src/scenarios/single-sign-on/login.ejs index e1dc943..6c0423a 100644 --- a/src/scenarios/single-sign-on/login.ejs +++ b/src/scenarios/single-sign-on/login.ejs @@ -1,8 +1,6 @@ <%- include(commonPath + '/header.ejs') %> -
-

Login

-
+ <%- include(commonPath + '/internal-page/header.ejs') %>
@@ -14,7 +12,6 @@
-
-
+ <%- include(commonPath + '/internal-page/footer.ejs') %> <%- include(commonPath + '/footer.ejs') %> diff --git a/src/scenarios/single-sign-on/profile.ejs b/src/scenarios/single-sign-on/profile.ejs index c101154..4921c9f 100644 --- a/src/scenarios/single-sign-on/profile.ejs +++ b/src/scenarios/single-sign-on/profile.ejs @@ -1,13 +1,10 @@ <%- include(commonPath + '/header.ejs') %> -
-
-

Welcome

+ <%- include(commonPath + '/internal-page/header.ejs') %>

You are logged in as <%= email %>

-
-
+ <%- include(commonPath + '/internal-page/footer.ejs') %> <%- include(commonPath + '/footer.ejs') %> diff --git a/src/scenarios/single-sign-on/routes.js b/src/scenarios/single-sign-on/routes.js index 2ef986c..77ac535 100644 --- a/src/scenarios/single-sign-on/routes.js +++ b/src/scenarios/single-sign-on/routes.js @@ -4,14 +4,9 @@ const router = express.Router(); router.get('/', (req, res) => { const email = req.cookies.localemail; - - if (email) { - // User is 'logged in', redirect to profile page - res.redirect('/single-sign-on/profile'); - } else { - // User is not logged in, redirect to sign-in page - res.redirect('/single-sign-on/sign-in'); - } + // User is 'logged in', redirect to profile page or sign-in page + const redirectURL = (email) ? '/single-sign-on/profile' : '/single-sign-on/sign-in'; + res.redirect(redirectURL); }); router.get('/profile', (req, res) => { @@ -20,7 +15,7 @@ router.get('/profile', (req, res) => { const domain = req.get('host'); if (email) { - res.render(path.join(__dirname, 'profile'), { title: 'Single Sign-On for ' + domain, email: email }); + res.render(path.join(__dirname, 'profile'), { title: 'Welcome ' + email, email: email }); } else { res.redirect('/single-sign-on/sign-in'); } diff --git a/src/scenarios/single-sign-on/signin.ejs b/src/scenarios/single-sign-on/signin.ejs index 03ef411..7fb40de 100644 --- a/src/scenarios/single-sign-on/signin.ejs +++ b/src/scenarios/single-sign-on/signin.ejs @@ -1,10 +1,9 @@ <%- include(commonPath + '/header.ejs') %>
-

Single Sign-On

-
+ <%- include(commonPath + '/internal-page/header.ejs') %> -
+ <%- include(commonPath + '/internal-page/footer.ejs') %>
diff --git a/src/common/header.ejs b/src/common/header.ejs index bd8454b..4c8c30f 100644 --- a/src/common/header.ejs +++ b/src/common/header.ejs @@ -9,16 +9,7 @@ - +