-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'baklava' into feature/users-stats
- Loading branch information
Showing
14 changed files
with
393 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { HomeScreenContent } from "../types"; | ||
|
||
export const DidYouKnow: HomeScreenContent[] = [ | ||
{ | ||
contentType: "DidYouKnow", | ||
image: "https://berkshares-images.imgix.net/BShare_Coins_Asset_4.png", | ||
textTitle: "Did You Know?", | ||
text: "Adopting BerkShares encourages local economic circularity—keeping more of the region’s wealth working locally. Well done for taking part!", | ||
}, | ||
{ | ||
contentType: "DidYouKnow", | ||
image: "https://berkshares-images.imgix.net/BShare_Coins_Asset_5.png", | ||
textTitle: "Did You Know?", | ||
text: "Everyday citizens are increasingly seeking ways to shop locally, eat local produce, and share in community. BerkShares is a conduit for that “support local” energy!", | ||
}, | ||
{ | ||
contentType: "DidYouKnow", | ||
image: "https://berkshares-images.imgix.net/BShare_Coins_Asset_6.png", | ||
textTitle: "Did You Know?", | ||
text: "As more people and businesses accept and pay through BerkShares, a larger share of local economic activity is kept working within the community. Spread the word!", | ||
}, | ||
{ | ||
contentType: "DidYouKnow", | ||
image: "https://berkshares-images.imgix.net/BShare_Coins_Asset_7.png", | ||
text: "By using blockchain technology, BerkShares offers a payment method that saves businesses on hefty processing fees. Aren’t you savvy?", | ||
}, | ||
{ | ||
contentType: "DidYouKnow", | ||
image: "https://berkshares-images.imgix.net/BShare_Coins_Asset_8.png", | ||
textTitle: "Did You Know?", | ||
text: "It’s always free to accept and spend BerkShares. Encourage friends, family, and neighbors to join in and support the local economy. It’s money well spent!", | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { HomeScreenContent } from "../types"; | ||
|
||
export const FeaturedArtists: HomeScreenContent[] = [ | ||
{ | ||
contentType: "FeaturedArtists", | ||
image: "https://berkshares-images.imgix.net/BerkShare_1-back.jpg", | ||
textTitle: "Bart Elsbach, Reflected Connections, oil on canvas, 1999", | ||
text: "Sheffield-based landscape painter who often depicts New England scenery. Influenced by the works of 17th and 18th Dutch Masters as well as the Hudson River School, his work has been described as a “celebration of the Berkshires.", | ||
}, | ||
{ | ||
contentType: "FeaturedArtists", | ||
image: "https://berkshares-images.imgix.net/BerkShare_5-back.jpg", | ||
textTitle: "Morgan Bulkeley, Jr., Bash Bish Gap, oil on canvas, 1976.", | ||
text: "Mount Washington-born artist and environmental conservationist. His paintings, sculptures and other works are animated by wildlife, childhood friends, and other “floundering souls of the modern human race.", | ||
}, | ||
{ | ||
contentType: "FeaturedArtists", | ||
image: "https://berkshares-images.imgix.net/BerkShare_10-back.jpg", | ||
textTitle: "Janet Rickus, Turnips on Table, oil on panel, 1996.", | ||
text: "West Springfield rooted painter of landscapes, portraits and still lives. Her parents operated a grocery store in West Springfield in her youth, and this early proximity to the products of the land is evident in her vibrant compositions.", | ||
}, | ||
{ | ||
contentType: "FeaturedArtists", | ||
image: "https://berkshares-images.imgix.net/BerkShare_20-back.jpg", | ||
textTitle: "Warner Friedman, June, acrylic on canvas, 1999.", | ||
text: "Landscape artist, architect and engineer residing in Massachusetts. A lifelong fascination with mathematical precision led him to incorporate abstract geometry into an unconventional approach to land and seascape painting.", | ||
}, | ||
{ | ||
contentType: "FeaturedArtists", | ||
image: "https://berkshares-images.imgix.net/BerkShare_50-back.jpg", | ||
textTitle: "Joan Griswold, Green Shopfront, oil on linen, 1998.", | ||
text: "Artist and teacher who calls Great Barrington home. Her richly textured scenes evoke the small town ambiance of the Berkshires as well as rural England, where she taught herself to paint.", | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { HomeScreenContent } from "../types"; | ||
|
||
export const Heroes: HomeScreenContent[] = [ | ||
{ | ||
contentType: "Heroes", | ||
image: "https://berkshares-images.imgix.net/BerkShare_1-front.jpg", | ||
textTitle: "The Mohican Nation", | ||
text: "Original Native American inhabitants of these lands and waterways prior to European settlement. Their responsible stewardship of our environment recalls our obligation to respect and care for our living ecology. A township was granted to tribe members in 1736 in today’s Stockbridge and West Stockbridge. These lands were later lost to white settlement through mortgage, debt, and sometimes fraud, and the group eventually accepted an offer of removal, and today’s Stockbridge-Munsee Band is centered around a reservation in Wisconsin. They still look to the Berkshires as a part of their ancestral homeland.", | ||
}, | ||
{ | ||
contentType: "Heroes", | ||
image: "https://berkshares-images.imgix.net/BerkShare_5-front.jpg", | ||
textTitle: "W. E. B. Du Bois", | ||
text: "Sociologist and civil rights pioneer committed to the freedom and equality of all peoples. Born in Great Barrington in 1868, Du Bois’ activities contributed to the formation of the National Association for the Advancement of Colored People. For twenty-five years he served as editor of the NAACP Magazine, The Crisis. Today, Du Bois’s boyhood homesite in the Berkshires is dedicated as a National Historic Landmark.", | ||
}, | ||
{ | ||
contentType: "Heroes", | ||
image: "https://berkshares-images.imgix.net/BerkShare_50-front.jpg", | ||
textTitle: "Norman Rockwell", | ||
text: "Iconic 20th century American artist celebrated for his vivid and affectionate portraits of everyday life. The people and community of Stockbridge are eternally woven into Rockwell’s classic depictions. The Norman Rockwell Museum at Stockbridge is a trust dedicated to his legacy.", | ||
}, | ||
{ | ||
contentType: "Heroes", | ||
image: "https://berkshares-images.imgix.net/BerkShare_20-front.jpg", | ||
textTitle: "Herman Melville", | ||
text: "Writer and mariner lauded for his great American novel, Moby-Dick written at Arrowhead. Melville frequented the Berkshires as a boy and, inspired by the beauty of the area, settled near Pittsfield in 1850. Written at Arrowhead farmhouse by 1851, its brilliance — with timeless reflections on human nature and environmental ethics — was not fully recognized until later. Arrowhead is today preserved as a National Historic Landmark.", | ||
}, | ||
{ | ||
contentType: "Heroes", | ||
image: "https://berkshares-images.imgix.net/BerkShare_10-front.jpg", | ||
links: [ | ||
{ | ||
url: "https://berkshiregrown.org/", | ||
text: "Berkshire Grown", | ||
}, | ||
], | ||
textTitle: "Robyn Van En", | ||
text: "A pioneer of the community supported agriculture (CSA) movement in North America. Van En co-founded the forerunner to today’s Berkshire Grown. Her Indian Line Farm in South Egremont has been a model for small-scale, sustainable agriculture since 1985. Her work lives on locally and in more than 3,000 CSAs now active globally.", | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { HomeScreenContent } from "../types"; | ||
|
||
export const Values: HomeScreenContent[] = [ | ||
{ | ||
contentType: "Values", | ||
image: | ||
"https://berkshares-images.imgix.net/BSHARES_UI_AssetsWell_original.tif.svg", | ||
textTitle: "COMMUNITY", | ||
text: "BerkShares fosters stronger community connections through personal exchanges and local trade.", | ||
}, | ||
{ | ||
contentType: "Values", | ||
image: | ||
"https://berkshares-images.imgix.net/BSHARES_UI_AssetsWheat_original.tif.svg", | ||
textTitle: "ECONOMY", | ||
text: "BerkShares are a tool for strengthening the local economy by prioritizing local exchange, building regional supply chain resilience.", | ||
}, | ||
{ | ||
contentType: "Values", | ||
image: | ||
"https://berkshares-images.imgix.net/BSHARES_UI_AssetsHive_original.tif.svg", | ||
textTitle: "ECOLOGY", | ||
text: "By encouraging people to shop locally, and businesses to procure locally, BerkShares decreases the distance of goods shipped.", | ||
}, | ||
{ | ||
contentType: "Values", | ||
image: | ||
"https://berkshares-images.imgix.net/BSHARES_UI_AssetsPhoenix_original.tif.svg", | ||
textTitle: "SUSTAINABILITY", | ||
text: "By promoting the local production and consumption of food and manufactured wares, using BerkShares helps nurture a sustainable future for the Berkshires.", | ||
}, | ||
{ | ||
contentType: "Values", | ||
image: | ||
"https://berkshares-images.imgix.net/BSHARES_UI_AssetsPeacock_original.tif.svg", | ||
textTitle: "EQUITY", | ||
text: "BerkShares strives to support a flourishing local economy for all residents, including groups structurally excluded from economic determination and regional prosperity.", | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { Request, Response } from "express"; | ||
import { HomeScreenContent } from "src/types"; | ||
import { httpUtils, log } from "src/utils"; | ||
import { DidYouKnow } from "src/content/DidYouKnow"; | ||
import { FeaturedArtists } from "src/content/FeaturedArtists"; | ||
import { Heroes } from "src/content/Heroes"; | ||
import { Values } from "src/content/Values"; | ||
|
||
const codes = httpUtils.codes; | ||
|
||
function randomInteger(upTo: number, includingZero = true): number { | ||
return Math.floor(Math.random() * upTo + (includingZero ? 0 : 1)); | ||
} | ||
|
||
function selectContentFromSource( | ||
sourceContent: HomeScreenContent[], | ||
random?: number | ||
): HomeScreenContent[] { | ||
let selectedContent: HomeScreenContent[] = []; | ||
|
||
if (random) { | ||
for (let i = 0; i < random; i++) { | ||
if (sourceContent.length > 0) { | ||
const index = randomInteger(sourceContent.length); | ||
selectedContent.push(sourceContent[index]); | ||
sourceContent.splice(index, 1); | ||
} | ||
} | ||
} else selectedContent = sourceContent; | ||
|
||
return selectedContent; | ||
} | ||
|
||
export async function getContent(_req: Request, res: Response): Promise<void> { | ||
try { | ||
const limit = _req?.query?.limit; | ||
const random = _req?.query?.random; | ||
let type = _req?.query?.type; | ||
|
||
let content: HomeScreenContent[] = []; | ||
|
||
if (!type) { | ||
content = [...DidYouKnow, ...FeaturedArtists, ...Heroes, ...Values]; | ||
} else { | ||
type = String(type).toUpperCase(); | ||
|
||
if (type == "DIDYOUKNOW") content = DidYouKnow; | ||
if (type == "FEATUREDARTISTS") content = FeaturedArtists; | ||
if (type == "HEROES") content = Heroes; | ||
if (type == "VALUES") content = Values; | ||
} | ||
|
||
content = selectContentFromSource(content, random); | ||
|
||
if (limit) { | ||
content = content.slice(0, limit); | ||
} | ||
|
||
httpUtils.createHttpResponse(content, codes.OK, res); | ||
} catch (err) { | ||
log(err); | ||
httpUtils.createHttpResponse( | ||
{ message: "Server error: " + err }, | ||
codes.SERVER_ERROR, | ||
res | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import express from "express"; | ||
import * as controller from "./controller"; | ||
|
||
const content = express(); | ||
content.get("/content", controller.getContent); | ||
export default content; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.