Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#55 - added customizable number of pull requests #90

Merged
merged 3 commits into from
Oct 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ cp secret.env.example secret.env
Paste the **Client ID** and **Client Secret** from your registered GitHub
application into `secret.env`.


(If on Windows) Make sure your local repository path (for example `C:\Users\username\repos\job-board`) is available for Docker Filesharing by going to `Docker Dashboard > Settings > Resources > File Sharing`

Start the database in daemon mode:

```
Expand All @@ -52,7 +55,7 @@ npm install
Build the frontend assets:

```
npm run production
npm run build
```

You're ready to go! Visit [http://localhost:8080](localhost:8080) in your
Expand Down
14 changes: 14 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ type Project struct {
Visible bool
}

type HacktoberfestConfiguration struct {
RequiredPullRequestCount int
RequiredPullRequestCountEng string
TimesToRepeat string
}

var hacktoberfestOptions = HacktoberfestConfiguration{
RequiredPullRequestCount: 2, // the number of pull requests required to qualify for this year.
RequiredPullRequestCountEng: "two pull requests", // the required number written out fully
TimesToRepeat: "Repeat 1 more times.", // the value in this sentence should be one less than the required count.
}

// These specific projects also count
var projects = map[string]Project{
"imacrayon/eventsinwichita": {
Expand Down Expand Up @@ -172,10 +184,12 @@ func home(w http.ResponseWriter, r *http.Request) {
Orgs map[string]bool
Projects map[string]Project
Year int
Config HacktoberfestConfiguration
}{
Orgs: orgs,
Projects: projects,
Year: time.Now().Year(),
Config: hacktoberfestOptions,
}
v.HTML(w, http.StatusOK, "home", data)
}
Expand Down
4 changes: 3 additions & 1 deletion profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ func profile(w http.ResponseWriter, r *http.Request) {
Projects map[string]Project
User goth.User
New bool
Config HacktoberfestConfiguration
Year int
}{
Orgs: orgs,
Projects: projects,
User: u,
New: n,
Year: time.Now().Year(),
Config: hacktoberfestOptions,
Year: time.Now().Year(),
}

v.HTML(w, http.StatusOK, "profile", info)
Expand Down
12 changes: 8 additions & 4 deletions public/js/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,23 @@ function checkPRs() {
results.prepend(t);
});

var requiredPullRequestsCount = $('#required-pull-requests-count').val();
var today = new Date();
var message;
if (data.length === 0) {
// No PRs
message = 'You have not opened any Pull Requests on public GitHub projects during October ' + today.getFullYear() + '.';
} else if (validCount === 0) {
// Some PRs but none counts
message = 'You have ' + data.length + ' Pull Request(s) but none of them are against approved repos.';
} else if (validCount < 2) {
var pullRequestsString = data.length == 1 ? 'Pull Request' : 'Pull Requests'
message = 'You have ' + data.length + ' ' + pullRequestsString + ' but none of them are against approved repos.';
} else if (validCount < requiredPullRequestsCount) {
// Some PRs that count but not quite 2
message = 'Nice! You have ' + validCount + ' Pull Request(s) that count for devICT Hacktoberfest. Keep it up!';
var pullRequestsString = validCount == 1 ? 'Pull Request' : 'Pull Requests'
var countsString = validCount == 1 ? 'counts' : 'count' // grammar agreement with singular or plural subject
message = 'Nice! You have <b>' + validCount + ' ' + pullRequestsString + '</b> that ' + countsString + ' for devICT Hacktoberfest. Keep it up!';
} else {
// >= 2 valid PRs! Woohoo!
// >= 'requiredPullRequestsCount' valid PRs! Woohoo!
message = 'Excellent! You have hit the goal! Maybe hop in the devICT Slack and help others hit their goal too!';
}

Expand Down
6 changes: 3 additions & 3 deletions templates/home.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</div>
-->
<div class="prose prose-xl text-gray-500">
<p class="text">This is a blatant attempt to piggyback off the popularity of the global <a class="dark" href="https://hacktoberfest.digitalocean.com">Hacktoberfest event</a> from Digital Ocean and GitHub. Submit two pull requests to qualifying Wichita projects during the month of October and receive stickers from us!</p>
<p class="text">This is a blatant attempt to piggyback off the popularity of the global <a class="dark" href="https://hacktoberfest.digitalocean.com">Hacktoberfest event</a> from Digital Ocean and GitHub. Submit {{ .Config.RequiredPullRequestCountEng }} to qualifying Wichita projects during the month of October and receive stickers from us!</p>
</div>
<div class="mb-1 sm:flex sm:justify-center md:justify-start">
<div class="rounded-md shadow">
Expand Down Expand Up @@ -110,7 +110,7 @@
<div class="mt-5">
<h3 class="text-lg leading-6 font-medium text-gray-900">Submit a PR</h3>
<p class="mt-2 text-base leading-6 text-gray-500">
Submit a pull request with your proposed change. Repeat 1 more time.
Submit a pull request with your proposed change. {{ .Config.TimesToRepeat }}
</p>
</div>
</li>
Expand All @@ -122,7 +122,7 @@
<div class="mt-5">
<h3 class="text-lg leading-6 font-medium text-gray-900">Enjoy Your Stickers!</h3>
<p class="mt-2 text-base leading-6 text-gray-500">
After two pull requests, you are eligible to receive a fun set of stickers!
After {{ .Config.RequiredPullRequestCountEng }}, you are eligible to receive a fun set of stickers!
</p>
</div>
</li>
Expand Down
7 changes: 4 additions & 3 deletions templates/layout.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<meta name="description" content="Submit two pull requests to qualifying Wichita projects during the month of October and receive cool stickers!">
<meta name="description" content="Submit {{ .Config.RequiredPullRequestCountEng }} to qualifying Wichita projects during the month of October and receive cool stickers!">
<meta name="keywords" content="devICT, Wichita, Hacktoberfest">

<meta property="og:type" content="website"/>
<meta property="og:title" content="Wichita Hacktoberfest {{ .Year }}!"/>
<meta property="og:url" content="https://devict-hacktoberfest.herokuapp.com/"/>
<meta property="og:description" content="Submit two pull requests to qualifying Wichita projects during the month of October and receive cool stickers!"/>
<meta property="og:description" content="Submit {{ .Config.RequiredPullRequestCountEng }} to qualifying Wichita projects during the month of October and receive cool stickers!"/>
<meta property="og:image" content="https://devict-hacktoberfest.herokuapp.com/public/images/social.png"/>

<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@dev_ict">
<meta name="twitter:title" content="devICT Hacktoberfest {{ .Year }}!">
<meta name="twitter:description" content="Submit two pull requests to qualifying Wichita projects during the month of October and receive cool stickers!">
<meta name="twitter:description" content="Submit {{ .Config.RequiredPullRequestCountEng }} to qualifying Wichita projects during the month of October and receive cool stickers!">
<meta name="twitter:image" content="https://devict-hacktoberfest.herokuapp.com/public/images/social.png">

<link rel="apple-touch-icon" sizes="180x180" href="/public/images/icons/apple-touch-icon.png">
Expand All @@ -39,6 +39,7 @@
{{ partial "css" }}
</head>
<body id="#">
<input hidden id="required-pull-requests-count" value='{{ .Config.RequiredPullRequestCount }}' />
{{ yield }}

<!-- Core JavaScript. jQuery, Bootstrap, and Popper -->
Expand Down
2 changes: 1 addition & 1 deletion templates/profile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
</li>
<li class="flex-1 min-w-0">
<strong>Submit a PR</strong><br>
Open a Pull Request back to the original project. This asks the project's maintainer to consider merging your changes into the project. Go pick another issue and start the cycle again. <em>Remember the target is 2 PRs</em>.
Open a Pull Request back to the original project. This asks the project's maintainer to consider merging your changes into the project. Go pick another issue and start the cycle again. <em>Remember the target is {{ .Config.RequiredPullRequestCountEng }}</em>.
</li>
<li class="flex-1 min-w-0">
<strong>Enjoy Your Stickers!</strong><br>
Expand Down