Skip to content

Commit b85faab

Browse files
Merge pull request #72 from the-api-administration/main
Updating branch resources to be up to date with main
2 parents 3c86f2e + ec81aca commit b85faab

File tree

6 files changed

+143
-36
lines changed

6 files changed

+143
-36
lines changed

CONTRIBUTING.md

Lines changed: 78 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,84 @@
11
<!-- CONTRIBUTING -->
22

3-
## Contributing
3+
# Contributing
44

5-
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
5+
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
66

7-
If you have a suggestion to better our API, please fork the repo and create a pull request. Additionally, you can open an issue and offer advice.
8-
Don't forget to give the project a star! Thanks again!
7+
<ins>Please make sure to follow our guidelines below before making any contributions.</ins>
98

10-
1. Visit our Issues page to check if an issue exists and does not have an assignee.
9+
10+
11+
## Understanding Coding-Resources-API branch structure
12+
### Permanent Branches
13+
#### Main
14+
- This branch is reserved for tested versions of our code-base. Do not make a PR directly into this branch, as we require testing before we can confirm any feature.
15+
16+
17+
18+
#### Test
19+
- This branch is used to test a collection of newly added features, which will eventually become a future iteration of our application after thoroughly testing for bugs and code/guideline consistency. If you are interested in creating your own feature, we suggest that you first open an issue here: https://github.com/the-api-administration/coding-resources-api/issues and wait for our team to respond to your message and approve the implementation. If you are interested in taking responsibility for the implementation, please assign yourself to the issue once you submit it, so that our team can note your interest.
20+
21+
22+
23+
#### Resources
24+
- This branch is reserved for adding new resources to our resources.js file. When adding a resource, follow these styling guidelines or we will be unable to address your contribution.
25+
26+
Resource Addition Guidelines:
27+
28+
- The resource <ins>must</ins> strictly pertain to coding. Please do not include resources that represent non-coding-related content.
29+
- The resources provided <ins>must</ins> strictly pertain to specific coding related topics, technologies, and content. We will not accept resources that are too broad and/or do not provide a specific focus.
30+
31+
Resource Styling:
32+
33+
- Object values <ins>must</ins> contain single quotes only.
34+
- Keywords array should contain strings only.
35+
- Keywords are preferred in lower case.
36+
- Keywords <ins>must</ins> be specific. Do not include broad keywords such as 'guide', 'tutorial', 'information' or we will be unable to process your PR. Please opt for keywords that are specific to the content.
37+
38+
Resource Format:
39+
40+
```
41+
{
42+
name: 'resource name',
43+
url: 'url here',
44+
keywords: ['each', 'keyword', 'should', 'be', 'a', 'string']
45+
},
46+
```
47+
48+
49+
50+
## How often should I stage changes?
51+
52+
We require that you stage your changes for each section of code you develop. <ins>Do not</ins> stage changes with a single large commit, or we will instantly close your pull request. We would like you to make commits for every task you complete in your code and avoid working through multiple files when possible. Your commit message should include a detailed view of the work you are implementing and an issue you are solving if you have assigned yourself to an issue.
53+
54+
55+
56+
## Where should I make my pull request to?
57+
58+
<ins>Never make a pull request into our main branch</ins>. If you plan on adding a feature, wait until you have completely finished that feature and then make a pull request into "test" with a clear description of the issue you are solving. If you are planning on adding a resource, please make a pull request to the resources branch.
59+
60+
61+
62+
## Creating an Issue
63+
64+
We'd love to hear your advice, feature suggestions and/or read about any bugs you've encountered. Please create an issue here: https://github.com/the-api-administration/coding-resources-api/issues. If you wish to implement a feature on your own, please add yourself as an assignee to the issue you create, so that we can note your interest. When creating an issue, please attempt to outline in detail the topic of the issue, and a thorough description of what the issue attempts to solve.
65+
66+
If you have encountered a bug, please provide as much information as you can to help us replicate the issue on our own end. Depending on the issue, it may be useful to communicate your browser, screen width, and/or anything that relates to your specific encounter.
67+
68+
69+
70+
## How to make a PR
71+
72+
If you want to help us improve our API, please fork the repo and follow these steps before creating a pull request.
73+
74+
1. Visit [our Issues](https://github.com/the-api-administration/coding-resources-api/issues) page to check if an issue exists and does not yet have an assignee. Assign yourself to the issue if you find what you are planning to solve.
1175
2. Fork the Project
12-
3. Change to your Feature Branch (`git checkout -b feature/AmazingFeature`)
13-
4. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
14-
5. Push to the Branch (`git push origin feature/AmazingFeature`)
15-
6. Open a Pull Request
76+
3. Clone your fork on your local device. The link can be found under the code drop-down at the base of your fork (`git clone <link here>`)
77+
4. If you are adding a resource, please skip to step 6.
78+
5. Create a new branch for your Feature (`git branch AmazingFeature`)
79+
6. Switch to the branch you are working on (`git checkout AmazingFeature`)
80+
7. Make your changes, commit after every isolated task.
81+
8. Add all of your changes (`git add .`)
82+
9. Commit your changes with a detailed description (`git commit -m 'added a, solved b, etc...'`)
83+
10. Push to the Branch (`git push origin AmazingFeature`)
84+
11. Open a Pull Request and follow the rules under "Where should I make my pull request to?"

README.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[![Contributors][contributors-shield]][contributors-url]
66
[![Forks][forks-shield]][forks-url]
77
[![Stargazers][stars-shield]][stars-url]
8+
[![Pull Requests][pullrequests-shield]][pullrequests-url]
89
[![Issues][issues-shield]][issues-url]
910
[![MIT License][license-shield]][license-url]
1011

@@ -103,15 +104,7 @@ See the [open issues](https://github.com/the-api-administration/coding-resources
103104

104105
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
105106

106-
If you have a suggestion to better our API, please fork the repo and create a pull request. Additionally, you can open an issue and offer advice.
107-
Don't forget to give the project a star! Thanks again!
108-
109-
1. Visit our Issues page to check if an issue exists and does not have an assignee.
110-
2. Fork the Project
111-
3. Change to your Feature Branch (`git checkout -b feature/AmazingFeature`)
112-
4. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
113-
5. Push to the Branch (`git push origin feature/AmazingFeature`)
114-
6. Open a Pull Request
107+
Please visit <a href="https://github.com/the-api-administration/coding-resources-api/blob/main/CONTRIBUTING.md">`CONTRIBUTING.md`</a> to read about our guidelines before making a contribution to our project. Thank you!
115108

116109
<p align="right">(<a href="#top">back to top</a>)</p>
117110

@@ -148,6 +141,8 @@ Distributed under the MIT License. See <a href="https://github.com/the-api-admin
148141
[forks-url]: https://github.com/the-api-administration/coding-resources-api/network/members
149142
[stars-shield]: https://img.shields.io/github/stars/the-api-administration/coding-resources-api.svg?style=for-the-badge
150143
[stars-url]: https://github.com/the-api-administration/coding-resources-api/stargazers
144+
[pullrequests-shield]: https://img.shields.io/github/issues-pr/the-api-administration/coding-resources-api?color=red&label=Pull%20Requests&style=for-the-badge
145+
[pullrequests-url]: https://github.com/the-api-administration/coding-resources-api/pulls
151146
[issues-shield]: https://img.shields.io/github/issues/the-api-administration/coding-resources-api.svg?style=for-the-badge
152147
[issues-url]: https://github.com/the-api-administration/coding-resources-api/issues
153148
[license-shield]: https://img.shields.io/github/license/the-api-administration/coding-resources-api.svg?style=for-the-badge

public/css/style.css

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ main {
191191
font-weight: 600;
192192
}
193193

194-
.api-test form input:hover {
194+
.api-test form input:focus {
195195
width: 70%;
196196
}
197197

@@ -257,15 +257,39 @@ main {
257257
background-color: #dbdbdb;
258258
}
259259

260-
.json {
261-
display: block;
262-
white-space: pre-wrap;
260+
.text-truncate {
261+
display: inline-block;
262+
max-width: 100%;
263+
white-space: nowrap;
264+
overflow: hidden;
265+
text-overflow: ellipsis;
266+
}
267+
268+
.json,
269+
code {
270+
white-space: pre-line;
271+
}
272+
273+
.indent h4,
274+
.indent h5,
275+
.indent h6 {
276+
padding: 0;
263277
}
264278

265279
.indent {
266280
padding-left: 2rem;
267-
margin-top: -2rem;
268-
line-height: 2;
281+
}
282+
283+
.indent * {
284+
line-height: 1.5; /* If this value is changed, make sure it is atleast 1 to avoid clipping when text wraps */
285+
font-size: 1em;
286+
margin: 0;
287+
text-align: left;
288+
font-weight: 400;
289+
}
290+
291+
.indent a {
292+
font-weight: 700;
269293
}
270294

271295
/* documentation */

public/js/main.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ async function getMatches() {
3535
const res = await fetch('/api');
3636
const data = await res.json();
3737
// Filters array from the API for resources with keywords containing user value
38-
const matches = data.filter(resource => resource.keywords.some(str => str.includes(keyword)));
38+
const matches = data.filter(resource => resource.keywords.some(str => str.toLowerCase().includes(keyword)));
3939
renderMatches(matches);
4040
} catch (err) {
4141
console.error(err);
@@ -63,7 +63,17 @@ function renderMatches(matches) {
6363

6464
// Create an element that looks like a JSON object for every match
6565
li.innerHTML = `
66-
<pre class="json"><code>{<div class="indent"><br>name: '${match.name}',<br>url: <a href="${match.url}" target="_blank">'${match.url}',</a><br class="middle-br">keywords: [${match.keywords.map(keyword => `'${keyword}'`).join(", ")}]<br></div>},</code></pre>
66+
<pre class="json">
67+
<code>
68+
{
69+
<div class="indent">
70+
<h4>name: ${match.name},</h4>
71+
<h5>url: '<a href=${match.url} target="_blank">${match.url}</a>',</h5>
72+
<h6 class="text-truncate">keywords: [${match.keywords.map(keyword => `'${keyword}'`).join(", ")}]</h6>
73+
</div>
74+
},
75+
</code>
76+
</pre>
6777
`;
6878

6979
list.appendChild(li);

server.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ app.use(express.static(__dirname + '/public'));
1010
app.use('/public', express.static(__dirname + '/public'));
1111

1212
app.get('/', (req, res) => {
13-
try {
14-
if (resources) {
15-
res.render('index.ejs', { resources });
16-
} else {
17-
throw new Error('Resources not found.')
18-
}
19-
} catch (err) {
20-
console.error(err);
13+
if (resources) {
14+
res.render('index.ejs', { resources });
15+
} else {
16+
// respond with status 500 if the resources array could not be loaded from resources.js
17+
res.status(500).json({
18+
error: 'Resources were not able to be loaded from resources.js.'
19+
});
2120
}
2221
});
2322

@@ -29,7 +28,7 @@ app.get('/api/:keyword', (req, res) => {
2928
const keyword = req.params.keyword.toLowerCase();
3029

3130
// filter resources array, return items that match query; tag.
32-
const matches = resources.filter((obj) => obj.keywords.some(str => str.includes(keyword)));
31+
const matches = resources.filter((obj) => obj.keywords.some(str => str.toLowerCase().includes(keyword)));
3332

3433
// if matches were found, respond with matches array in JSON format
3534
if (matches.length) {

views/index.ejs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,17 @@
6060
<li>
6161
<!-- JSON Format for DOM rendering -->
6262
<!-- Add indentation, line break and quotes around each key's value -->
63-
<pre class="json"><code>{<div class="indent"><br>name: '<%= resources[i].name %>',<br>url: <a href=<%= resources[i].url %> target="_blank">'<%= resources[i].url %>',</a><br class="middle-br">keywords: [<%= resources[i].keywords.map(keyword => `'${keyword}'`).join(", ") %>]<br></div>},</code></pre>
63+
<pre class="json">
64+
<code>
65+
{
66+
<div class="indent">
67+
<h4>name: '<%= resources[i].name %>',</h4>
68+
<h5>url: '<a href=<%= resources[i].url %> target="_blank"><%= resources[i].url %></a>',</h5>
69+
<h6 class="text-truncate">keywords: [<%= resources[i].keywords.map(keyword => `'${keyword}'`).join(", ") %>]</h6>
70+
</div>
71+
},
72+
</code>
73+
</pre>
6474
</li>
6575
<% } %>
6676
</ul>

0 commit comments

Comments
 (0)