Skip to content

Commit

Permalink
Merge pull request #399 from VigneshDevHub/test
Browse files Browse the repository at this point in the history
Merging changes from test to main
  • Loading branch information
Vignesh025 authored Nov 8, 2024
2 parents ba7c4c9 + afceef9 commit a1e8fac
Show file tree
Hide file tree
Showing 7 changed files with 475 additions and 148 deletions.
27 changes: 27 additions & 0 deletions controllers/campgrounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ module.exports = {
*/
createCampground: async (req, res, next) => {
try {
// Preven the largest input
if(req.body.campground.description.length >= 1000 && req.body.campground.title.length >= 70){
req.flash("error", "Description & title must be within 1000 & 70 character respectively!");
return res.redirect("campgrounds/new");
}
if(req.body.campground.title.length >= 70){
req.flash("error", "Title must be within 70 character!");
return res.redirect("campgrounds/new");
}
if(req.body.campground.description.length >= 1000){
req.flash("error", "Description must be within 1000 character!");
return res.redirect("campgrounds/new");
}

// Geocode the campground location
const geoData = await geocoder.forwardGeocode({
query: req.body.campground.location,
Expand Down Expand Up @@ -172,6 +186,19 @@ module.exports = {
updateCampground: async (req, res) => {
const { id } = req.params;

if(req.body.campground.description.length >= 1000 && req.body.campground.title.length >= 70){
req.flash("error", "Description & title must be within 1000 & 70 character respectively!");
return res.redirect(`/campgrounds/${id}/edit`);
}
if(req.body.campground.title.length >= 70){
req.flash("error", "Title must be within 70 character!");
return res.redirect(`/campgrounds/${id}/edit`);
}
if(req.body.campground.description.length >= 1000){
req.flash("error", "Description must be within 1000 character!");
return res.redirect(`/campgrounds/${id}/edit`);
}

// Geocode the new location for the campground
const geoData = await geocoder.forwardGeocode({
query: req.body.campground.location,
Expand Down
6 changes: 6 additions & 0 deletions controllers/reviews.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ module.exports.createReview = async (req, res) => {
return res.redirect(`/campgrounds/${campground._id}`);
}

// Prevent form submission if review body is gretter than 1000 charecter
if(req.body.review.body.length >= 1000){
req.flash("error", "Review must be within 1000 character!");
return res.redirect(`/campgrounds/${campground._id}`);
}

// Create a new review using the data from the request body
const review = new Review(req.body.review);
review.author = req.user._id; // Set the review's author to the current user
Expand Down
15 changes: 14 additions & 1 deletion public/stylesheets/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,20 @@ html {
.to-top{
right:20px;
}
}.mapboxgl-popup-content{
}

.review-popup{
background-color: rgb(33, 37, 41);
color: #fff;
}
.review-popup .popup-comment{
opacity: 0.7;
margin-top: 0 !important;
}
.review-popup .user-credential .user5{
height: 2rem;
}
.mapboxgl-popup-content{
color: black !important;
text-align: center;
}
Expand Down
228 changes: 228 additions & 0 deletions public/stylesheets/campgroundPage.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
/* searchCampground.css */

/* Main Container Styles */
.campground-search-controls {
background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.7));
padding: 30px 20px;
border-radius: 15px;
margin-bottom: 30px;
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
gap: 20px;
}

/* Search Form Styles */
.campground-search-form {
flex: 1;
min-width: 300px;
}

.campground-input-group {
background: rgba(255, 255, 255, 0.1);
border-radius: 12px;
overflow: hidden;
border: 1px solid rgba(255, 255, 255, 0.2);
display: flex;
}

.campground-search-input {
background: transparent;
border: none;
color: white;
padding: 12px 20px;
font-size: 1rem;
flex: 1;
}

.campground-search-input::placeholder {
color: rgba(255, 255, 255, 0.7);
}

.campground-search-button {
padding: 12px 25px;
background: #00b4d8;
border: none;
color: white;
font-weight: 500;
transition: all 0.2s ease;
}

.campground-search-button:hover {
background: #0096c7;
}

/* Sort Controls Styles */
.campground-sort-controls {
display: flex;
gap: 15px;
align-items: center;
}

.campground-nearest-btn {
padding: 12px 25px;
background: #2a9d8f;
border: none;
color: white;
border-radius: 12px;
transition: all 0.2s ease;
}

.campground-nearest-btn:hover {
background: #264653;
transform: translateY(-2px);
}

.campground-sort-select {
background-color: #212529;
color: #fff;
border: 1px solid #495057;
padding: 0.375rem 0.75rem;
border-radius: 0.25rem;
}

.campground-sort-select option {
background-color: #212529;
color: #fff;
}

.campground-sort-select:focus {
outline: none;
border-color: #86b7fe;
box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.campground-sort-button {
padding: 12px 25px;
background: #4361ee;
color: white;
border: none;
border-radius: 12px;
transition: all 0.2s ease;
}

.campground-sort-button:hover {
background: #3949ab;
}

/* Grid Layout */
.campground-listing-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 25px;
padding: 20px 0;
}

/* Card Styles */
.campground-card {
background: #1e2124;
border-radius: 15px;
overflow: hidden;
transition: transform 0.2s ease, box-shadow 0.2s ease;
border: 1px solid rgba(255, 255, 255, 0.1);
}

.campground-card:hover {
transform: translateY(-5px);
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.campground-image-container {
position: relative;
padding-top: 66.67%;
overflow: hidden;
}

.campground-image {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
transition: transform 0.3s ease;
}

.campground-card:hover .campground-image {
transform: scale(1.05);
}

.campground-content {
padding: 1.5rem;
}

.campground-title {
font-size: 1.25rem;
font-weight: 600;
color: white;
margin-bottom: 0.75rem;
}

.campground-description {
color: #a8a8a8;
margin-bottom: 1rem;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
}

.campground-price {
color: white;
}

.campground-location {
color: #6c757d;
font-size: 0.9rem;
margin-bottom: 1rem;
display: flex;
align-items: center;
}

.campground-view-button {
width: 100%;
padding: 10px;
background: #0d6efd;
color: white;
border: none;
border-radius: 8px;
transition: all 0.2s ease;
text-align: center;
text-decoration: none;
display: block;
}

.campground-view-button:hover {
background: #0b5ed7;
transform: translateY(-2px);
}

/* Responsive Design */
@media (max-width: 1200px) {
.campground-listing-grid {
grid-template-columns: repeat(2, 1fr);
}
}

@media (max-width: 768px) {
.campground-search-controls {
flex-direction: column;
}

.campground-sort-controls {
width: 100%;
flex-direction: column;
}

.campground-listing-grid {
grid-template-columns: 1fr;
padding: 10px;
}

.campground-nearest-btn,
.campground-sort-select,
.campground-sort-button {
width: 100%;
}
}
Loading

0 comments on commit a1e8fac

Please sign in to comment.