Makefile, AppCache and numerous other changes

This commit is contained in:
relikd
2019-11-25 18:09:40 +01:00
parent 57351a5e12
commit 40d483bc38
98 changed files with 1310 additions and 306 deletions

View File

@@ -0,0 +1,19 @@
yield: 20×20cm Backform
---
ingredients:
2 Tassen Walnüsse
1 Tasse Kakao
1/4 TL Salz
2 1/2 Tassen Datteln, weich, Medjool
Optional:
1 Tasse Mandeln, grob gehackt
---
directions:
Walnüsse im Mixer fein hacken. Kakao und Salz hinzugeben und miteinander vermixen.
Datteln nach und nach einzeln hinzugeben, während der Mixer weiter läuft. Die Mixtur sollte bröckelig sein aber beim Zusammendrücken leicht zusammenhalten (wenn es nicht zusammenhält, noch mehr Datteln hinzugeben)
In einer Schüssel die Mandeln mit der Mixtur vermischen und in eine Kuchenform pressen. Bis zum Servieren im Kühlschrank, luftdicht verschlossen halten.

View File

@@ -0,0 +1,19 @@
yield: 8×8 square pan
---
ingredients:
2 cups walnuts
1 cup cocoa powder
1/4 tsp salt
2 1/2 cups dates, soft, medjool
Optional:
1 cup almonds, roughly chopped
---
directions:
Blend walnuts on high until finely ground. Add the cocoa and salt. Pulse to combine.
Add the dates one at a time through the feed tube of the food processor while it is running. What you should end up with is a mix that appears rather like cake crumbs. But when pressed, will easily stick together (if the mixture does not hold together well, add more dates).
In a large bowl, combine the walnut-cocoa mix with the chopped almonds. Press into a lined cake pan or mold. Place in the fridge until ready to serve. Store in an airtight container.

View File

@@ -0,0 +1,13 @@
name: Brownies, Raw
---
tags: cake, glutenfree, raw, sweet
---
time: 15
---
difficulty: easy
---
rating: 4
---
source: https://mynewroots.org/site/2011/04/the-raw-brownie-2/
---
date: 2013-09-01

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

View File

@@ -0,0 +1 @@
_model: recipes

View File

