Skip to content

Commit

Permalink
Merge branch 'main' into dark-mode-feature
Browse files Browse the repository at this point in the history
  • Loading branch information
AnsharaFayazBeigh authored Oct 26, 2024
2 parents a4d5abc + 80c0ae6 commit 51aa41e
Show file tree
Hide file tree
Showing 27 changed files with 1,473 additions and 381 deletions.
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/custom.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: Custom issue template
about: Describe this issue template's purpose here.
title: ''
labels: ''
assignees: ''

---


20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
30 changes: 24 additions & 6 deletions .github/workflows/greetings.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Greetings

on: [pull_request_target, issues]
on:
pull_request_target:
types: [opened, reopened, closed]
issues:
types: [opened, closed]

jobs:
greeting:
Expand All @@ -9,8 +13,22 @@ jobs:
issues: write
pull-requests: write
steps:
- uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: "👋 Hey there, rockstar! Thanks for dropping an issue! The BlogLog team is on it like pineapple on pizza (love it or hate it). Stick around, magic's about to happen!"
pr-message: "🎉 Boom! Your pull request just flew into the BlogLog HQ. High fives all around! Our team of tech wizards will check it out and get back to you faster than you can say 'code ninja!' Thanks for leveling up the project!"
- uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: "👋 Hey there, rockstar! Thanks for dropping an issue! The BlogLog team is on it like pineapple on pizza (love it or hate it). Stick around, magic's about to happen!"
pr-message: "🎉 Boom! Your pull request just flew into the BlogLog HQ. High fives all around! Our team of tech wizards will check it out and get back to you faster than you can say 'code ninja!' Thanks for leveling up the project!"

congratulate:
if: github.event.action == 'closed' && github.event.issue != null
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Congratulate on Issue Closure
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments \
-d '{"body": "🎉 Congratulations @'${{ github.event.issue.user.login }}'! Your issue has been successfully closed! Thanks for your contribution! If you enjoyed contributing, please consider giving us a ⭐ and following us for updates!"}'
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
.env
.env
logs
127 changes: 94 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,111 @@
<div align="center">
# BlogLog 📝

# BlogLog
Welcome to **BlogLog**, your personalized blogging companion designed to help you effortlessly keep track of your thoughts, experiences, and reflections all in one convenient log. Built with **Node.js**, **Express**, and **MongoDB**, BlogLog provides a user-friendly interface to create, read, update, and delete (CRUD) your blog posts.

<i>Welcome to BlogLog, your personalized blogging companion tailored to keep track of your thoughts, experiences, and reflections in one convenient log. This application is built with Node.js, Express, and MongoDB, making it easy for you to create, read, update, and delete (CRUD) your blog posts.</i>
<table align="center">
<thead align="center">
<tr border: 2px;>
<td><b>🌟 Stars</b></td>
<td><b>🍴 Forks</b></td>
<td><b>🐛 Issues</b></td>
<td><b>🔔 Open PRs</b></td>
<td><b>🔕 Close PRs</b></td>
</tr>
</thead>
<tbody>
<tr>
<td><img alt="Stars" src="https://img.shields.io/github/stars/jinx-vi-0/BlogLog?style=flat&logo=github"/></td>
<td><img alt="Forks" src="https://img.shields.io/github/forks/jinx-vi-0/BlogLog?style=flat&logo=github"/></td>
<td><img alt="Issues" src="https://img.shields.io/github/issues/jinx-vi-0/BlogLog?style=flat&logo=github"/></td>
<td><img alt="Open Pull Requests" src="https://img.shields.io/github/issues-pr/jinx-vi-0/BlogLog?style=flat&logo=github"/></td>
<td><img alt="Close Pull Requests" src="https://img.shields.io/github/issues-pr-closed/jinx-vi-0/BlogLog?style=flat&color=critical&logo=github"/></td>
</tr>
</tbody>
</table>

</div>
## Key Features 🌟

<div align="center">
- **📝 Create New Blog Posts**: Easily compose and publish your thoughts.
- **👁️ Read & View**: Browse through your blog posts with a simple and intuitive design.
- **✏️ Update Posts**: Modify existing blog entries to reflect your current thoughts.
- **❌ Delete Posts**: Remove any blog posts you no longer wish to keep.
- **📱 Responsive Design**: Enjoy a seamless experience across all devices.
- **🖱️ User-Friendly Interface**: Navigate effortlessly with an easy-to-use interface.

## -> Key Features <-
</div>
## Installation 🚀

To get started with BlogLog, follow these steps:

1. **Clone the Repository**:
```bash
git clone https://github.com/yourusername/bloglog.git
cd bloglog
```

2. **Install Dependencies**:
```bash
npm install
```

3. Set Up Environment Variables:

Create a `.env` file in the root directory and add the following line:
```bash
MONGODB_URI=mongodb://localhost:27017/bloglog
```

4. Start the Server:
```bash
npm start
```

- **Create** new blog posts.
- **Read** and view individual blog posts.
- **Update** existing blog posts.
- **Delete** blog posts.
- **Responsive design** for a seamless experience on any device.
- **User-friendly interface** for easy navigation and interaction.
The application will be available at `http://localhost:5000` 🌐

## Installation
## Usage 🛠️
After starting the server, open your browser and navigate to `http://localhost:5000`. From there, you can create, view, update, and delete your blog posts.

