Skip to content

Commit

Permalink
Merge pull request #1018 from DemocracyLab/495-render-all-page-header…
Browse files Browse the repository at this point in the history
…s-on-backend-remove-react-helmet-component

solve #495 render all page headers on backend remove react helmet component
  • Loading branch information
marlonkeating authored Nov 2, 2023
2 parents 5c0d7d3 + ecb25ed commit 53978c5
Show file tree
Hide file tree
Showing 18 changed files with 75 additions and 168 deletions.
61 changes: 56 additions & 5 deletions civictechprojects/helpers/context_preload.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def about_project_preload(context, request):
print('Failed to preload project info, no cache entry found: ' + project_id)
return context


def about_event_preload(context, request):
context = default_preload(context, request)
query_args = url_params(request)
Expand Down Expand Up @@ -79,14 +78,14 @@ def about_group_preload(context, request):

def companies_preload(context, request):
context = default_preload(context, request)
context['title'] = 'DemocracyLab | Corporate Engagement'
context['title'] = 'Corporate Engagement | DemocracyLab'
context['description'] = 'Do well by doing good! Engage employees at custom events to build culture and spark innovation. Differentiate your brand by sponsoring our public hackathons.'
return context


def about_us_preload(context, request):
context = default_preload(context, request)
context['title'] = 'DemocracyLab | About'
context['title'] = 'About | DemocracyLab'
context['description'] = 'Learn About democracyLab, the nonprofit connecting skilled individuals to tech-for-good projects.'
return context

Expand All @@ -111,20 +110,47 @@ def create_event_preload(context, request):
context['description'] = 'Create event page'
return context

def create_group_preload(context, request):
context = default_preload(context, request)
context['title'] = 'Create a Group | DemocracyLab'
context['description'] = 'Create group page'
return context

def create_project_preload(context, request):
context = default_preload(context, request)
context['title'] = 'Create a Project | DemocracyLab'
context['description'] = 'Create project page'
return context

def my_projects_preload(context, request):
context = default_preload(context, request)
context['title'] = 'My Projects | DemocracyLab'
context['description'] = 'My Projects page'
return context


def my_groups_preload(context, request):
context = default_preload(context, request)
context['title'] = 'My Groups | DemocracyLab'
context['description'] = 'My Groups page'
return context

def find_events_preload(context, request):
context = default_preload(context, request)
context['title'] = 'Find Events | DemocracyLab'
context['description'] = 'Optimizing the connection between skilled volunteers and tech-for-good events'
return context

def find_groups_preload(context, request):
context = default_preload(context, request)
context['title'] = 'Find Groups | DemocracyLab'
context['description'] = 'Optimizing the connection between skilled volunteers and tech-for-good groups'
return context

def find_projects_preload(context, request):
context = default_preload(context, request)
context['title'] = 'Find Projects | DemocracyLab'
context['description'] = 'Optimizing the connection between skilled volunteers and tech-for-good projects'
return context

def my_events_preload(context, request):
context = default_preload(context, request)
Expand All @@ -144,6 +170,23 @@ def terms_preload(context, request):
context['description'] = 'Terms of Use page'
return context

def sign_up_preload(context, request):
context = default_preload(context, request)
context['title'] = 'Sign Up | DemocracyLab'
context['description'] = 'Sign up'
return context

def contact_us_preload(context, request):
context = default_preload(context, request)
context['title'] = 'Contact Us | DemocracyLab'
context['description'] = 'Contact information for DemocracyLab.'
return context

def reset_password_preload(context, request):
context = default_preload(context, request)
context['title'] = 'Reset Password | DemocracyLab'
context['description'] = 'Reset password page'
return context

def videos_preload(context, request):
context = default_preload(context, request)
Expand Down Expand Up @@ -182,6 +225,8 @@ def default_preload(context, request):
{'section': FrontEndSection.EditProfile.value, 'handler': edit_profile_preload},
{'section': FrontEndSection.AboutUs.value, 'handler': about_us_preload},
{'section': FrontEndSection.CreateEvent.value, 'handler': create_event_preload},
{'section': FrontEndSection.CreateGroup.value,'handler':create_group_preload},
{'section': FrontEndSection.CreateProject.value,'handler':create_project_preload},
{'section': FrontEndSection.MyProjects.value, 'handler': my_projects_preload},
{'section': FrontEndSection.MyGroups.value, 'handler': my_groups_preload},
{'section': FrontEndSection.MyEvents.value, 'handler': my_events_preload},
Expand All @@ -191,7 +236,13 @@ def default_preload(context, request):
{'section': FrontEndSection.VideoOverview.value, 'handler': videos_preload},
{'section': FrontEndSection.AboutEventProject.value, 'handler': about_event_project_preload},
{'section': FrontEndSection.Privacy.value, 'handler': privacy_preload},
{'section': FrontEndSection.Terms.value, 'handler': terms_preload}
{'section': FrontEndSection.Terms.value, 'handler': terms_preload},
{'section': FrontEndSection.SignUp.value, 'handler': sign_up_preload},
{'section': FrontEndSection.ContactUs.value,'handler':contact_us_preload},
{'section': FrontEndSection.ResetPassword.value,'handler':reset_password_preload},
{'section': FrontEndSection.FindEvents.value,'handler':find_events_preload},
{'section': FrontEndSection.FindGroups.value,'handler':find_groups_preload},
{'section': FrontEndSection.FindProjects.value,'handler':find_projects_preload},
]


