From b3f8f890f4a0f4f134dd3f71df1cc64dca4a3b77 Mon Sep 17 00:00:00 2001 From: Marek Baczynski Date: Mon, 28 Nov 2022 22:08:37 +0100 Subject: [PATCH 1/2] tagline randomiser --- parts/server.py | 8 +++++++- parts/taglines.txt | 22 ++++++++++++++++++++++ parts/templates/partsearch.html | 2 +- 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 parts/taglines.txt diff --git a/parts/server.py b/parts/server.py index fde1e58..94e5e20 100755 --- a/parts/server.py +++ b/parts/server.py @@ -13,6 +13,7 @@ from io import BytesIO from os import listdir from os.path import isfile, join from werkzeug.utils import secure_filename +import random app = Flask(__name__) @@ -22,6 +23,11 @@ parts = {} octopartURL ="" baseURL = "/parts" +taglines = [] +with open('taglines.txt', 'r') as infile: + for line in infile: + taglines.append(line[:-1]) + def getContainers(): query = "select id, name from containers order by UPPER(name);" r = db_engine.execute(text(query)) @@ -68,7 +74,7 @@ def serveImage(img): @app.route(baseURL, strict_slashes=True) def index(): - return render_template('partsearch.html', containers=getContainers(), baseURL=baseURL) + return render_template('partsearch.html', containers=getContainers(), baseURL=baseURL, tagline=random.choice(taglines)) @app.route(baseURL+'/getlocationsInContainer/') def get_locations_in_container(containerID): diff --git a/parts/taglines.txt b/parts/taglines.txt new file mode 100644 index 0000000..f59aaca --- /dev/null +++ b/parts/taglines.txt @@ -0,0 +1,22 @@ +Looking for obsolete ICs that were discontinued years ago? Just start typing! +Looking for obsolete ICs that were discontinued years ago? Just start typing! +Looking for obsolete ICs that were discontinued years ago? Just start typing! +Start typing to find your part +Start typing to find your part +Start typing to find your part +Try typing "mosfet" +Try typing "arduino" +Try typing "led driver" +Try typing "resistor" +Try typing "regulator" +Try typing "led" +Try typing "78L05" +Try typing "drv8833" +Try typing "stm32" +Try typing "Flux capacitor". We don't have one, but you can try. +You can also search for tools +Now with emoji support! +I know it's here somwhere! +For every part you find, there is 1000 you won't! +'); DROP TABLE parts;-- +Help! I'm trapped in a tagline randomiser! \ No newline at end of file diff --git a/parts/templates/partsearch.html b/parts/templates/partsearch.html index 60f5b88..30f087c 100755 --- a/parts/templates/partsearch.html +++ b/parts/templates/partsearch.html @@ -19,7 +19,7 @@

ELAB Part Search Engine

-

Looking for obsolete ICs that were discontinued years ago? Just start typing!

+

{{ tagline }}

SEARCH IN

From 4bceb35bd5d906276f8462a4507a1f5e714e5c0f Mon Sep 17 00:00:00 2001 From: Marek Baczynski Date: Mon, 28 Nov 2022 22:15:33 +0100 Subject: [PATCH 2/2] added more taglines --- parts/taglines.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/parts/taglines.txt b/parts/taglines.txt index f59aaca..5b6c167 100644 --- a/parts/taglines.txt +++ b/parts/taglines.txt @@ -1,6 +1,10 @@ Looking for obsolete ICs that were discontinued years ago? Just start typing! Looking for obsolete ICs that were discontinued years ago? Just start typing! Looking for obsolete ICs that were discontinued years ago? Just start typing! +Looking for obsolete ICs that were discontinued years ago? Just start typing! +Looking for obsolete ICs that were discontinued years ago? Just start typing! +Start typing to find your part +Start typing to find your part Start typing to find your part Start typing to find your part Start typing to find your part @@ -13,6 +17,12 @@ Try typing "led" Try typing "78L05" Try typing "drv8833" Try typing "stm32" +Try typing "logic analyzer" +Try typing "programmer" +Try typing "connector" +Try typing "motor" +Try typing "spring" +Try typing "usb" Try typing "Flux capacitor". We don't have one, but you can try. You can also search for tools Now with emoji support!