Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -145,9 +145,7 @@ def create_bibtex_entry(data):
|
|
145 |
return bibtex
|
146 |
|
147 |
def save_bibtex(bibtex_content):
|
148 |
-
|
149 |
-
temp_file.write(bibtex_content)
|
150 |
-
return temp_file.name
|
151 |
|
152 |
class CombinedProcessor:
|
153 |
def process(self, user_message):
|
@@ -203,16 +201,32 @@ processor = CombinedProcessor()
|
|
203 |
|
204 |
# Define the Gradio interface
|
205 |
with gr.Blocks(theme='JohnSmith9982/small_and_pretty') as demo:
|
206 |
-
gr.HTML("""<h1 style="text-align:center">Reversed Zotero
|
207 |
text_input = gr.Textbox(label="Your text", type="text", lines=10)
|
208 |
text_button = gr.Button("Process Text")
|
209 |
-
bibtex_output = gr.Textbox(label="BibTeX Entries", lines=15)
|
210 |
|
211 |
-
|
212 |
-
|
|
|
213 |
|
214 |
text_button.click(processor.process, inputs=text_input, outputs=[bibtex_output])
|
215 |
-
export_button.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
|
217 |
if __name__ == "__main__":
|
218 |
demo.queue().launch()
|
|
|
145 |
return bibtex
|
146 |
|
147 |
def save_bibtex(bibtex_content):
|
148 |
+
return bibtex_content
|
|
|
|
|
149 |
|
150 |
class CombinedProcessor:
|
151 |
def process(self, user_message):
|
|
|
201 |
|
202 |
# Define the Gradio interface
|
203 |
with gr.Blocks(theme='JohnSmith9982/small_and_pretty') as demo:
|
204 |
+
gr.HTML("""<h1 style="text-align:center">Reversed Zotero</h1>""")
|
205 |
text_input = gr.Textbox(label="Your text", type="text", lines=10)
|
206 |
text_button = gr.Button("Process Text")
|
|
|
207 |
|
208 |
+
with gr.Row():
|
209 |
+
bibtex_output = gr.Textbox(label="BibTeX Entries", lines=15)
|
210 |
+
export_button = gr.Button("Export", size="sm")
|
211 |
|
212 |
text_button.click(processor.process, inputs=text_input, outputs=[bibtex_output])
|
213 |
+
export_button.click(
|
214 |
+
save_bibtex,
|
215 |
+
inputs=[bibtex_output],
|
216 |
+
outputs=[gr.File(label="BibTeX File", visible=False)],
|
217 |
+
_js="""
|
218 |
+
(bibtex) => {
|
219 |
+
const blob = new Blob([bibtex], { type: 'text/plain' });
|
220 |
+
const url = URL.createObjectURL(blob);
|
221 |
+
const a = document.createElement('a');
|
222 |
+
a.href = url;
|
223 |
+
a.download = 'bibliography.bib';
|
224 |
+
a.click();
|
225 |
+
URL.revokeObjectURL(url);
|
226 |
+
return [null]; // Return null to avoid updating the invisible gr.File
|
227 |
+
}
|
228 |
+
"""
|
229 |
+
)
|
230 |
|
231 |
if __name__ == "__main__":
|
232 |
demo.queue().launch()
|