From 73a39bcd0aba23b3c851511503fb7498cf20999e Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Thu, 10 Oct 2019 17:39:13 +0200 Subject: [PATCH 1/5] control Google Analytics ID with ENV variable --- app/views/layout.ejs | 4 ++-- development.env | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/views/layout.ejs b/app/views/layout.ejs index 166cb66..d256919 100644 --- a/app/views/layout.ejs +++ b/app/views/layout.ejs @@ -2,12 +2,12 @@ - + diff --git a/development.env b/development.env index 94d8549..0221eaf 100644 --- a/development.env +++ b/development.env @@ -11,17 +11,18 @@ APP_BASE_URL=base url for the app MAX_REAL_ESTATES_IN_EMAIL=Max number of real estates that will be shown in email, others will be truncated and URL with full list will be shwon MAX_REAL_ESTATES_IN_FIRST_EMAIL=Max number of real estates that will be shown in first (welcome) email +#=============== GOOGLE ANALYTICS =============# +GA_ID=Google Analytics ID + +#=============== AWS SDK EMAIL SETTINGS =======# AWS_KEY_ID=(your-key-here) AWS_SECRET_ACCESS_KEY=(your-key-here) AWS_REGION=eu-west-1 - -APP_URL=http://localhost:3001 SOURCE_EMAIL=info@saburly.com +#=============== CRAWLER SETTINGS===============# CRAWLER_INTERVAL=Interval to run cralwer(s), in seconds STOP_CRAWLER=Non-zero value will skip crawler execution - -#=============== CRAWLER SETTINGS===============# #==OLX== OLX_MAX_PAGES=Restrict crawler to this number of pages OLX_MAX_RESULTS_PER_PAGE=Only this number or less results from one page will be scraped and saved -- 2.47.3 From ef3d97612ba66e74cdafc1fc9410435b7e3f0a6d Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Thu, 10 Oct 2019 19:50:44 +0200 Subject: [PATCH 2/5] remove .idea directory --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 713d500..b24fc61 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/ .env +.idea/ -- 2.47.3 From 3251aca4e745b01bcb1c94cf991569107437b71a Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Fri, 11 Oct 2019 15:37:47 +0200 Subject: [PATCH 3/5] move all filters to one page --- app/common/enums.js | 62 +++++++++++++++++++- app/controllers/gardenSizes.js | 48 ---------------- app/controllers/location.js | 2 +- app/controllers/prices.js | 43 -------------- app/controllers/queryReview.js | 6 +- app/controllers/realEstateFilters.js | 83 +++++++++++++++++++++++++++ app/controllers/sizes.js | 47 --------------- app/routes/index.js | 14 +---- app/views/gardenSize.ejs | 1 - app/views/price.ejs | 1 - app/views/realEstateFilters.ejs | 86 ++++++++++++++++++++++++++++ app/views/size.ejs | 1 - 12 files changed, 235 insertions(+), 159 deletions(-) delete mode 100644 app/controllers/gardenSizes.js delete mode 100644 app/controllers/prices.js create mode 100644 app/controllers/realEstateFilters.js delete mode 100644 app/controllers/sizes.js delete mode 100644 app/views/gardenSize.ejs delete mode 100644 app/views/price.ejs create mode 100644 app/views/realEstateFilters.ejs delete mode 100644 app/views/size.ejs diff --git a/app/common/enums.js b/app/common/enums.js index b488b21..2616002 100644 --- a/app/common/enums.js +++ b/app/common/enums.js @@ -1,14 +1,70 @@ +const PRICE_SLIDER_OPTIONS = { + start: [30000, 70000], + range: { + min: [0, 1000], + "10%": [20000, 1000], + "35%": [100000, 1000], + "70%": [200000, 10000], + max: [1000000] + }, + connect: true, + tooltips: true +}; + +//This will be used for Flats, Apartments, Houses +const HOME_SIZE_SLIDER_OPTIONS = { + start: [20, 75], + range: { + min: [0, 5], + "50%": [100, 10], + max: [400] + }, + connect: true, + tooltips: true +}; + +const GARDEN_SIZE_SLIDER_OPTIONS = { + start: [100, 1000], + range: { + min: [0, 10], + "40%": [1000, 100], + "80%": [10000, 100], + max: [100000] + }, + connect: true, + tooltips: true +}; + const AD_TYPE = { AD_TYPE_SALE: "SALE", AD_TYPE_RENT: "RENT" }; const AD_CATEGORY = { - FLAT: { id: "FLAT", title: "Stan", hasGardenSize: false }, - HOUSE: { id: "HOUSE", title: "Kuća", hasGardenSize: true }, + FLAT: { + id: "FLAT", + title: "Stan", + hasGardenSize: false, + priceSliderOptions: PRICE_SLIDER_OPTIONS, + sizeSliderOptions: HOME_SIZE_SLIDER_OPTIONS + }, + HOUSE: { + id: "HOUSE", + title: "Kuća", + hasGardenSize: true, + priceSliderOptions: PRICE_SLIDER_OPTIONS, + sizeSliderOptions: HOME_SIZE_SLIDER_OPTIONS, + gardenSizeSliderOptions: GARDEN_SIZE_SLIDER_OPTIONS + }, //OFFICE: { id: "OFFICE", title: "Kancelarija", hasGardenSize: false }, //LAND: { id: "LAND", title: "Zemljište", hasGardenSize: true }, - APARTMENT: { id: "APARTMENT", title: "Apartman", hasGardenSize: false } + APARTMENT: { + id: "APARTMENT", + title: "Apartman", + hasGardenSize: false, + priceSliderOptions: PRICE_SLIDER_OPTIONS, + sizeSliderOptions: HOME_SIZE_SLIDER_OPTIONS + } //GARAGE: { id: "GARAGE", title: "Garaža", hasGardenSize: false }, //COTTAGE: { id: "COTTAGE", title: "Vikendica", hasGardenSize: true } }; diff --git a/app/controllers/gardenSizes.js b/app/controllers/gardenSizes.js deleted file mode 100644 index 221e5a0..0000000 --- a/app/controllers/gardenSizes.js +++ /dev/null @@ -1,48 +0,0 @@ -const { currentSearchRequest } = require("../helpers/url"); -const { AD_CATEGORY } = require("../common/enums"); - -const getGardenSize = (req, res) => { - const title = "Koliko okućnice tražite ?"; - - const unit = " m2"; - const rangeFrom = { - min: 10, - max: 3000, - value: 0, - step: 10 - }; - - const rangeTo = { - min: 10, - max: 3000, - value: 100, - step: 10 - }; - - res.render("gardenSize", { rangeFrom, rangeTo, unit, title }); -}; - -const postGardenSize = async (req, res) => { - const searchRequest = await currentSearchRequest(req); - - const nextStepPage = req.query.nextStep || "cijena"; - const nextStepUrl = `/${nextStepPage}/${searchRequest.id}`; - - const realEstateType = AD_CATEGORY[searchRequest.realEstateType]; - if (realEstateType && realEstateType.hasGardenSize) { - const gardenSizeMin = req.body.from || 0; - const gardenSizeMax = req.body.to || 0; - //TODO: Validate input - - searchRequest.gardenSizeMin = gardenSizeMin; - searchRequest.gardenSizeMax = gardenSizeMax; - await searchRequest.save(); - } - - res.redirect(nextStepUrl); -}; - -module.exports = { - getGardenSize, - postGardenSize -}; diff --git a/app/controllers/location.js b/app/controllers/location.js index 02076db..43f6c29 100644 --- a/app/controllers/location.js +++ b/app/controllers/location.js @@ -40,7 +40,7 @@ const postLocation = async (req, res) => { await searchRequest.save(); - const nextStepPage = req.query.nextStep || "povrsina"; + const nextStepPage = req.query.nextStep || "filteri"; const nextStepUrl = `/${nextStepPage}/${searchRequest.id}`; res.redirect(nextStepUrl); diff --git a/app/controllers/prices.js b/app/controllers/prices.js deleted file mode 100644 index 91ae0ae..0000000 --- a/app/controllers/prices.js +++ /dev/null @@ -1,43 +0,0 @@ -const { currentSearchRequest } = require("../helpers/url"); - -const getPrice = (req, res) => { - const title = "Koja Vam okvirna cijena odgovara ?"; - - const unit = " KM"; - const rangeFrom = { - min: 1000, - max: 250000, - value: 0, - step: 1000 - }; - - const rangeTo = { - min: 1000, - max: 250000, - value: 50000, - step: 1000 - }; - - res.render("price", { rangeFrom, rangeTo, unit, title }); -}; - -const postPrice = async (req, res) => { - const searchRequest = await currentSearchRequest(req); - - const nextStepPage = req.query.nextStep || "pregled"; - const nextStepUrl = `/${nextStepPage}/${searchRequest.id}`; - const priceMin = req.body.from || 0; - const priceMax = req.body.to || 0; - //TODO: price validation - - searchRequest.priceMin = priceMin; - searchRequest.priceMax = priceMax; - await searchRequest.save(); - - res.redirect(nextStepUrl); -}; - -module.exports = { - getPrice, - postPrice -}; diff --git a/app/controllers/queryReview.js b/app/controllers/queryReview.js index 04dfe4f..e014065 100644 --- a/app/controllers/queryReview.js +++ b/app/controllers/queryReview.js @@ -49,17 +49,17 @@ const getQueryReviewData = searchRequest => { { id: "size", title: sizeTitle, - url: `/povrsina/${id}?nextStep=pregled` + url: `/filteri/${id}?nextStep=pregled` }, { id: "gardenSize", title: gardenSizeTitle, - url: enableGardenSizeEdit ? `/okucnica/${id}?nextStep=pregled` : "" + url: enableGardenSizeEdit ? `/filteri/${id}?nextStep=pregled` : "" }, { id: "price", title: priceTitle, - url: `/cijena/${id}?nextStep=pregled` + url: `/filteri/${id}?nextStep=pregled` } ]; }; diff --git a/app/controllers/realEstateFilters.js b/app/controllers/realEstateFilters.js new file mode 100644 index 0000000..c984c11 --- /dev/null +++ b/app/controllers/realEstateFilters.js @@ -0,0 +1,83 @@ +const { currentSearchRequest } = require("../helpers/url"); +const { AD_CATEGORY } = require("../common/enums"); + +const getFilters = async (req, res) => { + const searchRequest = await currentSearchRequest(req); + const title = "Filteri za pretraživanje"; + + const { + realEstateType, + priceMin, + priceMax, + sizeMin, + sizeMax, + gardenSizeMin, + gardenSizeMax + } = searchRequest; + const category = AD_CATEGORY[realEstateType] || AD_CATEGORY.FLAT; + + const { + hasGardenSize, + priceSliderOptions, + sizeSliderOptions, + gardenSizeSliderOptions + } = category; + + if (priceMin && priceMax) { + priceSliderOptions.start = [priceMin, priceMax]; + } + + if (sizeMin && sizeMax) { + sizeSliderOptions.start = [sizeMin, sizeMax]; + } + + if (gardenSizeSliderOptions && gardenSizeMin && gardenSizeMax) { + gardenSizeSliderOptions.start = [gardenSizeMin, gardenSizeMax]; + } + + res.render("realEstateFilters", { + title, + hasGardenSize, + priceSliderOptions: JSON.stringify(priceSliderOptions), + sizeSliderOptions: JSON.stringify(sizeSliderOptions), + gardenSizeSliderOptions: JSON.stringify(gardenSizeSliderOptions) + }); +}; + +const postFilters = async (req, res) => { + const searchRequest = await currentSearchRequest(req); + + const nextStepPage = req.query.nextStep || "pregled"; + const nextStepUrl = `/${nextStepPage}/${searchRequest.id}`; + + const priceMin = parseInt(req.body.priceFilterMin) || 0; + const priceMax = parseInt(req.body.priceFilterMax) || 0; + const sizeMin = parseInt(req.body.sizeFilterMin) || 0; + const sizeMax = parseInt(req.body.sizeFilterMax) || 0; + + //TODO: Filter validation + + searchRequest.priceMin = priceMin; + searchRequest.priceMax = priceMax; + searchRequest.sizeMin = sizeMin; + searchRequest.sizeMax = sizeMax; + + if (req.body.gardenSizeFilterMin && req.body.gardenSizeFilterMax) { + const gardenSizeMin = parseInt(req.body.gardenSizeFilterMin); + const gardenSizeMax = parseInt(req.body.gardenSizeFilterMax); + + //TODO: Filter validation + + searchRequest.gardenSizeMin = gardenSizeMin; + searchRequest.gardenSizeMax = gardenSizeMax; + } + + await searchRequest.save(); + + res.redirect(nextStepUrl); +}; + +module.exports = { + getFilters, + postFilters +}; diff --git a/app/controllers/sizes.js b/app/controllers/sizes.js deleted file mode 100644 index 288410c..0000000 --- a/app/controllers/sizes.js +++ /dev/null @@ -1,47 +0,0 @@ -const { currentSearchRequest } = require("../helpers/url"); -const { AD_CATEGORY } = require("../common/enums"); - -const getSize = (req, res) => { - const title = "Od koliko kvadrata tražite nekretninu ?"; - const unit = " m2"; - const rangeFrom = { - min: 10, - max: 250, - value: 0, - step: 10 - }; - - const rangeTo = { - min: 10, - max: 250, - value: 50, - step: 10 - }; - - res.render("size", { rangeFrom, rangeTo, unit, title }); -}; - -const postSize = async (req, res) => { - const searchRequest = await currentSearchRequest(req); - - const realEstateType = AD_CATEGORY[searchRequest.realEstateType]; - const sizeMin = req.body.from || 0; - const sizeMax = req.body.to || 0; - //TODO: Validation, check if real estate type is valid, ... - const nextStep = - realEstateType && realEstateType.hasGardenSize ? "okucnica" : "cijena"; - - const nextStepPage = req.query.nextStep || nextStep; - const nextStepUrl = `/${nextStepPage}/${searchRequest.id}`; - - searchRequest.sizeMin = sizeMin; - searchRequest.sizeMax = sizeMax; - await searchRequest.save(); - - res.redirect(nextStepUrl); -}; - -module.exports = { - getSize, - postSize -}; diff --git a/app/routes/index.js b/app/routes/index.js index 807f594..61e67f7 100644 --- a/app/routes/index.js +++ b/app/routes/index.js @@ -7,9 +7,6 @@ const { getRealEstateTypes, postRealEstateTypes } = require("../controllers/realEstateTypes"); -const { getSize, postSize } = require("../controllers/sizes"); -const { getGardenSize, postGardenSize } = require("../controllers/gardenSizes"); -const { getPrice, postPrice } = require("../controllers/prices"); const { getQueryReview, postQueryReview @@ -19,6 +16,7 @@ const { getLocation, postLocation } = require("../controllers/location"); const { getUnsubscribe } = require("../controllers/unsubscribe"); const { getRealEstates } = require("../controllers/realEstates"); const { getRedirect } = require("../controllers/redirect"); +const { getFilters, postFilters } = require("../controllers/realEstateFilters"); const router = express.Router(); @@ -32,14 +30,8 @@ router.post("/vrstanekretnine", postRealEstateTypes); router.get("/lokacija/:searchRequestId", getLocation); router.post("/lokacija/:searchRequestId", postLocation); -router.get("/povrsina/:searchRequestId", getSize); -router.post("/povrsina/:searchRequestId", postSize); - -router.get("/okucnica/:searchRequestId", getGardenSize); -router.post("/okucnica/:searchRequestId", postGardenSize); - -router.get("/cijena/:searchRequestId", getPrice); -router.post("/cijena/:searchRequestId", postPrice); +router.get("/filteri/:searchRequestId", getFilters); +router.post("/filteri/:searchRequestId", postFilters); router.get("/pregled/:searchRequestId", getQueryReview); router.post("/pregled/:searchRequestId", postQueryReview); diff --git a/app/views/gardenSize.ejs b/app/views/gardenSize.ejs deleted file mode 100644 index ce68925..0000000 --- a/app/views/gardenSize.ejs +++ /dev/null @@ -1 +0,0 @@ -<% include partials/range %> diff --git a/app/views/price.ejs b/app/views/price.ejs deleted file mode 100644 index ce68925..0000000 --- a/app/views/price.ejs +++ /dev/null @@ -1 +0,0 @@ -<% include partials/range %> diff --git a/app/views/realEstateFilters.ejs b/app/views/realEstateFilters.ejs new file mode 100644 index 0000000..ad12b7e --- /dev/null +++ b/app/views/realEstateFilters.ejs @@ -0,0 +1,86 @@ +
+
+ +
+
Cijena
+

