Skip to content

Commit

Permalink
Merge branch 'main' into fb_test_portal
Browse files Browse the repository at this point in the history
  • Loading branch information
drfho authored Jun 12, 2024
2 parents 7f186f3 + 1021c6c commit 137b9a3
Show file tree
Hide file tree
Showing 13 changed files with 433 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class com_zms_catalog_opensearch:
package = ""

# Revision
revision = "1.6.0"
revision = "1.8.2"

# Type
type = "ZMSPackage"
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class adwords:
package = "com.zms.catalog.opensearch"

# Revision
revision = "1.6.1"
revision = "1.8.4"

# Type
type = "ZMSRecordSet"
Expand All @@ -42,7 +42,7 @@ class Attrs:
,"repetitive":0
,"type":"list"}

grid = {"default":"1"
grid = {"default":0
,"id":"_grid"
,"keys":[]
,"mandatory":1
Expand Down Expand Up @@ -80,7 +80,8 @@ class Attrs:
,"repetitive":0
,"type":"url"}

synonyms = {"default":""
synonyms = {"custom":1
,"default":""
,"id":"synonyms"
,"keys":[]
,"mandatory":0
Expand All @@ -89,22 +90,48 @@ class Attrs:
,"repetitive":0
,"type":"string"}

category = {"default":""
category = {"custom":1
,"default":""
,"id":"category"
,"keys":["##"
,"return ["
," ('person','Person'),"
," ('news','News'),"
," ('direkt','Direkteinstiege'),"
," ('universitaet','Universität'),"
," ('study','Studium'),"
," ('event','Veranstaltung'),"
," ('tip','Tipp')"
," ('forschung','Forschung'),"
," ('weiterbildung','Weiterbildung'),"
," ('fakultaeten','Fakultäten'),"
," ('institute','Institute und Zentren'),"
," ('microsites','Microsites'),"
," ('apps','Applikationen'),"
," ('extern','Externe Seiten')"
,"]"]
,"mandatory":0
,"multilang":0
,"name":"Category"
,"repetitive":0
,"type":"select"}

title = {"custom":1
,"default":""
,"id":"title"
,"keys":[]
,"mandatory":0
,"multilang":0
,"name":"Ext.Link: Title"
,"repetitive":0
,"type":"string"}

attr_dc_description = {"custom":1
,"default":""
,"id":"attr_dc_description"
,"keys":[]
,"mandatory":0
,"multilang":0
,"name":"Ext.Link: Text"
,"repetitive":0
,"type":"string"}

icon_clazz = {"custom":"far fa-list-alt text-danger"
,"default":""
,"id":"icon_clazz"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,47 @@

def get_target_nodes(adword):
rows = zmscontext.attr('records')
zmsnodes = [zmscontext.getLinkObj(row.get('url')) for row in rows if (row.get('adword').lower()==adword or (adword in row.get('synonyms').lower())) ]
zmsnodes = [zmscontext.getLinkObj(row.get('url')) for row in rows if ((row.get('adword').lower()==adword or (adword in row.get('synonyms').lower())) and not row.get('url').startswith('http'))]
return zmsnodes

def get_target_extlinks(adword):
rows = zmscontext.attr('records')
extlinks = [{'index_html':row.get('url'),'title':row.get('title'),'attr_dc_description':row.get('attr_dc_description')} for row in rows if ((row.get('adword').lower()==adword or (adword in row.get('synonyms').lower())) and row.get('url').startswith('http'))]
return extlinks


# ##########################################################
# TODO: process synonyms and multiple node of same keyword
# ##########################################################
target_nodes = get_target_nodes(adword)
target_extlinks = get_target_extlinks(adword)

targets_as_dict = {}
targets = {'adword':adword, 'docs':[] }

if target_nodes:
# Extract content form target
# Extract content from target node
for target_node in target_nodes:
titleimage_url = target_node.attr('titleimage') and target_node.attr('titleimage').getHref(zmscontext.REQUEST) or ''
if not titleimage_url:
document_images = target_node.getObjChildren('e',zmscontext.REQUEST,['ZMSGraphic'])
if document_images:
titleimage_url = document_images[0].attr('img').getHref(zmscontext.REQUEST)

target_as_dict = {
'title': target_node.attr('title'),
'attr_dc_description': target_node.attr('attr_dc_description') or target_node.attr('text'),
'title': target_node.attr('seotitle_tag') or target_node.attr('title'),
'attr_dc_description': target_node.attr('seometa_tag') or target_node.attr('attr_dc_description') or target_node.attr('text'),
'index_html': target_node.getHref2IndexHtml(zmscontext.REQUEST),
'titleimage': titleimage_url
}
targets['docs'].append({'doc':target_as_dict})

if target_extlinks:
# Extract content from adwords dataset
for target_extlink in target_extlinks:
target_as_dict = {
'title': target_extlink['title'],
'attr_dc_description': target_extlink['attr_dc_description'],
'index_html': target_extlink['index_html'],
'titleimage': ''
}
targets['docs'].append({'doc':target_as_dict})


return targets
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ class opensearch_connector:
package = "com.zms.catalog.opensearch"

# Revision
revision = "1.7.4"
revision = "1.7.5"

# Type
type = "ZMSLibrary"

# Attrs
class Attrs:
properties = {"custom":"[\r\n {\r\n \"id\": \"opensearch.url\",\r\n \"type\": \"string\",\r\n \"label\": \"URL(s)\",\r\n \"default_value\": \"https://localhost:9200\",\r\n \"is_target_of\": \"\"\r\n },\r\n {\r\n \"id\": \"opensearch.username\",\r\n \"type\": \"string\",\r\n \"label\": \"Username\",\r\n \"default_value\": \"admin\",\r\n \"is_target_of\": \"\"\r\n },\r\n {\r\n \"id\": \"opensearch.password\",\r\n \"type\": \"password\",\r\n \"label\": \"Password\",\r\n \"default_value\": \"admin\",\r\n \"is_target_of\": \"\"\r\n },\r\n {\r\n \"id\": \"opensearch.schema\",\r\n \"type\": \"text\",\r\n \"label\": \"Schema\",\r\n \"default_value\": \"{}\",\r\n \"is_target_of\": \"schematize\"\r\n },\r\n {\r\n \"id\": \"opensearch.parser\",\r\n \"type\": \"string\",\r\n \"label\": \"Parser\",\r\n \"default_value\": \"http://localhost:9998/tika\",\r\n \"is_target_of\": \"\"\r\n },\r\n {\r\n \"id\": \"opensearch.score_script\",\r\n \"type\": \"text\",\r\n \"label\": \"Score-Script (Painless)\",\r\n \"default_value\": \"return _score;\",\r\n \"is_target_of\": \"\"\r\n }\r\n]"
properties = {"custom":"[\r\n {\r\n \"id\": \"opensearch.url\",\r\n \"type\": \"string\",\r\n \"label\": \"URL(s)\",\r\n \"default_value\": \"https://localhost:9200\",\r\n \"is_target_of\": \"\"\r\n },\r\n {\r\n \"id\": \"opensearch.username\",\r\n \"type\": \"string\",\r\n \"label\": \"Username\",\r\n \"default_value\": \"admin\",\r\n \"is_target_of\": \"\"\r\n },\r\n {\r\n \"id\": \"opensearch.password\",\r\n \"type\": \"password\",\r\n \"label\": \"Password\",\r\n \"default_value\": \"admin\",\r\n \"is_target_of\": \"\"\r\n },\r\n {\r\n \"id\": \"opensearch.schema\",\r\n \"type\": \"text\",\r\n \"label\": \"Schema\",\r\n \"default_value\": \"{}\",\r\n \"is_target_of\": \"schematize\"\r\n },\r\n {\r\n \"id\": \"opensearch.parser\",\r\n \"type\": \"string\",\r\n \"label\": \"Parser\",\r\n \"default_value\": \"http://localhost:9998/tika\",\r\n \"is_target_of\": \"\"\r\n },\r\n {\r\n \"id\": \"opensearch.score_script\",\r\n \"type\": \"text\",\r\n \"label\": \"Score-Script (Painless)\",\r\n \"default_value\": \"return _score;\",\r\n \"is_target_of\": \"\"\r\n },\r\n {\r\n \"id\": \"opensearch.suggest.fields.unibe\",\r\n \"type\": \"string\",\r\n \"label\": \"Suggest-Fields: unibe\",\r\n \"default_value\": \"['title', 'attr_dc_description']\",\r\n \"is_target_of\": \"\"\r\n },\r\n {\r\n \"id\": \"opensearch.suggest.fields.unitel\",\r\n \"type\": \"string\",\r\n \"label\": \"Suggest-Fields: unitel\",\r\n \"default_value\": \"['Vorname', 'Nachname']\",\r\n \"is_target_of\": \"\"\r\n }\r\n]"
,"default":""
,"id":"properties"
,"keys":[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get_opensearch_client(self):
http_auth = auth,
use_ssl = use_ssl,
verify_certs = verify,
ssl_assert_hostname = False,
ssl_assert_hostname = verify,
ssl_show_warn = False,
)
return client
Expand Down Expand Up @@ -143,7 +143,7 @@ def opensearch_query( self, REQUEST=None):

# No multisite-search: show only results of current ZMS-client
if multisite_search==0 and len(home_id) > 0:
query['query']['bool']['must'].append( {
query['query']['script_score']['query']['bool']['must'].append( {
"match": {
"home_id": str(home_id)
}
Expand All @@ -152,10 +152,10 @@ def opensearch_query( self, REQUEST=None):
# Exclusion of ZMS-Clients (home_id exclusions) via 'must_not' operator
if multisite_exclusions[0]!='':
# init 'must_not' operator
query['query']['bool']['must_not'] = []
query['query']['script_score']['query']['bool']['must_not'] = []
# add must_not for each home_id
for home_id in multisite_exclusions:
query['query']['bool']['must_not'].append( {
query['query']['script_score']['query']['bool']['must_not'].append( {
"match": {
"home_id": str(home_id)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def get_opensearch_client(self):
http_auth = auth,
use_ssl = use_ssl,
verify_certs = verify,
ssl_assert_hostname = verify,
ssl_show_warn = False,
)
return client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,57 @@ class opensearch_page:
# Id
id = "opensearch_page"

# Lang_dict
lang_dict = {"opensearch_page.BTN_SEARCH":{"eng":"Search"
,"fra":"Recherche"
,"ger":"Suchen"
,"ita":"Ricerca"}
,"opensearch_page.INFO_KEYWORD":{"eng":"Keyword"
,"fra":"Mot-clé"
,"ger":"Stichwort"
,"ita":"Parola chiave"}
,"opensearch_page.INFO_LOADING":{"eng":"Is loading ..."
,"fra":"En attendant ..."
,"ger":"Wird geladen..."
,"ita":"In attesa ..."}
,"opensearch_page.INFO_RESULTS":{"eng":"Hits"
,"fra":"Résultats"
,"ger":"Treffer"
,"ita":"Colpi"}
,"opensearch_page.INFO_RESULTS_FOR":{"eng":"Hits for"
,"fra":"Les hits pour"
,"ger":"Treffer für"
,"ita":"Colpi per"}
,"opensearch_page.INFO_SEARCH":{"eng":"Search for Keywords"
,"fra":"Recherche de mots-clés"
,"ger":"Suche nach Stichworten"
,"ita":"Ricerca per parole chiave"}
,"opensearch_page.INFO_UNIBE":{"eng":"Content"
,"fra":"Contenu"
,"ger":"Inhalte"
,"ita":"Contenuto"}
,"opensearch_page.INFO_UNITEL":{"eng":"Persons"
,"fra":"Personnes"
,"ger":"Personen"
,"ita":"Persone"}
,"opensearch_page.SEARCH_FOR":{"eng":"Search for"
,"fra":"Recherche de"
,"ger":"Suche nach"
,"ita":"Ricerca di"}
,"opensearch_page.TOP_RESULTS":{"eng":"Top Hits"
,"fra":"Meilleurs résultats"
,"ger":"Top-Treffer"
,"ita":"Colpo di punta"}}


# Name
name = "Opensearch-Page"

# Package
package = "com.zms.catalog.opensearch"

# Revision
revision = "1.6.1"
revision = "1.8.6"

# Type
type = "ZMSDocument"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,27 @@

catalog =zmsindex.get_catalog()
q = catalog({ cat_attr_name : str(id) })
obj_path = []
zmsobj = None
zmsobj_path = []
for r in q:
uid = r['get_uid']
pth = r['getPath']
zms_data_id = '{$%s}'%uid
# return '%s\n%s'%(zmsindex.getLinkObj(zms_data_id), r.getObject())
# return zmscontext.getLinkObj(zms_data_id).attr('standard_html')
obj_path = zmscontext.getLinkObj(zms_data_id).breadcrumbs_obj_path()
zmsobj = zmscontext.getLinkObj(zms_data_id)
if zmsobj:
zmsobj_path = zmsobj.breadcrumbs_obj_path(portalMaster=False)

# Return HTML for Ajax-Requests
if len(obj_path) > 2:
obj_path = obj_path[:-1]
return '\n'.join(['<li><a href="%s">%s</a></li>'%(obj.getHref2IndexHtml(request), obj.attr('titlealt')) for obj in obj_path])
## Return HTML for Ajax-Requests
if len(zmsobj_path) > 2:
zmsobj_path = zmsobj_path[:-1]
## #############################################
## A. Basic URL Generation: getHref2IndexHtml()
return '\n'.join(['<li><a href="%s">%s</a></li>'%(obj.getHref2IndexHtml(request), obj.attr('titlealt')) for obj in zmsobj_path if obj.attr('titlealt')])
## #############################################
## B. Specific URL Generation: custom function getHref2SubdomainHtml()
# return '\n'.join(['<li><a href="%s">%s</a></li>'%(zmscontext.UniBE_zeix_('getHref2SubdomainHtml',item=obj), obj.attr('titlealt')) for obj in zmsobj_path if obj.attr('titlealt')])
## #############################################

# --// /opensearch_breadcrumbs_obj_path //--
Loading

0 comments on commit 137b9a3

Please sign in to comment.