@@ -0,0 +1,133 @@
name: Glutenfreies Mehl
---
yield: 9 Tassen
---
ingredients:
6 Tassen Mehl
3 Tassen Stärke
---
directions:
1) Mindestens 12 Stärken (leichtes Mehl) und 1 mittleres Mehl mischen. Je nach Geschmack und Textur noch ein weiteres Mehl (mittel oder schwer) hinzufügen.
2) Mehl mit einem Löffel umfüllen und mit einem Messer glattstreichen.
3) In einen luftdichten Behälter geben und gut schütteln.
4) An einem dunklen, trockenen Ort oder im Kühlschrank aufbewahren.
### Existierende Mischungen
#### [Cara's All-Purpose Mischung](https://forkandbeans.com/2013/02/13/the-best-gluten-free-flour-blend/)
- 3 Tassen __Braunes Reismehl__, extrafein gemahlen
- 3 Tassen __Sorghummehl__, extrafein gemahlen
- 1.5 Tassen __Pfeilwurzmehl__
- 1.5 Tassen __Kartoffelstärke__
Für die [Leichte Mischung](https://forkandbeans.com/2015/11/18/gluten-free-flour-blend-for-cakes/) (perfekt für Kuchen, Cupcakes, Muffins, etc.) Sorghum ersetzen durch Weißes Reismehl.
#### [Sarah's All-Purpose Mischung](https://sarahbakesgfree.com/2012/05/sarahs-gluten-free-flour-blend.html)
- 4 Tassen __Braunes Reismehl__
- 2 Tassen __Weißes Reismehl__
- 2 Tassen __Kartoffelstärke__
- 1/2 Tasse __Tapiokastärke__
- 1/2 Tasse __Maisstärke__
- 5 TL __Xanthan__
### Mischung selbst zusammen stellen
#### Leichte Mehle:
Das sind alle Stärken — ein Muss bei der Herstellung von glutenfreien Mehlen.
<dl>
<dt>Pfeilwurzmehl</dt>
<dd>
Diese leicht verdauliche Stärke wird aus einer Kombination mehrerer Wurzeln gewonnen. Es kann als gesündere Alternative für Maisstärke, zur Verdickung von Soßen verwendet werden.
</dd>
<dt>Maisstärke</dt>
<dd>
Aus Mais gemahlen, ist diese Stärke ein hervorragendes Binde- und Verdickungsmittel. Maisstärke erzeugt bspw. bei Brot eine großartige Kruste.
</dd>
<dt>Kartoffelstärke</dt>
<dd>
Ausgezeichnete Stärke um Backwaren mit Feuchtigkeit zu versorgen. Bitte beachte, dass Kartoffelstärke und Kartoffelmehl zwei verschiedene Dinge sind Etikett sorgfältig lesen.
</dd>
<dt>Tapiokastärke / Tapiokamehl</dt>
<dd>
Aus der Maniokwurzel extrahiert und gebleicht, wird Tapiokastärke typischerweise als Verdickungsmittel in Rezepten verwendet. Dies ist eine aromatisierte Stärke. Sie verleiht dem Backgut eine gewisse Leichtigkeit in der Textur.
</dd>
</dl>
#### Mittlere Mehle:
Obwohl diese Mehle an sich nahrhaft sind, sind sie bei der Verwendung in einer Rezeptur etwas leichter und stabiler. Sie können in Verbindung mit einer Stärke auch einzeln verwendet werden.
<dl>
<dt>Favabohne / Ackerbohne</dt>
<dd>
Die Favabohne kommt typischerweise in einer Mischung aus Kichererbsenmehl vor. Sie lässt den Teig schön aufgehen, hat aber einen ausgeprägten Geschmack.
</dd>
<dt>Kichererbse</dt>
<dd>
Einer der besten glutenfreien Mehle, der einzige Haken ist ein sehr ausgeprägter Bohnengeschmack. Lässt die Backwaren außergewöhnlich gut aufgehen. Kann einzeln mit Stärke verwendet werden.
</dd>
<dt>Hirse</dt>
<dd>
Mit einem trockenen und leicht nussigen Geschmack ist Hirsemehl ein überwiegend stärkehaltiges Getreide. Der Proteingehalt gleicht dem von Vollkornmehl.
</dd>
<dt>Hafer</dt>
<dd>
Dieses Mehl, das direkt aus Hafer gemahlen wird, ist reich an Vitaminen und Ballaststoffen. Es ergibt einen schönen, gleichmäßigen Geschmack und lässt die Backwaren gut aufgehen. Kann einzeln oder in Kombination mit anderen Mehlen verwendet werden.
</dd>
<dt>Quinoa</dt>
<dd>
Trotz seines sehr ausgeprägten Geschmacks ist Quinoa ein weiteres großartiges Mehl. Es kann einzeln oder in Kombination mit anderen Mehlen verwendet werden. Es ist nahrhaft, enthält viele Mineralien und Vitamine, und produziert eine hervorragende Textur.
</dd>
<dt>Sorghum</dt>
<dd>
Sorghum neigt dazu, die Textur und Leichtigkeit von Weizenmehl nachzuahmen und verleiht den Backwaren eine gewisse Zartheit. Aus diesem Grund ist es eines meiner Lieblingsmehle.
</dd>
<dt>Weißer Reis</dt>
<dd>
Berühmt dafür, eine kiesige Textur zu erzeugen. Bei diesem Mehl ist es wichtig, einen sehr feinen Mahlgrad zu wählen. Es ist ein sehr verbreitetes Mehl, das aus gutem Grund in vielen Mischungen verwendet wird. Es ist leicht und liefert hervorragende Ergebnisse. <b>Hinweis:</b> Süßer Reis unterscheidet sich vom weißem Reis und sollte eher wie eine Stärke (und in kleineren Mengen) verwendet werden.
</dd>
</dl>
#### Schwere Mehle:
Das sind dichtere und nahrhaftere Mehle. Sie werden selten einzeln verwendet, sondern in Kombination mit mittleren Mehlen.
<dl>
<dt>Mandel</dt>
<dd>
Mit einem schönen Kick an Proteinen ist Mandelmehl eine gute Möglichkeit, deinen Backwaren einen butterigen Geschmack zu verleihen. Es ist ein gutes Bindemittel und verleiht Feuchtigkeit (besonders wenn du keine Eier verwendest). Für Paleo-Diät sind Nuss- und Kokosmehle eine Korn-freie Alternative.
</dd>
<dt>Amaranth</dt>
<dd>
Aus den Samen der Amaranthpflanze gewonnen, ist dieses gemahlene Mehl dichter und nährstoffreicher als die meisten Mehle. Es kann in Backwaren die wenig aufgehen einzeln verwendet werden, oder in Kombination mit einer Mischung aus mittleren Mehlen.
</dd>
<dt>Brauner Reis</dt>
<dd>
Braunes Reismehl ist sehr vergleichbar mit Vollkornmehl. Es hat viele Nährstoffe und verleiht deinem Rezept eine gute Struktur. Idealerweise sollte es superfein gemahlen sein sonst entsteht eine kiesige Textur. Es kann mit einer Stärke einzeln verwendet werden oder in Kombination mit anderen mittleren Mehl(en).
</dd>
<dt>Buchweizen</dt>
<dd>
Lass dich sich nicht von dem Namen täuschen, Buchweizen wird nicht aus Weizen gewonnen, sondern aus einer Frucht. Dieses Mehl kann deinem Backgut einen schönen braunen Farbton verleihen, ist voll von Nährstoffen und Dichte. Es muss in Kombination mit einer Stärke und einem mittlerem Mehl verwendet werden, insbesondere für stark aufgehende Rezepte.
</dd>
<dt>Kokosnuss</dt>
<dd>
Kokosnuss absorbiert sehr viel Flüssigkeit im Rezept. Deshalb nur in kleineren Mengen (ca. 1/4 Tasse) und in Kombination mit anderen Mehlen verwenden.
</dd>
<dt>Mais</dt>
<dd>
Ein herzhaftes, dichtes Mehl. Maismehl kann der Mehlmischung eine schöne Textur verleihen, ähnlich wie bei einem Maisbrot.
</dd>
<dt>Teff</dt>
<dd>
Teff ist ein einzigartiges, aromatisiertes Vollkorn Mehl, das in äthiopischen Lebensmitteln verwendet wird. Es ist leicht, erzeugt aber gleichzeitig eine dichte Textur, so dass es am besten in kleineren Mengen (wie Kokosmehl) und in Kombination mit anderen Mehlen verwendet wird.
</dd>
</dl>

View File

@@ -0,0 +1,134 @@
name: Gluten-Free Flour
---
yield: 9 cups
---
ingredients:
6 cups flour
3 cups starch
---
directions:
1) You'll need 12 starches (light flour) and at least 1 medium flour. Based on the prefered flavor and texture, you can mix in another flour (medium or heavy).
2) Spoon out flours with a spoon and level off with a knife.
3) Place into an air-tight container and shake well.
4) Keep stored in a dark, dry place or in the refrigerator.
### Existing blends
#### [Cara's All-Purpose Blend](https://forkandbeans.com/2013/02/13/the-best-gluten-free-flour-blend/)
- 3 cups brown rice flour, superfine ground
- 3 cups sorghum flour, superfine ground
- 1.5 cups arrowroot powder
- 1.5 cups potato starch
For the [Light Blend](https://forkandbeans.com/2015/11/18/gluten-free-flour-blend-for-cakes/) (perfect for cakes, cupcakes, muffins, etc.) replace sorghum with white rice flour.
#### [Sarah's All-Purpose Blend](https://sarahbakesgfree.com/2012/05/sarahs-gluten-free-flour-blend.html)
- 4 cups brown rice flour
- 2 cups white rice flour
- 2 cups potato starch
- 1/2 cup tapioca flour
- 1/2 cup corn starch
- 5 tsp xanthan gum
### Create your own blend
#### Light based flours:
These are all of the starches — a must when creating a blend of gluten free flours.
<dl>
<dt>Arrowroot Powder</dt>
<dd>
This easy-to-digest starch is extracted from a combination of several plant rootstocks. It can be used as a healthier sub for cornstarch in thickening up sauces and gravies.
</dd>
<dt>Corn Starch</dt>
<dd>
Ground from corn, this starch makes for a great binder and thickening agent. Check for a great non GMO brand because cornstarch can add a great outer crust for your breads.
</dd>
<dt>Potato Starch</dt>
<dd>
This is my go-to starch for it's ability to add moisture into baked goods. Please note that potato starch and potato flour are two different things read the label carefully.
</dd>
<dt>Tapioca Starch / Tapioca Flour</dt>
<dd>
Extracted and bleached from the cassava root, tapioca starch is typically used as a thickening agent in recipes. This is a flavored starch to use in a blend for its ability to bring a certain lightness in texture to the baked good.
</dd>
</dl>
#### Medium based flours:
Though nutritious in their own right, these flours are a bit lighter when used in a recipe and are more stable to be used alone paired with a starch.
<dl>
<dt>Fava Bean</dt>
<dd>
Fava bean can typically be found with a mix of garbanzo bean flour. It yields a really nice rise but has a distinct flavor.
</dd>
<dt>Garbanzo Bean / Chickpea</dt>
<dd>
One of the best result-producing gluten-free flours, the only catch is its a very distinct bean flavor. The rise in your baked goods will be exceptional and can be used alone with a starch.
</dd>
<dt>Millet</dt>
<dd>
With a dry and slighty nutty flavor, millet flour is a predominantly starchy grain with a protein content that is similar to whole wheat flour.
</dd>
<dt>Oat</dt>
<dd>
Ground straight from oats, this flour is rich in vitamins and fiber. It yields a nice even flavor and a great rise to your baked goods. Can be used alone or in a combination of other flours.
</dd>
<dt>Quinoa</dt>
<dd>
Despite it's very distinct flavor, quinoa is another great medium-based flour that can work alone or in combination to other flours. It's nutritious, dense with minerals and vitamins, and produces a great texture.
</dd>
<dt>Sorghum</dt>
<dd>
Sorghum tends to mimic the texture and lightness of wheat flour and will give your baked goods a certain tenderness. For this reason, it's one of my go-to flours in my flour blend.
</dd>
<dt>White Rice</dt>
<dd>
Notorious for yielding a gritty texture, it's important to get the finest ground for this flour. It's a very common flour used in blends for good reason, it's light and gives great results. <b>Note:</b> Sweet Rice is different from White Rice and should be used more like a starch and in smaller amounts.
</dd>
</dl>
#### Heavy based flours:
These are the more dense and nutritious flours that are rarely used alone and will need to be used in tandem with another medium-based flour.
<dl>
<dt>Almond</dt>
<dd>
With a nice kick of protein, nut meal is a great way to give your baked goods a buttery flavor. It works best if you add a little into your mix (especially if you do not use eggs) to yield a nice binding result and overall moisture into your recipe. If you are Paleo, nut and coconut flours are you to-go grain-free flours.
</dd>
<dt>Amaranth</dt>
<dd>
Derived from the seeds of the amaranth plant, this stone ground flour is denser and more nutritious than most flours. It can be used alone in low rise baked goods or in combination with a mix of medium flours.
</dd>
<dt>Brown Rice</dt>
<dd>
Brown rice flour is very comparable to whole wheat flour, with its dense nutrition and great structure it lends to your recipe. It's best if you use it in superfine ground form this way you will avoid that gritty texture. It can be used alone with a starch or in combination with another medium flour(s).
</dd>
<dt>Buckwheat</dt>
<dd>
Don't be fooled by its name, buckwheat is not derived by wheat but rather a fruit. This flour can give your baked good a nice brown hue, full of nutrition and density. It needs to be used in combination with a starch and medium flour, especially for higher rising recipes.
</dd>
<dt>Coconut</dt>
<dd>
Coconut has a great way of absorbing the liquid in a recipe, which is why it needs to be used in smaller amounts (think 1/4 cup) and in combo with other flours.
</dd>
<dt>Corn</dt>
<dd>
A hearty, dense flour, corn flour can add a nice texture to your flour blend, similar to a corn bread toothsome feel.
</dd>
<dt>Teff</dt>
<dd>
A unique flavored whole grain, Teff is a very common flour used in Ethiopian food. It's light but creates a dense texture at the same time so it's best if used in smaller amounts (like coconut flour) and in combination with other flours.
</dd>
</dl>

View File

@@ -0,0 +1,9 @@
tags: bread, glutenfree, ingredient
---
time: 5
---
difficulty: easy
---
source: https://forkandbeans.com/2013/12/30/guide-gluten-free-flours/
---
date: 2013-08-09

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

View File

@@ -0,0 +1,14 @@
name: Vanille Ausstech-Kekse
---
ingredients:
1/2 Tasse Margarine, oder Kokos Öl
1/2 Tasse Ahornsirup
1/2 TL Vanille Extrakt
1/4 TL Vanilleshote
1 Prise Salz
2 1/4 Tassen Mehl, glutenfrei, @../gluten-free-flour/
---
directions:
No translation yet. Click the flag (🇱🇷) at the bottom.

View File

@@ -0,0 +1,24 @@
name: Vanilla cut-out cookies
---
ingredients:
1/2 cup non-dairy butter, or coconut oil
1/2 cup maple syrup
1/2 tsp vanilla extract
1/4 tsp vanilla bean
1 dash salt
2 1/4 cups flour, gluten-free, @../gluten-free-flour/
---
directions:
1. Preheat oven to 350°F. Line 2 cookie sheets with parchment paper. Prepare a rolling area with two additional sheets of parchment paper for that, and have your cookie cutter(s) handy.
2. Place butter in a large mixing bowl and whip it with a mixer until it's creamy. Add sweetener, vanilla extract and bean, and salt and mix once again to combine. Add in flour and use a wooden spoon to mix. Then get in there with your hands and mix everything together by working the dough until you can shape it into a ball {note: as depending on the flour mix you use there may be a slight variance, know that the consistency of the dough should not be sticky but should press together when pinched — be sure to knead it really well first for some time — if it's a little sticky, add a little more flour (try 1-2 Tbsp); if it's a little dry add a little more sweetener (try 1 Tbsp)}. Shape the dough into 2 balls and then flatten each into a disk.
3. Roll out one of the dough balls between two sheets of parchment paper to ¼" thickness {or thinner or thicker depending on how you want your cookies to turn out}. Use a cookie cutter to cut out the cookies. Carefully transfer to a prepared cookie sheets, spacing them ½" apart {they won't spread as they bake}. Gather up any dough scraps and repeat until all dough is used up. Repeat the process with the second dough ball.
4. Bake in a pre-heated oven for approximately 11-13 minutes, until the edges just begin to become golden. Remove from oven and place on a cooling rack. {Note: cookies will harden a little within minutes of cooling, so don't overbake}. Allow the cookies to cool for 10 minutes and enjoy!
__Note:__
You can make your own glutenfree flour blend by combining:
1 cup brown rice flour, ¾ cup tapioca starch, ½ cup sweet rice flour, ½ tsp guar gum

View File

@@ -0,0 +1,13 @@
tags: cookies, sweet, xmas, glutenfree
---
time: 30
---
rating: 4
---
difficulty: easy
---
yield: 26-28
---
source: https://unconventionalbaker.com/recipes/gluten-free-vegan-vanilla-cut-out-cookies/
---
date: 2019-05-15

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

View File

@@ -0,0 +1 @@
_model: recipes

196
data/export-yummy.py Normal file
View File

@@ -0,0 +1,196 @@
#!/usr/bin/env python3
import sqlite3
import os
import sys
from datetime import datetime
'''
Usage: python3 generate-alternates.py '…/YummySoup.library/Database.SQL'
You may have to adjust `mapTag`, `clearUTF()`, and `slugify()` below.
Output is generated in the current folder under `yummysoup-exported`.
'''
# check if input param is SQL database file
try:
inputPath = os.path.abspath(sys.argv[1])
if not os.path.isfile(inputPath) or not inputPath.upper().endswith('SQL'):
raise Exception()
base = os.path.dirname(inputPath)
print('connecting...')
db = sqlite3.connect(inputPath)
except Exception:
print()
print(f'usage: {os.path.basename(sys.argv[0])} "path/to/db.SQL"')
print('(e.g., "…/YummySoup! Librarys.library/Library Database.SQL")')
print()
exit()
# create output export dir if necessary
_out = os.path.abspath('./yummysoup-exported/')
if not os.path.exists(_out):
os.mkdir(_out)
# map old tags to new one. Should be all available tags in YummySoup!
# right hand side must be lower case string or None
mapTag = {
'': None,
'Weihnachten': 'xmas',
'Wurst': None,
'Dressing': 'dressing',
'Soße': 'sauce',
'Hauptspeise': 'main-dish',
'Süßes': 'sweet',
'Zutat': 'ingredient',
'Raw': 'raw',
'Aufstrich': 'spread',
'Brot': 'bread',
'Kuchen': 'cake',
'Kekse': 'cookies',
'trocken': None,
'Salat': 'salad',
'Drink': 'drinks',
'Riegel': None,
'Schokolade': 'chocolate',
'Dip': 'dip',
'fruchtig': None,
'Glutenfrei': 'glutenfree'
}
def ttoint(txt):
i, n = txt.split(' ') if txt else (0, 'M')
return int(i) * [1, 60, 1440]['MST'.index(n[0])]
# def matchTime(time):
# if time in [0, 25, 135, 165, 300]:
# return [None, 30, 150, 150, 360][[0, 25, 135, 165, 300].index(time)]
# prev = 99999
# val = time
# for x in [5, 10, 15, 20, 30, 45, 60, 75, 90, 105,
# 120, 150, 180, 240, 360, 480, 720, 1440]:
# diff = abs(time - x)
# if diff < prev:
# prev = diff
# val = x
# elif diff == prev:
# print(time)
# return val
def clearUTF(txt):
return txt.replace('\\U00df', 'ß').replace('\\U00f1', 'ñ')\
.replace('\\U00c4', 'Ä').replace('\\U00e4', 'ä')\
.replace('\\U00d6', 'Ö').replace('\\U00f6', 'ö')\
.replace('\\U00dc', 'Ü').replace('\\U00fc', 'ü')
def slugify(txt):
return txt.lower().replace(' ', '-').replace(':', '').replace('ß', 'ss')\
.replace('(', '').replace(')', '').replace(',', '').replace('ê', 'e')\
.replace('ä', 'ae').replace('ü', 'ue').replace('ö', 'oe').strip('-')
def formatIngredient(info):
try:
if info['isG'] in ['YES', '1']:
return '\n' + info['nam']
except KeyError:
pass
txt = info['nam'].replace(',', ' ')
if info['mea']:
txt = '{} {}'.format(info['mea'], txt)
if info['qua']:
txt = '{} {}'.format(info['qua'], txt)
if info['met']:
txt = '{}, {}'.format(txt, info['met'])
return txt
def ingredientToStr(txt):
res = ''
for ing in clearUTF(txt).split('},'):
ing = ing.strip('{()} \n')
info = {'qua': '', 'mea': '', 'nam': '', 'met': ''}
for prop in ing.split(';'):
if not prop:
continue
k, v = [x.strip('\n "') for x in prop.split('=')]
info[k[:3]] = v
res += '\n' + formatIngredient(info)
return res
def directionsToStr(txt):
return txt.replace('<font face="" size="">', '').replace(' ', '')\
.replace('</font>', '').replace('<br>', '').replace('<b>', '__').\
replace('</b>', '__').replace('<i>', '_').replace('</i>', '_')\
.replace('', '°C').replace(' °C', '°C')\
.replace('½', '1/2').replace('¼', '1/4').replace('', '1/8')\
.replace('', '1/3').replace('', '2/3').replace('¾', '3/4')
def prnt(key, val, inline=True):
return '' if not val else '{}:{}{}\n---\n'.format(
key, ' ' if inline else '\n\n', str(val).strip())
def export(slug, content, img):
output = os.path.join(_out, slug)
for i in range(10):
folder = output
if i > 0:
folder += '-%d' % i
if not os.path.isdir(folder):
output = folder
break
os.mkdir(output)
with open(os.path.join(output, 'contents.lr'), 'w') as f:
f.write(txt.strip().rstrip('-'))
for i in range(1, 10):
src = img % i
dest = os.path.join(output, f'image{"" if i == 1 else i}.jpg')
if not os.path.isfile(src):
break
with open(src, 'rb') as a, open(dest, 'wb') as b:
b.write(a.read())
print('exporting...')
for row in db.cursor().execute('''SELECT * FROM ZRECIPES'''):
difficulty, rating, date, img = row[4], row[7], row[9], row[10]
duration, tags, name, yields = row[12:15], row[15], row[17], row[21]
notes, directions, source, ingredients = row[23], row[25], row[26], row[27]
# preprocess
date = datetime.fromtimestamp(date + 978307200).strftime('%Y-%m-%d')
img = os.path.join(base, 'Images', img + '-Image%d.jpg')
duration = sum([ttoint(x) for x in duration]) # matchTime()
tags = ', '.join(sorted([mapTag[x] for x in tags.split(',') if mapTag[x]]))
slug = slugify(name)
if yields:
y = yields.split(' ')
if len(y) == 3 and y[1].endswith('form'):
yields = '{} {}'.format(y[2], y[1])
txt = ''
txt += prnt('name', name)
txt += prnt('tags', tags)
txt += prnt('time', duration)
txt += prnt('difficulty', [None, 'easy', 'medium', 'hard'][difficulty])
txt += prnt('rating', rating)
txt += prnt('yield', yields)
txt += prnt('ingredients', ingredientToStr(ingredients), False)
desc = directionsToStr(directions)
if notes:
desc = '{}\n\n__Notes:__ {}'.format(desc.strip(), notes)
txt += prnt('directions', desc, False)
txt += prnt('source', source)
txt += prnt('date', date)
export(slug, txt, img)
db.close()
print('done.')

View File

@@ -0,0 +1,59 @@
#!/usr/bin/env python3
import os
import sys
'''
Usage: python3 generate-alternates.py development/*
Input is a recipe folder.
Will take the `contents.lr` and extract `contents+de.lr` and `contents+en.lr`.
The content will be identical but its easier to edit this way.
No necessary redundant data fields.
'''
def prnt(key, val, inline=True):
return '' if not val else '{}:{}{}\n---\n'.format(
key, ' ' if inline else '\n\n', str(val).strip())
def splitContent(path):
mode = 1
idx = 0
with open(os.path.join(path, 'contents.lr'), 'r') as fin:
tmp = ['', '']
for line in fin:
if mode == 1:
tag = line.split(':')[0]
if tag in ['name', 'yield', 'ingredients', 'directions']:
idx = 1
else:
idx = 0
tmp[idx] += line
mode = 2
else:
tmp[idx] += line
if line == '---\n':
mode = 1
tmp[1] = tmp[1][:-4]
return tmp
def writeSplit(path):
de_file = os.path.join(path, 'contents+de.lr')
if not os.path.isdir(path) or os.path.exists(de_file):
return
print(path)
content = splitContent(path)
if not content[1]:
return
with open(de_file, 'w') as f:
f.write(content[1])
with open(os.path.join(path, 'contents+en.lr'), 'w') as f:
f.write(content[1])
with open(os.path.join(path, 'contents.lr'), 'w') as f:
f.write(content[0])
for x in sys.argv[1:]:
writeSplit(x)