From ac82ac6f925ec4540689dcac888a807f44c25ea2 Mon Sep 17 00:00:00 2001 From: Roman Dvorak Date: Mon, 10 Jul 2023 02:00:59 +0200 Subject: [PATCH 01/17] add thumbnail tag --- src/MLABweb/template/modules.detail.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MLABweb/template/modules.detail.hbs b/src/MLABweb/template/modules.detail.hbs index a81c873..9cf8860 100644 --- a/src/MLABweb/template/modules.detail.hbs +++ b/src/MLABweb/template/modules.detail.hbs @@ -8,7 +8,7 @@ - + + diff --git a/src/MLABweb/template/index.hbs b/src/MLABweb/template/index.hbs index 21b7446..5ec3594 100644 --- a/src/MLABweb/template/index.hbs +++ b/src/MLABweb/template/index.hbs @@ -356,16 +356,16 @@ info@mlab.cz wow.init(); + + + From df3b6246e3d7f767b499d9a32b30146ca48cd7df Mon Sep 17 00:00:00 2001 From: Roman Dvorak Date: Thu, 20 Jul 2023 09:53:54 +0200 Subject: [PATCH 03/17] aktualizace kategorii, drobne upravy --- src/MLABweb/categories.py | 81 +++++++++++++++++++++++++ src/MLABweb/handlers/admin.py | 19 +++--- src/MLABweb/mlab_web.py | 10 +++ src/MLABweb/template/modules.detail.hbs | 4 +- src/MLABweb/template/modules.hbs | 11 ++-- 5 files changed, 110 insertions(+), 15 deletions(-) create mode 100644 src/MLABweb/categories.py diff --git a/src/MLABweb/categories.py b/src/MLABweb/categories.py new file mode 100644 index 0000000..41538cd --- /dev/null +++ b/src/MLABweb/categories.py @@ -0,0 +1,81 @@ +categories = [ + + { + '_id': 'power-sw', + 'name': "Power switches", + 'description': "Power switches" + },{ + '_id': "sensor", + 'name': "Sensors", + 'description': "Sensor modules" + },{ + '_id': "clock", + 'name': "Clock", + },{ + '_id': "comm-rf", + 'name': "Radio communication", + },{ + '_id': "comm-ir", + 'name': "IR communication", + },{ + '_id': "comm-serial", + 'name': "Serial communication", + },{ + '_id': "translators", + 'name': "Translators", + },{ + '_id': "memories", + 'name': "Memories", + },{ + '_id': "mcu-arm", + 'name': "ARM", + },{ + '_id': "mcu-avr", + 'name': "AVR", + },{ + '_id': "mcu-pic", + 'name': "PIC", + },{ + '_id': "power-supply", + 'name': "Power supply", + },{ + '_id': "universial", + 'name': "Universial parts", + },{ + '_id': "human-interface", + 'name': "Human interfaces", + },{ + '_id': "audio", + 'name': "Audio", + },{ + '_id': "motor-driver", + 'name': "Motor drivers", + },{ + '_id': "x86", + 'name': "x86 CPU", + },{ + '_id': "box", + 'name': "Boxes", + },{ + '_id': "op-amps", + 'name': "Operational amplifiers", + },{ + '_id': "tdc", + 'name': "Time-to-digital converters", + },{ + '_id': "measuring", + 'name': "Measuring", + },{ + '_id': "cpld-fpga", + 'name': "CPLD FPGA", + },{ + '_id': "ad-converter", + 'name': "AD converters", + },{ + '_id': "mechanical", + 'name': "Mechanical parts", + },{ + '_id': "mcu", + 'name': "Microcontrollers", + } +] \ No newline at end of file diff --git a/src/MLABweb/handlers/admin.py b/src/MLABweb/handlers/admin.py index 58c7ba3..a217fb4 100644 --- a/src/MLABweb/handlers/admin.py +++ b/src/MLABweb/handlers/admin.py @@ -195,12 +195,15 @@ def get(self, module = None): if not module_data.get('file_readme'): readme_html = "No content" else: - readme_html = markdown.markdown(open(module_data.get('file_readme', ''), 'r').read(), - extensions=['pymdownx.extra', 'pymdownx.magiclink', 'pymdownx.b64'], - extension_configs={ - "pymdownx.b64": {"base_path": os.path.dirname(module_data.get('file_readme', ''))}, - } - ) + try: + readme_html = markdown.markdown(open(module_data.get('file_readme', ''), 'r').read(), + extensions=['pymdownx.extra', 'pymdownx.magiclink', 'pymdownx.b64'], + extension_configs={ + "pymdownx.b64": {"base_path": os.path.dirname(module_data.get('file_readme', ''))}, + } + ) + except Exception as e: + readme_html = "No README.." self.render("modules.detail.hbs", db_web = self.db_web, module=module, module_data=module_data, images = images, documents = glob2.glob(module_path+"//**/*.pdf"), assembly_gh_link = assembly_gh_link, readme_html = readme_html, path = module_path) @@ -271,7 +274,7 @@ def get(self, category = None): if category: q += [ { - "$match": {'category[]': {cat_pol: [category]}} + "$match": {'tags': {cat_pol: [category]}} }] q += [ { @@ -323,7 +326,7 @@ def post(self, category = None): "name": { "$regex": search, "$options": 'i'} }, { - 'short_en': { "$regex": search, "$options": 'i'} + 'description': { "$regex": search, "$options": 'i'} } ] } diff --git a/src/MLABweb/mlab_web.py b/src/MLABweb/mlab_web.py index 4754146..8e7a69f 100644 --- a/src/MLABweb/mlab_web.py +++ b/src/MLABweb/mlab_web.py @@ -12,6 +12,9 @@ from handlers import github, admin, auth, api from handlers import _sql, BaseHandler +import pymongo + +from categories import categories tornado.options.define("port", default=5000, help="port", type=int) tornado.options.define("debug", default=False, help="debug mode") @@ -117,6 +120,13 @@ def __init__(self, config={}): autoreload=True ) tornado.locale.load_translations("locale/") + + dbw = pymongo.MongoClient('mongo', 27017).MLABweb.Category + dbw.delete_many({}) + dbw.insert_many(categories) + + + tornado.web.Application.__init__(self, handlers, **settings) def main(): diff --git a/src/MLABweb/template/modules.detail.hbs b/src/MLABweb/template/modules.detail.hbs index 9cf8860..94c0d9d 100644 --- a/src/MLABweb/template/modules.detail.hbs +++ b/src/MLABweb/template/modules.detail.hbs @@ -8,7 +8,7 @@ - +