mirror of
https://codeberg.org/scip/kleingebaeck.git
synced 2025-12-16 12:01:00 +01:00
Fix #47: add mock http server for testing w/o hitting prod site
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -3,3 +3,6 @@ kleingebaeck
|
|||||||
releases
|
releases
|
||||||
t/out
|
t/out
|
||||||
.bak
|
.bak
|
||||||
|
t/httproot/out
|
||||||
|
t/httproot/kleinanzeigen
|
||||||
|
t/httproot/favicon.ico
|
||||||
|
|||||||
13
t/httproot/README.md
Normal file
13
t/httproot/README.md
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# Mock http server
|
||||||
|
|
||||||
|
Install ehfs from https://github.com/mjpclab/extra-http-file-server/.
|
||||||
|
|
||||||
|
Install p2cli from https://github.com/wrouesnel/p2cli.
|
||||||
|
|
||||||
|
Run `templates/render.sh` to build the file structure.
|
||||||
|
|
||||||
|
Run `server.sh` to start the http server.
|
||||||
|
|
||||||
|
To scrape an ad from it, use such a URL:
|
||||||
|
|
||||||
|
http://localhost:8080/s-anzeige/first-ad/111-11-111
|
||||||
BIN
t/httproot/img/cdas4sd5-5258-42c2-bf58-as43as5d43as
Normal file
BIN
t/httproot/img/cdas4sd5-5258-42c2-bf58-as43as5d43as
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
BIN
t/httproot/img/cdas4sd5-5258-42c2-bf58-d1b8e9221574
Normal file
BIN
t/httproot/img/cdas4sd5-5258-42c2-bf58-d1b8e9221574
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
BIN
t/httproot/img/fcf6d664-5258-42c2-bf58-as43as5d43as
Normal file
BIN
t/httproot/img/fcf6d664-5258-42c2-bf58-as43as5d43as
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
BIN
t/httproot/img/fcf6d664-5258-42c2-bf58-d1b8e9221574
Normal file
BIN
t/httproot/img/fcf6d664-5258-42c2-bf58-d1b8e9221574
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
4
t/httproot/serve.sh
Executable file
4
t/httproot/serve.sh
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
ehfs -a :/s-anzeige:./kleinanzeigen \
|
||||||
|
-a :/api/v1/prod-ads/images/fc:./img \
|
||||||
|
-l localhost:8080 -I index.html
|
||||||
50
t/httproot/templates/ad.tpl
Normal file
50
t/httproot/templates/ad.tpl
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="de">
|
||||||
|
<head>
|
||||||
|
<title>Ad Listing</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="l-container-row">
|
||||||
|
<div id="vap-brdcrmb" class="breadcrump">
|
||||||
|
<a class="breadcrump-link" itemprop="url" href="/" title="Kleinanzeigen ">
|
||||||
|
<span itemprop="title">Kleinanzeigen </span>
|
||||||
|
</a>
|
||||||
|
<a class="breadcrump-link" itemprop="url" href="/egal">
|
||||||
|
<span itemprop="title">{{ category }}</span></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% for image in images %}
|
||||||
|
<div class="galleryimage-element" data-ix="3">
|
||||||
|
<img src="http://localhost:8080/api/v1/prod-ads/images/fc/{{ image.id }}?rule=$_59.JPG"/>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
<h1 id="viewad-title" class="boxedarticle--title" itemprop="name" data-soldlabel="Verkauft">
|
||||||
|
{{ title }}</h1>
|
||||||
|
<div class="boxedarticle--flex--container">
|
||||||
|
<h2 class="boxedarticle--price" id="viewad-price">
|
||||||
|
{{ price }}</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="viewad-extra-info" class="boxedarticle--details--full">
|
||||||
|
<div><i class="icon icon-small icon-calendar-gray-simple"></i><span>{{ created }}</span></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="splitlinebox l-container-row" id="viewad-details">
|
||||||
|
<ul class="addetailslist">
|
||||||
|
<li class="addetailslist--detail">
|
||||||
|
Zustand<span class="addetailslist--detail--value" >
|
||||||
|
{{ condition }}</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="l-container last-paragraph-no-margin-bottom">
|
||||||
|
<p id="viewad-description-text" class="text-force-linebreak " itemprop="description">
|
||||||
|
{{ text }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
15
t/httproot/templates/index.tpl
Normal file
15
t/httproot/templates/index.tpl
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="de" >
|
||||||
|
<head>
|
||||||
|
<title>Ads</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{% for ad in ads %}
|
||||||
|
<h2 class="text-module-begin">
|
||||||
|
<a class="ellipsis"
|
||||||
|
href="/s-anzeige/{{ ad.slug }}/{{ ad.id }}">{{ ad.title }}</a>
|
||||||
|
</h2>
|
||||||
|
{% endfor %}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
13
t/httproot/templates/render.sh
Executable file
13
t/httproot/templates/render.sh
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh -x
|
||||||
|
base="../kleinanzeigen"
|
||||||
|
mkdir -p $base
|
||||||
|
|
||||||
|
echo "Generating /s-bestandsliste.html"
|
||||||
|
p2cli -t index.tpl -i vars.yaml > $base/s-bestandsliste.html
|
||||||
|
|
||||||
|
for idx in 0 1; do
|
||||||
|
slug=$(cat vars.yaml | yq ".ads[$idx].slug")
|
||||||
|
id=$(cat vars.yaml | yq ".ads[$idx].id")
|
||||||
|
mkdir -p $base/$slug/$id
|
||||||
|
cat vars.yaml | yq ".ads[$idx]" | p2cli -t ad.tpl -f yaml > $base/$slug/$id/index.html
|
||||||
|
done
|
||||||
27
t/httproot/templates/vars.yaml
Normal file
27
t/httproot/templates/vars.yaml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
ads:
|
||||||
|
- slug: first-ad
|
||||||
|
id: 111-11-111
|
||||||
|
title: First Ad
|
||||||
|
price: "19 €"
|
||||||
|
condition: "Sehr gut"
|
||||||
|
category: "Weitere Elektronik"
|
||||||
|
created: 21.12.2023
|
||||||
|
images:
|
||||||
|
- id: fcf6d664-5258-42c2-bf58-d1b8e9221574
|
||||||
|
- id: fcf6d664-5258-42c2-bf58-as43as5d43as
|
||||||
|
text: |
|
||||||
|
Zu Verkaufen.
|
||||||
|
Zahlung nur Paypal.
|
||||||
|
- slug: second-ad
|
||||||
|
id: 222-22-222
|
||||||
|
title: Second Ad
|
||||||
|
price: "200 €"
|
||||||
|
condition: "Sehr gut"
|
||||||
|
category: "Elektronik"
|
||||||
|
created: 21.12.2023
|
||||||
|
images:
|
||||||
|
- id: cdas4sd5-5258-42c2-bf58-d1b8e9221574
|
||||||
|
- id: cdas4sd5-5258-42c2-bf58-as43as5d43as
|
||||||
|
text: |
|
||||||
|
Zu Verkaufen.
|
||||||
|
Zahlung nur Überweisung.
|
||||||
Reference in New Issue
Block a user