Skip to content

Commit 0de54e2

Browse files
authored
Merge pull request #1439 from CodingTrain/submission-updates
Showcase Language Updates
2 parents 3f99835 + 78691b5 commit 0de54e2

File tree

6 files changed

+84
-18
lines changed

6 files changed

+84
-18
lines changed

content-testing/schemas.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ const baseVideosSchema = strictObject({
124124
name: string().required(),
125125
url: string().url()
126126
}).required()
127-
)
128-
.required()
127+
).required()
129128
});
130129

131130
const videosSchema = baseVideosSchema.concat(
@@ -149,6 +148,7 @@ const showcasesSchema = strictObject({
149148
title: string().required(),
150149
url: string().url().required(),
151150
submittedOn: dateRangeValidator.required(),
151+
socialPermission: boolean().default(true),
152152
author: strictObject({
153153
name: string().required(),
154154
url: string().url(),

content/pages/guides/passenger-showcase-guide.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ date: '2022-05-04'
66

77
## Submission Form
88

9-
Thank you for sharing your work in the Passenger Showcase! There are currently two ways to submit your work: by using this form to upload your work, or to follow the instructions below to create a Pull Request for your project on GitHub!
9+
Thank you for sharing your work in the Passenger Showcase! The Passenger Showcase is a community collection that lives on the Coding Train website, but also is featured periodically during Coding Train live streams as well as on other Coding Train social media spaces!
10+
11+
There are currently two ways to submit your work:
12+
13+
1. Use the form below to share your work.
14+
2. Follow the instructions below to create a pull request to add your project manually.
1015

1116
<PassengerShowcaseForm />
1217

@@ -16,11 +21,11 @@ If you have questions or need any help, come board the [Coding Train Discord](ht
1621

1722
If you choose not to use the form above, you can also submit a Pull Request on GitHub. The first step is to associate your submission with a specific video. Don't worry too much if you aren't sure, just pick wherever you think it fits best! If your work relates to multiple videos just pick one!
1823

19-
First, you will need to [fork the repo](https://docs.github.com/en/get-started/quickstart/fork-a-repo#forking-a-repository). On the [GitHub repo homepage](https://github.com/CodingTrain/thecodingtrain.com), click the button `Fork` in the upper-right corner. You will be prompted to the `Create a new fork` window, press `Create fork` in the bottom of the page. Now, you will have a fork of the original repo.
24+
First, you will need to [fork the repo](https://docs.github.com/en/get-started/quickstart/fork-a-repo#forking-a-repository). On the [GitHub repo homepage](https://github.com/CodingTrain/thecodingtrain.com), click the button `Fork` in the upper-right corner. You will be prompted to the `Create a new fork` window, press `Create fork` in the bottom of the page. Now, you will have a fork of the original repo.
2025

2126
![Fork button](./passenger-showcase/fork.png)
2227

23-
Second, create a branch in your fork by clicking a button in the upper left-hand corner where it says `main`.
28+
Second, create a branch in your fork by clicking a button in the upper left-hand corner where it says `main`.
2429
Type in the name of a branch (you can make this up!) and create the branch! In the example below, I'm calling it `dan-showcase-submission`.
2530

2631
![Branches dropdown](./passenger-showcase/branches.png)
@@ -64,7 +69,9 @@ All showcase submissions should include a thumbnail preview image! While any asp
6469

6570
## Submitting a Pull Request
6671

67-
[Return to the main branch](https://github.com/CodingTrain/thecodingtrain.com/tree/main), and select "Compare & pull request" (or go to the “Pull requests” tab and create a pull request by selecting "New pull request", then "compare: main" and choosing `your-branch-name` from the dropdown)
72+
[Return to the main branch](https://github.com/CodingTrain/thecodingtrain.com/tree/main), and select "Compare & pull request" (or go to the “Pull requests” tab and create a pull request by selecting "New pull request", then "compare: main" and choosing `your-branch-name` from the dropdown).
73+
74+
If you would like to opt out of having your work featured on social media, please note in the comments field of your pull request.
6875

6976
![Uploading thumbnail](./passenger-showcase/pullrequest1.png)
7077
![Uploading thumbnail](./passenger-showcase/pullrequest2.png)

netlify/functions/submission-background.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ const crypto = require('crypto');
1414
// authorInstagram: "@the.coding.train"
1515
// url: "https://thecodingtrain.com/tracks",
1616
// videoDir: "challenges/01-test",
17-
// imageExtension: "png|jpg"
17+
// imageExtension: "png|jpg",
18+
// socialPermission: true
1819
// }
1920
// X-Signature: sha256=...
2021

@@ -77,6 +78,10 @@ exports.handler = async function (event) {
7778
json.author.instagram = postInfo.authorInstagram;
7879
}
7980

81+
if ('socialPermission' in postInfo) {
82+
json.socialPermission = postInfo.socialPermission;
83+
}
84+
8085
const jsonString = JSON.stringify(json, null, 2) + '\n';
8186
const jsonContent = Buffer.from(jsonString).toString('base64');
8287

netlify/functions/submission-sync.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const crypto = require('crypto');
1414
// url: "https://thecodingtrain.com/tracks",
1515
// track: "challenges",
1616
// video: "01-starfield",
17+
// socialPermission: true
1718
// }
1819

1920
async function validateImage(imageBase64) {
@@ -89,6 +90,7 @@ exports.handler = async function (event, context) {
8990
authorTwitter: postInfo.authorTwitter,
9091
authorInstagram: postInfo.authorInstagram,
9192
url: postInfo.url,
93+
socialPermission: postInfo.socialPermission,
9294
videoDir:
9395
postInfo.track === 'challenges'
9496
? `challenges/${postInfo.video}`

src/components/PassengerShowcaseForm.js

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState, useRef, useMemo } from 'react';
22
import { useStaticQuery, graphql } from 'gatsby';
3-
import { object, string } from 'yup';
3+
import { object, string, boolean } from 'yup';
44
import { useLocation } from '@reach/router';
55

66
import Button from './Button';
@@ -19,6 +19,7 @@ import * as css from './PassengerShowcaseForm.module.css';
1919
// url: "https://thecodingtrain.com/tracks",
2020
// track: "challenges",
2121
// video: "01-starfield",
22+
// socialPermission: true
2223
// }
2324

2425
const defaultState = {
@@ -31,7 +32,8 @@ const defaultState = {
3132
authorUrl: '',
3233
authorEmail: '',
3334
authorTwitter: '',
34-
authorInstagram: ''
35+
authorInstagram: '',
36+
socialPermission: true
3537
};
3638

3739
const schema = object({
@@ -44,7 +46,8 @@ const schema = object({
4446
authorUrl: string().label('Your website').url(),
4547
authorEmail: string().label('Your email'),
4648
authorTwitter: string().label('Twitter'),
47-
authorInstagram: string().label('Instagram')
49+
authorInstagram: string().label('Instagram'),
50+
socialPermission: boolean().required()
4851
});
4952

5053
const useVideosWithShowcase = function () {
@@ -144,6 +147,12 @@ const PassengerShowcaseForm = () => {
144147
);
145148
return;
146149
}
150+
if (e.target.name === 'socialPermission') {
151+
setState(
152+
Object.assign({}, state, { [e.target.name]: e.target.value == 'true' })
153+
);
154+
return;
155+
}
147156
setState(Object.assign({}, state, { [e.target.name]: e.target.value }));
148157
};
149158

@@ -294,8 +303,8 @@ const PassengerShowcaseForm = () => {
294303
onChange={onChange}
295304
/>
296305
<span>
297-
A link to either the source code (p5.js editor, GitHub) or a video
298-
(YouTube, Vimeo).
306+
A link to any kind of documentation of your project (blog post,
307+
p5.js editor sketch, GitHub repo, video).
299308
</span>
300309
</label>
301310
<label>
@@ -350,8 +359,36 @@ const PassengerShowcaseForm = () => {
350359
onChange={onChange}
351360
/>
352361
<span>
353-
<em>Optional</em>. Your email address used for the submission in the
354-
Git repository.
362+
<em>Optional</em>. Your email address (This is not stored, but
363+
rather used to match your GitHub account and assign commits for the
364+
submission.)
365+
</span>
366+
</label>
367+
<label>Social media permission</label>
368+
<label>
369+
<span className={css.radioLabel}>
370+
<input
371+
type="radio"
372+
name="socialPermission"
373+
value="true"
374+
checked={state.socialPermission}
375+
onChange={onChange}
376+
/>
377+
The Cafe Car: You have my permission to share this project to other
378+
Coding Train social media platforms!
379+
</span>
380+
</label>
381+
<label>
382+
<span className={css.radioLabel}>
383+
<input
384+
type="radio"
385+
name="socialPermission"
386+
value="false"
387+
checked={!state.socialPermission}
388+
onChange={onChange}
389+
/>
390+
By private carriage: I prefer this project to be featured on the
391+
Coding Train website only.
355392
</span>
356393
</label>
357394
<label>
@@ -363,8 +400,9 @@ const PassengerShowcaseForm = () => {
363400
onChange={onChange}
364401
/>
365402
<span>
366-
<em>Optional</em>. We are sharing the showcase on Twitter! Please
367-
leave your handle if you'd like to be tagged.
403+
<em>Optional</em>. We are not currently featuring the showcase on
404+
Twitter/X, but feel free to leave your handle if you’d like to be
405+
tagged and credited if and when we do.
368406
</span>
369407
</label>
370408
<label>
@@ -376,8 +414,8 @@ const PassengerShowcaseForm = () => {
376414
onChange={onChange}
377415
/>
378416
<span>
379-
<em>Optional</em>. We are sharing the showcase on Instagram! Please
380-
leave your handle if you'd like to be tagged.
417+
<em>Optional</em>. We are featuring the showcase on Instagram!
418+
Please leave your handle if youd like to be tagged and credited!
381419
</span>
382420
</label>
383421
{error && <div className={css.error}>{error}</div>}

src/components/PassengerShowcaseForm.module.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
max-width: 500px;
1616
font-size: var(--maru-small);
1717
line-height: 17px;
18+
19+
&.radio-label {
20+
/* display: inline; */
21+
margin-right: var(--spacing-small);
22+
color: var(--black);
23+
font-size: var(--maru-medium);
24+
max-width: 500px;
25+
}
1826
}
1927
}
2028

@@ -30,6 +38,12 @@
3038
padding: var(--spacing-small);
3139
}
3240

41+
.form input[type="radio"] {
42+
display: inline;
43+
margin-right: var(--spacing-small);
44+
-webkit-appearance: radio;
45+
}
46+
3347
.error,
3448
.submitted {
3549
max-width: 500px;

0 commit comments

Comments
 (0)