Skip to content

Commit

Permalink
about modal component
Browse files Browse the repository at this point in the history
  • Loading branch information
carolrs committed Jun 22, 2023
1 parent b83c9ef commit 5123722
Show file tree
Hide file tree
Showing 25 changed files with 23,702 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

.env
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# NY Times Search App

![Class System Design Drawing](docs/ny-times-news.gif?raw=true "News")

# Overview
This project is a search application that utilizes the New York Times and OpenWeatherMap API to fetch and display articles and information about the Weather. The original version of this project was created by following the tutorial "ReactJs News App using the New York Times Articles API" on YouTube(https://www.youtube.com/watch?v=m2aYEl14ekY). However, I have added new features and personalized the all CSS to make it my own.

# New Features Included by me:

- **Navigation Bar**: Navigate through different sections like "About" and "Contact".
- **Dark Mode**: A feature to switch between light and dark themes.
- **Web Share API**: Share articles easily using the Web Share API.
- **Pagination**: Navigate through different articles using the pagination system.
- **Read Later Function**: Save articles for reading later.
- **List of Saved Articles**: Access all the articles you've saved for reading later.
- **Subscription**: Subscribe button that redirects to the New York Times subscription page.
- **Weather Information**: This feature shows weather information of the user's current location using the OpenWeatherMap API.
- **Dynamic Background**: The background of the weather information changes according to the weather.
- **Geolocation**: The application retrieves the user's current location and uses it to fetch weather information.

## Weather Information with Geolocation

The weather information feature uses the OpenWeatherMap API to fetch current weather information based on the user's geolocation. It uses the `navigator.geolocation` web API to get the current location of the user (latitude and longitude). If the geolocation service is not enabled or available, it defaults to a predefined location.

Additionally, this feature includes a dynamic background that changes based on the weather. For example, if it's snowing, the background image will be one that suits a snowy atmosphere. The images are fetched from Pexels API.

The geolocation feature is safe to use as it only accesses the location data when the user permits it. If the user doesn't allow location access, the feature won't work but the application will continue to function normally.

# Original Features

* Search for articles.
* Display article information
* Links to the full articles.

# Pre-requisites
* Node.js installed on your machine.
* An API key from the New York Times API.
* An API key from the OpenWeatherMap API.

# Installation
* Clone this repository by running `git clone <https://github.com/carolrs/news-article>` in your terminal.

* Install the necessary dependencies with `npm install` or `yarn install`.

* Create a .env file in the root of your project.

* Inside this file, you should set your New York Times API Key and your OpenWeatherMap API key like this:

```
REACT_APP_NYT_API_KEY=your_nyt_api_key_here
REACT_APP_OWM_API_KEY=your_owm_api_key_here
```

* Run the project locally with `npm start` or `yarn start`.

Your app should now be running on `localhost:3000`.

# Usage

Simply type your search term in the search bar and press 'Search'. The results will be fetched from the New York Times API and displayed on the page. You can click 'Read More' to go to the full article.

# Acknowledgements

This project was initially created by following the tutorial "ReactJs News App using the New York Times Articles API" on YouTube(https://www.youtube.com/watch?v=m2aYEl14ekY). I have extended the project by adding new features and customizing the app.

1 change: 1 addition & 0 deletions api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules
56 changes: 56 additions & 0 deletions api/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const cron = require('node-cron');
const nodemailer = require('nodemailer');
const mongoose = require('mongoose');
const fetch = require('node-fetch');

const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: '[email protected]',
pass: 'topmot-7koGcy-quqsap'
}
});



// substituir "news-articles" pelo nome real do seu banco de dados
mongoose.connect(process.env.MONGO_URL + "/news-articles", { useNewUrlParser: true, useUnifiedTopology: true });

const db = mongoose.connection;
// db.on('error', console.error.bind(console, 'connection error:'));
// db.once('open', function() {
// cron.schedule('* * * * 7', () => {
// const Subscription = mongoose.model('Subscription', new mongoose.Schema({}, { strict: false }), 'subscriptions');
// Subscription.find({}, (err, docs) => {
// if (err) throw err;

// docs.forEach(async doc => {
// const { email, preferences } = doc;

// const articles = [];
// for (let pref of preferences) {
// const res = await fetch(`https://api.nytimes.com/svc/search/v2/articlesearch.json?q=${pref}&api-key=${process.env.REACT_APP_NYT_API_KEY}`);
// const data = await res.json();
// articles.push(...data.response.docs);
// }
// })
// })

// const mailOptions = {
// from: '[email protected]',
// to: email,
// subject: 'Sua newsletter semanal',
// text: articles.map(article => article.web_url).join('\n')
// };

// transporter.sendMail(mailOptions, (error, info) => {
// if (error) {
// console.log(error);
// } else {
// console.log('Email sent: ' + info.response);
// }
// });
// });
// });
// });
// });
Loading

0 comments on commit 5123722

Please sign in to comment.