1. **Clone the repository:**
## Contributing 🤝
We welcome contributions! Here’s how you can contribute:

```bash
git clone https://github.com/yourusername/bloglog.git
cd bloglog
```
1. **Fork the Repository**: Create a personal copy of the repository on your GitHub account.

2. **Install dependencies:**
2. **Create Your Branch**: Develop your feature or fix.
```bash
git checkout -b feature/YourFeatureName
```

```bash
npm install
```
3. **Commit Your Changes**: Make sure to write meaningful commit messages.
```bash
git commit -m "Add some feature"
```

3. **Set up environment variables:**
4. **Open a Pull Request**: Push your changes to your fork and submit a pull request.

Create a `.env` file in the root directory and add the following:
5. Add Detailed Descriptions: Include any relevant information and screenshots if applicable.

```env
MONGODB_URI=mongodb://localhost:27017/bloglog
```

4. **Start the server:**
## License 📜
This project is licensed under the [MIT License](LICENSE)

## Acknowledgments 🙌

- Thanks to the open-source community for their valuable resources.
- Special thanks to the contributors who have made this project better.


## Our Contributors 👀

- We extend our heartfelt gratitude for your invaluable contribution to our project! Your efforts play a pivotal role in elevating Ratna-Supermarket to greater heights.
- Make sure you show some love by giving ⭐ to our repository.

<div>

<a href="https://github.com/jinx-vi-0/BlogLog">
<img src="https://contrib.rocks/image?repo=jinx-vi-0/BlogLog&&max=1000" />
</a>
</div>

```bash
npm start
```
## Give it a Star! ⭐
#### If you enjoy BlogLog, give this repository a star! ⭐

The application will be available at `http://localhost:5000`.
### Enjoy using BlogLog, and happy blogging! 🌈
93 changes: 69 additions & 24 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,95 @@
require('dotenv').config();
require("dotenv").config();

const express = require('express');
const expressLayout = require('express-ejs-layouts');
const methodOverride = require('method-override');
const cookieParser = require('cookie-parser');
const session = require('express-session');
const MongoStore = require('connect-mongo');
const express = require("express");
const expressLayout = require("express-ejs-layouts");
const methodOverride = require("method-override");
const cookieParser = require("cookie-parser");
const session = require("express-session");
const MongoStore = require("connect-mongo");
const rfs = require("rotating-file-stream");
const passport = require('passport'); // Added passport for authentication
const flash = require('connect-flash'); // Added flash for storing flash messages

const connectDB = require('./server/config/db');
const { isActiveRoute } = require('./server/helpers/routeHelpers');
const connectDB = require("./server/config/db");
const { isActiveRoute } = require("./server/helpers/routeHelpers");
const morgan = require("morgan");

// Passport configuration
require('./server/config/passport')(passport); // Passport config to be created separately

const app = express();
const PORT = process.env.PORT || 5000;


const accessLogStream = rfs.createStream("application.log", {
interval: "1d",
path: "./logs",
});

app.use(morgan("combined", { stream: accessLogStream }));

// Connect to DB

app.use(session({
secret: 'your_secret_key', // Change this to your secret key
resave: false,
saveUninitialized: true,
}));

app.use(flash());


// Connect to MongoDB
connectDB();

// Middleware setup
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use(cookieParser());
app.use(methodOverride('_method'));
app.use(morgan("dev"));
app.use(methodOverride("_method"));

app.use(session({
secret: 'keyboard cat',
resave: false,
saveUninitialized: true,
store: MongoStore.create({
mongoUrl: process.env.MONGODB_URI
}),
//cookie: { maxAge: new Date ( Date.now() + (3600000) ) }
}));
// Session setup for storing user session data
app.use(
session({
secret: process.env.SESSION_SECRET || "keyboard cat", // Use SESSION_SECRET from .env
resave: false,
saveUninitialized: true,
store: MongoStore.create({
mongoUrl: process.env.MONGODB_URI, // Use MongoDB Atlas URI from .env
}),
// cookie: { maxAge: new Date(Date.now() + 3600000) }// Uncomment if you want custom cookie expiry time
})
);

app.use(express.static('public'));
// Passport middleware
app.use(passport.initialize());
app.use(passport.session()); // Persist user sessions


// Global variables for flash messages
app.use((req, res, next) => {
res.locals.success_msg = req.flash('success_msg');
res.locals.error_msg = req.flash('error_msg');
res.locals.error = req.flash('error'); // Error messages from Passport
next();
});

// Static files
app.use(express.static("public"));

// Templating Engine
app.use(expressLayout);
app.set('layout', './layouts/main');
app.set('view engine', 'ejs');


// Helper for active route
app.locals.isActiveRoute = isActiveRoute;


// Routes
app.use('/', require('./server/routes/main'));
app.use('/', require('./server/routes/admin'));

app.listen(PORT, ()=> {
// Start the server
app.listen(PORT, () => {
console.log(`App listening on port ${PORT}`);
});
4 changes: 4 additions & 0 deletions example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MONGODB_URI=mongodb://localhost:27017/bloglog
EMAIL_USERNAME=test
EMAIL_APP_PASSWORD=test@123
JWT_SECRET= <- your jwt secret key ->
Loading

0 comments on commit 51aa41e

Please sign in to comment.