@@ -39,10 +39,14 @@ def generate_embed(url, response_type=False, css=False):
3939 return flask .jsonify ({"error" : "Could not fetch GTN page." }), 500
4040
4141 soup = BeautifulSoup (gtn_data .text , "html.parser" )
42- # itemprop="acceptedAnswer"
43- answer = soup .find ("div" , {"itemprop" : "acceptedAnswer" })
44- # Find the col-md-8 child
45- answer = answer .find ("div" , {"class" : "col-md-8" })
42+ if '/faqs/' in url :
43+ # itemprop="acceptedAnswer"
44+ answer = soup .find ("div" , {"itemprop" : "acceptedAnswer" })
45+ # Find the col-md-8 child
46+ answer = answer .find ("div" , {"class" : "col-md-8" })
47+ else :
48+ answer = soup .find ("div" , {"class" : "main-content" })
49+
4650 # get the page <title>
4751 answer_title = soup .find ("title" ).text
4852 og_desc = soup .find ("meta" , {"property" : "og:description" })["content" ]
@@ -62,6 +66,7 @@ def generate_embed(url, response_type=False, css=False):
6266 elif a ["href" ].startswith ("#" ):
6367 a ["href" ] = url + a ["href" ]
6468 elif a ["href" ].startswith (".." ):
69+ a ["href" ] = '/' .join (url .split ('/' )[0 :- 1 ]) + '/' + a ["href" ]
6570 print (f"Found a relative path, { url } - { a ['href' ]} " )
6671 elif a ["href" ].startswith ("http" ):
6772 pass
@@ -78,6 +83,7 @@ def generate_embed(url, response_type=False, css=False):
7883 if img ["src" ].startswith ("/" ):
7984 img ["src" ] = GTN_URL + img ["src" ]
8085 elif img ["src" ].startswith (".." ):
86+ img ["src" ] = '/' .join (url .split ('/' )[0 :- 1 ]) + '/' + img ["src" ]
8187 print (f"Found a relative path, { url } - { img ['src' ]} " )
8288 elif img ["src" ].startswith ("http" ):
8389 pass
@@ -109,14 +115,19 @@ def generate_embed(url, response_type=False, css=False):
109115 data ['thumbnail_height' ] = 400
110116 else :
111117 data ["html" ] = f"""
118+ <style>
119+ a[target="_blank"]::after { '{' } content: "" !important; { '}' }
120+ </style>
112121 <section style="border: 1px solid #2c3143; box-shadow: 5px 6px #b2b2b2;margin:1rem 0;">
113122 <div style="border-bottom: 3px solid #2c3143; padding:0.8rem;display: flex; justify-content: space-between; align-items: center;">
114123 <span>
115124 Content from
116125 <a href="{ url } ?utm_source=galaxy-help&utm_medium=oembed&utm_campaign=oembed">{ answer_title } </a>
117126 </span>
118127 <span>
119- <img src="https://training.galaxyproject.org/training-material/assets/images/GTN-60px.png" style="height: 30px; width: 30px;" alt="Galaxy Training Network logo"> <a href="https://training.galaxyproject.org/training-material/?utm_source=galaxy-help&utm_medium=oembed&utm_campaign=oembed">Galaxy Training!</a>
128+ <a href="https://training.galaxyproject.org/training-material/?utm_source=galaxy-help&utm_medium=oembed&utm_campaign=oembed">
129+ <img src="https://training.galaxyproject.org/training-material/assets/images/GTN-60px.png" style="height: 30px; width: 30px;" alt="GTN logo">
130+ </a>
120131 </span>
121132 </div>
122133 <div style="padding: 0.8rem;">
0 commit comments