Compare commits

..

No commits in common. "master" and "v0.0.1" have entirely different histories.

27 changed files with 4626 additions and 4342 deletions

3
.gitignore vendored
View file

@ -243,6 +243,3 @@ temp/
# .pnp.*
# End of https://www.toptal.com/developers/gitignore/api/node,phpunit,symfony,composer,yarn
# Snyk
.dccache

45
Jenkinsfile vendored
View file

@ -2,39 +2,36 @@ node {
def app
stage('Clone repository') {
// Let's make sure we have the repository cloned to our workspace
/* Let's make sure we have the repository cloned to our workspace */
checkout scm
}
stage('Install dependencies') {
// Install dependencies for build later
sh 'composer update'
sh 'yarn install'
stage('Build image') {
/* This builds the actual image; synonymous to
* docker build on the command line */
app = docker.build("thisfro/plantex")
}
stage('Composer Vulnr test') {
snykSecurity(
snykInstallation: 'snyk-local',
targetFile: 'composer.lock',
)
stage('Test image') {
/* Ideally, we would run a test framework against our image.
* For this example, we're using a Volkswagen-type approach ;-) */
app.inside {
// php 'bin/phpunit'
sh 'echo "success"'
}
}
stage('npm vulnr test') {
snykSecurity(
snykInstallation: 'snyk-local',
targetFile: 'package.json',
)
stage('Push image') {
docker.withRegistry('https://hub.thisfro.ch') {
app.push("$BUILD_NUMBER")
app.push('latest')
}
}
stage('Deploy staging') {
// Deploy to staging host
sh 'vendor/bin/dep deploy lq5xi.ftp.infomaniak.com --no-interaction'
sh 'cd /opt/containers/pflaenz.li && docker-compose pull && docker-compose up -d'
}
/*
stage('Test staging') {
// Run phpunit tests on staging host
bin/phpunit COMMAND
}
*/
}

View file

@ -1,14 +1,11 @@
# Pflänz.li
# plant-exchange
## Idea
A platform where people can trade their plants. You can post what you have and search for others with [filters](#filters). The aim is to make it easier to trade plants and collect as few data as possible. Only the email/username and a postal code is required.
A platform where people can exchange plants. They can post what they have and search for others with [filters](#filters).
## Tech stack
- [Symfony](https://symfony.com/)
- [MariaDB](https://www.mariadb.org)
- [Deployer](https://deployer.org)
Can easily be depoyed to a LAMP server
## Admin dashboard
Find it under `/admin`
@ -17,11 +14,8 @@ Find it under `/admin`
### Implemented
- Distance between postal codes
- Search within title
### Ideas
It would be nice to have categories somehow, but it would be hard to make it comprehensive.
:warning: This list is work in progress!
Searching with filters such as:

View file

@ -8,6 +8,7 @@
// any CSS you import will output into a single css file (app.css in this case)
import './styles/app.scss';
const $ = require('jquery');
// start the Stimulus application
require('bootstrap');
@ -17,32 +18,27 @@ import '@fortawesome/fontawesome-free/js/solid'
import '@fortawesome/fontawesome-free/js/regular'
import '@fortawesome/fontawesome-free/js/brands'
// Friendly captcha
import { WidgetInstance } from 'friendly-challenge';
function doneCallback(solution) {
$('#registration_form_captcha_solution').val(solution);
}
const element = document.querySelector('#captcha');
const options = {
doneCallback: doneCallback,
sitekey: 'FCMVL79DP1G5K1K0',
}
const widget = new WidgetInstance(element, options);
widget.start()
// Dsiplay Filename when uploading
document.querySelector('.custom-file-input').addEventListener('change', function (e) {
var fileName = document.getElementById('offer_form_photo').files[0].name;
var nextSibling = e.target.nextElementSibling
nextSibling.innerText = fileName
})
// Cookie-consent
import 'cookie-notice/dist/cookie.notice.min';
new cookieNoticeJS({
// Position for the cookie-notifier (default=bottom)
'cookieNoticePosition': 'bottom',
// The message will be shown again in X days
'expiresIn': 365,
// Specify a custom font family and size in pixels
'fontFamily': 'inherit',
'fontSize': '.9rem',
// Dismiss button background color
'buttonBgColor': '#343a40',
// Dismiss button text color
'buttonTextColor': '#fff',
// Notice background color
'noticeBgColor': '#000',
// Notice text color
'noticeTextColor': '#fff',
// Print debug output to the console (default=false)
'debug': false
});
import 'cookie-notice/dist/cookie.notice.min.js'

View file

@ -1,15 +0,0 @@
// Friendly captcha
import { WidgetInstance } from 'friendly-challenge';
const $ = require('jquery');
function doneCallback(solution) {
$('#registration_form_captcha_solution').val(solution);
}
const element = document.querySelector('#captcha');
const options = {
doneCallback: doneCallback,
sitekey: 'FCMVL79DP1G5K1K0',
}
const widget = new WidgetInstance(element, options);
widget.start()

View file

@ -1,5 +0,0 @@
const $ = require('jquery');
$( ".custom-file-input" ).change(function() {
$(".custom-file-label").html(($(".custom-file-input").prop("files")[0]["name"]));
});

View file

@ -8,7 +8,6 @@
"ext-ctype": "*",
"ext-iconv": "*",
"composer/package-versions-deprecated": "1.11.99.1",
"deployer/deployer": "^7.0",
"doctrine/doctrine-bundle": "^2.3",
"doctrine/doctrine-migrations-bundle": "^3.1",
"doctrine/orm": "^2.8",
@ -18,26 +17,26 @@
"presta/sitemap-bundle": "^3.2",
"samayo/bulletproof": "4.0.1",
"sensio/framework-extra-bundle": "^6.1",
"symfony/asset": "^5.4.20",
"symfony/console": "^5.4.20",
"symfony/dotenv": "^5.4.20",
"symfony/filesystem": "^5.4.20",
"symfony/asset": "5.4.*",
"symfony/console": "5.4.*",
"symfony/dotenv": "5.4.*",
"symfony/filesystem": "5.4.*",
"symfony/flex": "^1.3.1",
"symfony/form": "^5.4.20",
"symfony/framework-bundle": "^5.4.20",
"symfony/mailer": "^5.4.20",
"symfony/form": "5.4.*",
"symfony/framework-bundle": "5.4.*",
"symfony/mailer": "5.4.*",
"symfony/monolog-bundle": "^3.7",
"symfony/proxy-manager-bridge": "^5.4.20",
"symfony/security-bundle": "^5.4.20",
"symfony/twig-bundle": "^5.4.20",
"symfony/validator": "^5.4.20",
"symfony/proxy-manager-bridge": "5.4.*",
"symfony/security-bundle": "5.4.*",
"symfony/twig-bundle": "5.4.*",
"symfony/validator": "5.4.*",
"symfony/webpack-encore-bundle": "^1.11",
"symfony/yaml": "^5.4.20",
"symfony/yaml": "5.4.*",
"symfonycasts/reset-password-bundle": "^1.7",
"symfonycasts/verify-email-bundle": "^1.4",
"twig/extra-bundle": "^2.12|^3.0",
"twig/intl-extra": "^3.3",
"twig/twig": "^3.4.3"
"twig/twig": "^2.12|^3.0"
},
"config": {
"optimize-autoloader": true,
@ -83,10 +82,11 @@
"extra": {
"symfony": {
"allow-contrib": false,
"require": "^5.4.20"
"require": "5.4.*"
}
},
"require-dev": {
"deployer/dist": "^6.8",
"symfony/browser-kit": "^5.4",
"symfony/css-selector": "^5.4",
"symfony/debug-bundle": "^5.4",

1894
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,10 +1,10 @@
<?php
namespace Deployer;
require 'recipe/symfony.php';
require 'recipe/symfony4.php';
// Project name
set('application', 'pflaenz.li');
set('application', 'beta.pflaenz.li');
// Project repository
set('repository', 'ssh://git@git.thisfro.ch:222/thisfro/pflaenz.li.git');
@ -13,11 +13,11 @@ set('repository', 'ssh://git@git.thisfro.ch:222/thisfro/pflaenz.li.git');
set('git_tty', true);
set('bin/php', function() {
return '/opt/php8.2/bin/php';
return '/opt/php8.0/bin/php';
});
set('bin/composer', function() {
return '/opt/php8.2/bin/composer2';
return '/opt/php8.0/bin/composer2';
});
// Shared files/dirs between deploys
@ -28,14 +28,14 @@ add('shared_dirs', ['public/uploads']);
add('writable_dirs', []);
// Set composer options
set('composer_options', '--verbose --prefer-dist --no-progress --no-interaction --optimize-autoloader --no-scripts');
set('composer_options', '{{composer_action}} --verbose --prefer-dist --no-progress --no-interaction --optimize-autoloader --no-scripts --no-dev');
// Hosts
host('lq5xi.ftp.infomaniak.com')
->set('remote_user', 'lq5xi_thisfro')
->set('deploy_path', '~/sites/{{stage}}.{{application}}')
host('beta.xn--pflnz-ira.li')
->user('lq5xi_thisfro')
->set('deploy_path', '~/sites/{{application}}')
->set('http_user', 'uid153060')
->set('stage', 'beta');
->stage('beta');
// Tasks
@ -45,9 +45,9 @@ task('upload:build', function() {
// Build yarn locally
task('deploy:build:assets', function (): void {
runLocally('yarn install');
runLocally('yarn encore production');
})->desc('Install front-end assets');
run('yarn install');
run('yarn encore production');
})->local()->desc('Install front-end assets');
before('deploy:symlink', 'deploy:build:assets');

6691
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -19,12 +19,11 @@
"dev-server": "encore dev-server",
"dev": "encore dev",
"watch": "encore dev --watch",
"build": "encore production --progress",
"test": "snyk test"
"build": "encore production --progress"
},
"dependencies": {
"@snyk/protect": "^1.834.0",
"cookie-notice": "^1.3.6",
"friendly-challenge": "^0.8.5"
"friendly-challenge": "^0.8.5",
"snyk": "^1.806.0"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6 KiB

View file

@ -18,7 +18,5 @@ if ($_SERVER['APP_DEBUG']) {
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->headers->set('X-Frame-Options', 'DENY');
$response->headers->set('X-Content-Type-Options', 'nosniff');
$response->send();
$kernel->terminate($request, $response);

View file

@ -33,21 +33,15 @@ class OfferController extends AbstractController
}
#[Route('/offers', name: 'offers', options: ["sitemap" => true])]
public function showAll(Request $request, OfferRepository $offerRepository, PlzToCoordinate $plzconverter, DistanceCalculator $distanceCalculator): Response
public function showAll(Environment $twig, Request $request, OfferRepository $offerRepository, PlzToCoordinate $plzconverter, DistanceCalculator $distanceCalculator): Response
{
$form = $this->createForm(OfferFilterFormType::class);
$form->handleRequest($request);
$allOffers = $offerRepository->findAll();
$filteredOffers = [];
if ($form->isSubmitted() && $form->isValid() && $form->get('search')->getData() != null) {
$allOffers = $offerRepository->findBySearchLiteral($form->get('search')->getData());
}
else {
$allOffers = $offerRepository->findAll();
}
if ($form->isSubmitted() && $form->isValid() && $form->get('distance')->getData() != null && $form->get('zipCode')->getData() != null) {
if ($form->isSubmitted() && $form->isValid()) {
$filterDistance = $form->get('distance')->getData();
$filterPlz = $form->get('zipCode')->getData();
$filterCoordinate = $plzconverter->convertPlzToCoordinate($filterPlz);
@ -150,7 +144,7 @@ class OfferController extends AbstractController
}
#[Route('/offer/edit/{urlId}', name: 'edit_offer')]
public function editOffer(Offer $offer, Request $request, string $photoDir, OfferPhotoHelper $offerPhotoHelper): Response
public function editOffer(Offer $offer, OfferRepository $offerRepository, Request $request, string $photoDir, OfferPhotoHelper $offerPhotoHelper): Response
{
$form = $this->createForm(OfferFormType::class, $offer);
$user = $this->getUser();
@ -170,10 +164,6 @@ class OfferController extends AbstractController
$this->entityManager->persist($offer);
$this->entityManager->flush();
$this->addFlash("success", "Successfully updated the offer!");
return $this->redirectToRoute('show_offer', ['urlId' => $offer->getUrlId()]);
}
return $this->render('offer/edit.html.twig', [
@ -219,14 +209,4 @@ class OfferController extends AbstractController
'offers' => $offerRepository->findByUser($user),
]);
}
#[Route('/offers/search', name: 'search', options: ["sitemap" => false])]
public function search(OfferRepository $offerRepository): Response
{
$offers = $offerRepository->findBySearchLiteral('');
return $this->render('offer/search.html.twig', [
'offers' => $offers,
]);
}
}

View file

@ -71,7 +71,7 @@ class ResetPasswordController extends AbstractController
* Validates and process the reset URL that the user clicked in their email.
*/
#[Route('/reset/{token}', name: 'app_reset_password')]
public function reset(Request $request, UserPasswordHasherInterface $passwordEncoder, string $token = null): Response
public function reset(Request $request, UserPasswordHasherInterface $passwordHasher, string $token = null): Response
{
if ($token) {
// We store the token in session and remove it from the URL, to avoid the URL being
@ -106,13 +106,12 @@ class ResetPasswordController extends AbstractController
$this->resetPasswordHelper->removeResetRequest($token);
// Encode the plain password, and set it.
$user->setPassword(
$passwordEncoder->hashPassword(
$encodedPassword = $passwordHasher->encodePassword(
$user,
$form->get('plainPassword')->getData()
)
);
$user->setPassword($encodedPassword);
$this->getDoctrine()->getManager()->flush();
// The session is cleaned up after the password has been changed.

View file

@ -14,17 +14,11 @@ class OfferFilterFormType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('search', TextType::class, [
'label' => '<i class="fas fa-search mr-1"></i>Search',
'label_html' => true,
])
->add('zipCode', NumberType::class, [
'label' => '<i class="fas fa-map-marker-alt mr-2"></i>ZIP',
'label_html' => true,
->add('zipCode', TextType::class, [
'label' => 'ZIP',
])
->add('distance', NumberType::class, [
'label' => '<i class="fas fa-map-signs mr-1"></i>Distance',
'label_html' => true,
'label' => 'Distance',
])
->add('Apply', SubmitType::class)
;

View file

@ -46,8 +46,6 @@ class RegistrationFormType extends AbstractType
])
->add('agreeTerms', CheckboxType::class, [
'mapped' => false,
'label' => 'Agree to <a href="/imprint" target="_blank">Terms</a>',
'label_html' => true,
'constraints' => [
new IsTrue([
'message' => 'You need to agree to our terms.',

View file

@ -44,19 +44,6 @@ class OfferRepository extends ServiceEntityRepository
;
}
public function findBySearchLiteral(string $literal)
{
$qb = $this->createQueryBuilder('o');
$qb->andWhere($qb->expr()->like('o.title', ':lit'))
->setParameter('lit', '%' . $literal . '%')
->orderBy('o.id', 'ASC')
;
$qb = $qb->getQuery()->getResult();
return $qb;
}
/*
public function findOneBySomeField($value): ?Offer
{

View file

@ -348,9 +348,15 @@
"symfony/polyfill-mbstring": {
"version": "v1.22.1"
},
"symfony/polyfill-php73": {
"version": "v1.22.1"
},
"symfony/polyfill-php80": {
"version": "v1.22.1"
},
"symfony/polyfill-php81": {
"version": "v1.23.0"
},
"symfony/polyfill-uuid": {
"version": "v1.22.1"
},
@ -398,6 +404,9 @@
"symfony/security-csrf": {
"version": "v5.2.4"
},
"symfony/security-guard": {
"version": "v5.2.4"
},
"symfony/security-http": {
"version": "v5.2.6"
},

View file

@ -2,10 +2,6 @@
{% block title %}New Offer{% endblock %}
{% block javascripts %}
{{ encore_entry_script_tags('fileUpload') }}
{% endblock %}
{% block body %}
{% for message in app.flashes('error') %}
<div class="alert alert-error" role="alert">

View file

@ -41,10 +41,10 @@
</p>
<p class="pr-3">
<i class="fas fa-map-marker-alt"></i> {{ offer.zipCode }}
</p>
{% if distance > 0 %}
<p class="pr-3"><i class="fas fa-map-signs mr-1"></i>ca. {{ distance }} km</p>
(ca. {{ distance }} km)
{% endif %}
</p>
</div>
<h3>Description</h3>
<p>{{ offer.description }}</p>

View file

@ -10,14 +10,13 @@
<meta name="robots" content="index,follow" />
{% endif %}
<meta name="publisher" content="pflänz.li" />
<meta name="keywords" content="trade, share, plants, sustainability, pflanzentausch, pflanzen" />
<meta name="keywords" content="trade, share, plants", "sustainability" />
{% block stylesheets %}
{{ encore_entry_link_tags('app') }}
{% endblock %}
{% block javascripts %}{% endblock %}
{% block javascripts %}
{{ encore_entry_script_tags('app') }}
<!-- Matomo -->
@ -27,7 +26,7 @@
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function () {
var u = "https://analytics.thisfro.ch/";
var u = "//analytics.thisfro.ch/";
_paq.push([
'setTrackerUrl',
u + 'matomo.php'
@ -42,6 +41,7 @@
})();
</script>
<!-- End Matomo Code -->
{% endblock %}
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
@ -110,11 +110,11 @@
</a>
</section>
</div>
<div class="col-lg pt-4 pl-5">
<div class="col-lg pt-4">
<section>
<h2 class="h5">Links</h2>
<ul class="link-list">
<li><a href="https://blog.pflaenz.li">Blog</a></li>
<li><a href="https://blog.pflänz.li">Blog</a></li>
<li><a href="{{ path('imprint') }}">Imprint</a></li>
<li><a href="{{ path('faq') }}">FAQ</a></li>
</ul>

View file

@ -20,7 +20,7 @@
<div class="btn btn-primary"><i class="fas fa-filter mr-3"></i>Filter<i class="fas fa-chevron-down ml-3 dropdown-collapse"></i></div>
</a>
<div class="collapse" id="collapseExample">
{{ form(filter_form, {attr: {novalidate: 'novalidate'}}) }}
{{ form(filter_form) }}
</div>
</div>

View file

@ -4,11 +4,7 @@
{% endblock %}
{% block meta %}
<meta name="description" content="Register for pflänz.li" />
{% endblock %}
{% block javascripts %}
{{ encore_entry_script_tags('captcha') }}
<meta name="description" content="Register for pflänz.li"
{% endblock %}
{% block body %}

View file

@ -6,6 +6,7 @@
<h1>Reset your password</h1>
{{ form_start(resetForm) }}
{{form_widget(resetForm)}}
{{ form_row(resetForm.plainPassword) }}
<button class="btn btn-primary">Reset password</button>
{{ form_end(resetForm) }}
{% endblock %}

View file

@ -21,8 +21,6 @@ Encore
* and one CSS file (e.g. app.css) if your JavaScript imports CSS.
*/
.addEntry('app', './assets/app.js')
.addEntry('captcha', './assets/captcha.js')
.addEntry('fileUpload', './assets/fileUpload.js')
// enables the Symfony UX Stimulus bridge (used in assets/bootstrap.js)
.enableStimulusBridge('./assets/controllers.json')

View file

@ -936,11 +936,6 @@
error-stack-parser "^2.0.0"
string-width "^4.2.3"
"@snyk/protect@^1.834.0":
version "1.834.0"
resolved "https://registry.npmjs.org/@snyk/protect/-/protect-1.834.0.tgz"
integrity sha512-I/zzykVqRI4ZeIGwhwnQ/li01W0fJC6uMGdM6oGWOIOex3L6BBz2LTZeHr4PMoZDNha2TM10hgcYf9JvGvjNKQ==
"@stimulus/core@^2.0.0":
version "2.0.0"
resolved "https://registry.npmjs.org/@stimulus/core/-/core-2.0.0.tgz"
@ -1598,9 +1593,9 @@ caniuse-api@^3.0.0:
lodash.uniq "^4.5.0"
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001286:
version "1.0.30001388"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001388.tgz"
integrity sha512-znVbq4OUjqgLxMxoNX2ZeeLR0d7lcDiE5uJ4eUiWdml1J1EkxbnQq6opT9jb9SMfJxB0XA16/ziHwni4u1I3GQ==
version "1.0.30001287"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001287.tgz"
integrity sha512-4udbs9bc0hfNrcje++AxBuc6PfLNHwh3PO9kbwnfCQWyqtlzg3py0YgFu8jyRTTo85VAz4U+VLxSlID09vNtWA==
chalk@^2.0.0, chalk@^2.3.2, chalk@^2.4.2:
version "2.4.2"
@ -4202,6 +4197,11 @@ slash@^3.0.0:
resolved "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz"
integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==
snyk@^1.806.0:
version "1.806.0"
resolved "https://registry.npmjs.org/snyk/-/snyk-1.806.0.tgz"
integrity sha512-X0Aso0+zA9YXrrIgW1G3GXRqsvW4j7gXS9QyxFUwPp9qp5dAX1sjNUuLrK/z0CpuIpT7MVOBrYHF/RkMJ2C+FA==
sockjs@^0.3.21:
version "0.3.24"
resolved "https://registry.npmjs.org/sockjs/-/sockjs-0.3.24.tgz"