@@ -68,7 +68,7 @@ def _generate_menu(all_items, flt=None):
6868 return menu_html
6969
7070
71- def build_from_items (items , filename , title = 'Gallery' , subtitle = None , menu_html = '' ):
71+ def build_from_items (items , filename , title = 'Gallery' , subtitle = None , menu_html = '' , max_descr_len = 300 ):
7272
7373 # Build the gallery file
7474 panels_body = []
@@ -102,22 +102,19 @@ def build_from_items(items, filename, title='Gallery', subtitle=None, menu_html=
102102 else :
103103 _str = affiliation_name
104104 affiliation_strs .add (_str )
105+
105106 authors_str = f"<strong>Author:</strong> { ', ' .join (author_strs )} "
106107 if affiliation_strs :
107108 affiliations_str = f"<strong>Affiliation:</strong> { ' ' .join (affiliation_strs )} "
108109 else :
109110 affiliations_str = ''
110111
111- panels_body .append (
112- f"""\
113- ---
114-
115- <button type="button" class="btn modal-btn w-100 h-100">
116- <div class="text-center">
117- <img src="{ thumbnail } " class="gallery-thumbnail" />
118- <strong>{ item ["title" ]} </strong>
119- </div>
120- </button>
112+ if len (item ['description' ]) < max_descr_len :
113+ short_description = item ['description' ]
114+ modal_str = ''
115+ else :
116+ short_description = item ['description' ][:max_descr_len ] + ' <a class="modal-btn">...more</a>'
117+ modal_str = f"""
121118<div class="modal">
122119<div class="content">
123120<img src="{ thumbnail } " class="modal-img" />
@@ -130,6 +127,21 @@ def build_from_items(items, filename, title='Gallery', subtitle=None, menu_html=
130127<p class="mt-3"><a href="{ item ["url" ]} " class="btn btn-outline-primary btn-block">Visit Website</a></p>
131128</div>
132129</div>
130+ """
131+
132+ panels_body .append (
133+ f"""\
134+ ---
135+
136+ <div class="d-flex">
137+ <img src="{ thumbnail } " class="gallery-thumbnail" />
138+ <div class="container">
139+ <a href="{ item ["url" ]} " class="text-decoration-none"><h4 class="display-4 p-0">{ item ["title" ]} </h4></a>
140+ <p class="card-subtitle">{ authors_str } <br/>{ affiliations_str } </p>
141+ <p class="my-2">{ short_description } </p>
142+ </div>
143+ </div>
144+ { modal_str }
133145
134146+++
135147
@@ -153,16 +165,17 @@ def build_from_items(items, filename, title='Gallery', subtitle=None, menu_html=
153165{ menu_html }
154166
155167````{{panels}}
156- :column: text-left col-lg-3 col-md-4 col-sm-6
157- :card: +mb-4
168+ :column: col-12
169+ :card: +mb-4 w-100
158170:header: d-none
159- :body: p-0 m-0
171+ :body: p-3 m-0
160172:footer: p-1
161173
162174{ dedent (panels_body )}
163175````
164176
165177<div class="modal-backdrop"></div>
178+ <script src="_static/custom.js"></script>
166179"""
167180
168181 pathlib .Path (f'{ filename } .md' ).write_text (panels )
0 commit comments