Expand Down
31 changes: 0 additions & 31 deletions common/components/common/Headers.jsx

This file was deleted.

19 changes: 0 additions & 19 deletions common/components/common/projects/AboutProjectDisplay.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import VolunteerSection from "../volunteers/VolunteerSection.jsx";
import IconLinkDisplay from "../../componentsBySection/AboutProject/IconLinkDisplay.jsx";
import type { PositionInfo } from "../../forms/PositionInfo.jsx";
import CurrentUser, { MyGroupData } from "../../utils/CurrentUser.js";
import Headers from "../Headers.jsx";
import Truncate from "../../utils/truncate.js";
import Sort from "../../utils/sort.js";
import { LinkTypes } from "../../constants/LinkConstants.js";
Expand Down Expand Up @@ -113,7 +112,6 @@ class AboutProjectDisplay extends React.PureComponent<Props, State> {
return (
<div className={"container Profile-root" + widthModifier }>
{isWithinIframe() && <base target="_blank" />}
{this._renderHeader(project)}
<div className="row">
<div className="Profile-top-section col-12">
{this._renderTopSection(project)}
Expand Down Expand Up @@ -366,23 +364,6 @@ class AboutProjectDisplay extends React.PureComponent<Props, State> {
);
}

_renderHeader(project: ProjectDetailsAPIData): React$Node {
const title: string = project.project_name + " | DemocracyLab";
const description: string =
project.project_short_description ||
Truncate.stringT(project.project_description, 300);

return (
<Headers
title={title}
description={description}
thumbnailUrl={
project.project_thumbnail && project.project_thumbnail.publicUrl
}
/>
);
}

_renderContactAndVolunteerButtons(): React$Node {
return (
<div className="Profile-owner">
Expand Down
16 changes: 0 additions & 16 deletions common/components/controllers/AboutEventController.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// @flow

import React from "react";
import Helmet from "react-helmet";
import ProjectAPIUtils from "../utils/ProjectAPIUtils.js";
import type { ProjectDetailsAPIData } from "../utils/ProjectAPIUtils.js";
import metrics from "../utils/metrics.js";
import Headers from "../common/Headers.jsx";
import Truncate from "../utils/truncate.js";
import AboutProjectDisplay from "../common/projects/AboutProjectDisplay.jsx";
import { APIError } from "../utils/api.js";
Expand Down Expand Up @@ -59,25 +57,11 @@ class AboutEventController extends React.PureComponent<{||}, State> {
_renderDetails(): React$Node {
return (
<React.Fragment>
{this._renderEventHeader(this.state.event)}
<AboutEventDisplay event={this.state.event} viewOnly={false} />
</React.Fragment>
);
}

_renderEventHeader(event: EventData): React$Node {
const title: string = event.event_name + " | DemocracyLab";
const description: string = event.event_short_description;

return (
<Headers
title={title}
description={description}
thumbnailUrl={event.event_thumbnail && event.event_thumbnail.publicUrl}
/>
);
}

_renderLoadMessage(): React$Node {
return (
<React.Fragment>
Expand Down
2 changes: 0 additions & 2 deletions common/components/controllers/AboutProjectController.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
// @flow

import React from "react";
import Helmet from "react-helmet";
import ProjectAPIUtils from "../utils/ProjectAPIUtils.js";
import type { ProjectDetailsAPIData } from "../utils/ProjectAPIUtils.js";
import metrics from "../utils/metrics.js";
import Headers from "../common/Headers.jsx";
import Truncate from "../utils/truncate.js";
import AboutProjectDisplay from "../common/projects/AboutProjectDisplay.jsx";
import { APIError } from "../utils/api.js";
Expand Down
9 changes: 0 additions & 9 deletions common/components/controllers/ContactUsController.jsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
// @flow

import React from "react";
import Headers from "../common/Headers.jsx";
import ContactForm from "../forms/ContactForm.jsx";

class ContactUsController extends React.PureComponent<{||}> {

_renderHeader(): React$Node {
const title: string = "DemocracyLab | Contact Us";
const description: string = "Contact information for DemocracyLab.";

return <Headers title={title} description={description} />;
}

render(): $React$Node {
return (
<React.Fragment>
{this._renderHeader()}
<div className="container contact-us-root">
<div className="row justify-content-center">
<div className="col-12 col-lg-10 col-xxl-9">
Expand Down
6 changes: 0 additions & 6 deletions common/components/controllers/CreateGroupController.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import React from "react";
import CurrentUser from "../../components/utils/CurrentUser.js";
import Section from "../enums/Section.js";
import Headers from "../common/Headers.jsx";
import LogInController from "./LogInController.jsx";
import VerifyEmailBlurb from "../common/notification/VerifyEmailBlurb.jsx";
import GroupOverviewForm from "../componentsBySection/CreateGroup/GroupOverviewForm.jsx";
Expand Down Expand Up @@ -138,11 +137,6 @@ class CreateGroupController extends React.PureComponent<{||}, State> {
render(): React$Node {
return (
<React.Fragment>
<Headers
title="Create an group | DemocracyLab"
description="Create group page"
/>

<div className="form-body">
{!CurrentUser.isLoggedIn() ? (
<LogInController prevPage={Section.CreateGroup} />
Expand Down
5 changes: 0 additions & 5 deletions common/components/controllers/CreateProjectController.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import CurrentUser from "../../components/utils/CurrentUser.js";
import metrics from "../utils/metrics.js";
import LogInController from "./LogInController.jsx";
import Section from "../enums/Section.js";
import Headers from "../common/Headers.jsx";
import ProjectOverviewForm from "../componentsBySection/CreateProject/ProjectOverviewForm.jsx";
import ProjectInfoForm from "../componentsBySection/CreateProject/ProjectInfoForm.jsx";
import ProjectPreviewForm from "../componentsBySection/CreateProject/ProjectPreviewForm.jsx";
Expand Down Expand Up @@ -198,10 +197,6 @@ class CreateProjectController extends React.PureComponent<{||}, State> {
render(): React$Node {
return (
<React.Fragment>
<Headers
title="Create a Project | DemocracyLab"
description="Create project page"
/>
<div className="form-body">
{!CurrentUser.isLoggedIn() ? (
<LogInController prevPage={Section.CreateProject} />
Expand Down
5 changes: 0 additions & 5 deletions common/components/controllers/FindEventsController.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// @flow

import Headers from "../common/Headers.jsx";
import EventCardsContainer from "../componentsBySection/FindEvents/EventCardsContainer.jsx";
import React from "react";
import urls from "../utils/url.js";
Expand Down Expand Up @@ -30,10 +29,6 @@ class FindEventsController extends React.PureComponent {
render(): React$Node {
return (
<React.Fragment>
<Headers
title="DemocracyLab"
description="Optimizing the connection between skilled volunteers and tech-for-good events"
/>
<div className="FindEventsController-root">
<div className="container">
<div className="row justify-content-center">
Expand Down
5 changes: 0 additions & 5 deletions common/components/controllers/FindGroupsController.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import UniversalDispatcher from "../stores/UniversalDispatcher.js";
import { SearchFor } from "../stores/EntitySearchStore.js";
import GroupCardsContainer from "../componentsBySection/FindGroups/GroupCardsContainer.jsx";
import GroupFilterContainer from "../componentsBySection/FindGroups/FIlters/GroupFilterContainer.jsx";
import Headers from "../common/Headers.jsx";
import urls from "../utils/url.js";
import React from "react";
import _ from "lodash";
Expand Down Expand Up @@ -47,10 +46,6 @@ class FindGroupsController extends React.PureComponent {
render(): React$Node {
return (
<React.Fragment>
<Headers
title="DemocracyLab"
description="Optimizing the connection between skilled volunteers and tech-for-good groups"
/>
<div className="FindProjectsController-root container">
<div className="row">
<GroupFilterContainer />
Expand Down
5 changes: 0 additions & 5 deletions common/components/controllers/FindProjectsController.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import ProjectCardsContainer from "../componentsBySection/FindProjects/ProjectCa
import ProjectFilterContainer from "../componentsBySection/FindProjects/Filters/ProjectFilterContainer.jsx";
import { FindProjectsArgs, SearchFor } from "../stores/EntitySearchStore.js";

import Headers from "../common/Headers.jsx";
import urls from "../utils/url.js";
import React from "react";
import _ from "lodash";
Expand Down Expand Up @@ -51,10 +50,6 @@ class FindProjectsController extends React.PureComponent {
render(): React$Node {
return (
<React.Fragment>
<Headers
title="DemocracyLab"
description="Optimizing the connection between skilled volunteers and tech-for-good projects"
/>
<div className="FindProjectsController-root container">
<div className="row">
<ProjectFilterContainer />
Expand Down
Loading

0 comments on commit 53978c5

Please sign in to comment.