+
+ + +
+ +

+ +
+
Površina
+

+
+ + +
+ +

+ + <% if(hasGardenSize) { %> +
+
Površina okućnice
+

+
+ + +
+ +

+ <% } %> + +
+
+ Dalje +
+
+
+ + diff --git a/app/views/size.ejs b/app/views/size.ejs deleted file mode 100644 index ce68925..0000000 --- a/app/views/size.ejs +++ /dev/null @@ -1 +0,0 @@ -<% include partials/range %> -- 2.47.3 From 164510c8fc9372727bfce38b6b5e602f6c8898a4 Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Fri, 11 Oct 2019 15:45:29 +0200 Subject: [PATCH 4/5] fix next button width --- app/views/location.ejs | 9 ++++++--- app/views/welcome.ejs | 10 ++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/views/location.ejs b/app/views/location.ejs index cceff60..672eb3b 100644 --- a/app/views/location.ejs +++ b/app/views/location.ejs @@ -2,6 +2,7 @@ Područje na mapi će biti uključeno u pretragu. Namjestite mapu na ulice koje želite da budu vidljive. +
@@ -10,13 +11,15 @@ gps_fixed
+
-
- + +
+
@@ -30,6 +33,7 @@ + -
diff --git a/app/views/welcome.ejs b/app/views/welcome.ejs index 5853b9d..e1ad1ac 100644 --- a/app/views/welcome.ejs +++ b/app/views/welcome.ejs @@ -7,10 +7,8 @@
Na vaš email.
BESPLATNO
-
- +
+
+ Javi mi +
-- 2.47.3 From 1dbe1da802537b78529131d521f1380ab416671e Mon Sep 17 00:00:00 2001 From: Bilal Catic Date: Fri, 11 Oct 2019 15:45:50 +0200 Subject: [PATCH 5/5] fix default range filter values --- app/common/enums.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/common/enums.js b/app/common/enums.js index 2616002..d17ed0f 100644 --- a/app/common/enums.js +++ b/app/common/enums.js @@ -1,5 +1,5 @@ const PRICE_SLIDER_OPTIONS = { - start: [30000, 70000], + start: [50000, 85000], range: { min: [0, 1000], "10%": [20000, 1000], @@ -13,7 +13,7 @@ const PRICE_SLIDER_OPTIONS = { //This will be used for Flats, Apartments, Houses const HOME_SIZE_SLIDER_OPTIONS = { - start: [20, 75], + start: [30, 75], range: { min: [0, 5], "50%": [100, 10], -- 2.47.3