From eb8def8543b39a3fafcdcf7bb0c0091cbcb7d404 Mon Sep 17 00:00:00 2001 From: Dcosthephalump Date: Thu, 3 Aug 2023 12:23:59 -0600 Subject: [PATCH] styled and added xml upload functions --- .../__pycache__/__init__.cpython-311.pyc | Bin 173 -> 173 bytes .../__pycache__/annotation.cpython-311.pyc | Bin 2141 -> 5064 bytes glyptodon/__pycache__/classes.cpython-311.pyc | Bin 9026 -> 9026 bytes glyptodon/__pycache__/export.cpython-311.pyc | Bin 2122 -> 3203 bytes .../__pycache__/information.cpython-311.pyc | Bin 4638 -> 4638 bytes .../manuscriptFiles.cpython-311.pyc | Bin 11594 -> 11594 bytes .../__pycache__/selection.cpython-311.pyc | Bin 2178 -> 2502 bytes glyptodon/_modidx.py | 3 + glyptodon/annotation.py | 42 +++-- glyptodon/app.py | 164 ++++------------ glyptodon/export.py | 60 ++++-- glyptodon/manuscriptFiles.py | 29 ++- nbs/01_manuscriptFiles.ipynb | 178 +++++++----------- nbs/04_annotation.ipynb | 24 ++- nbs/06_export.ipynb | 12 +- nbs/07_app.ipynb | 105 +++++++++-- 16 files changed, 319 insertions(+), 298 deletions(-) diff --git a/glyptodon/__pycache__/__init__.cpython-311.pyc b/glyptodon/__pycache__/__init__.cpython-311.pyc index 8536daaa5b4e159d4e2313ea3d1c58dfebd34063..f3242e38af643d8035614cb525ac512235e3776e 100644 GIT binary patch delta 19 ZcmZ3>xR#N7IWI340}vd!etIJJA^xR#N7IWI340}${(IW>`c5dbb^1ug&p diff --git a/glyptodon/__pycache__/annotation.cpython-311.pyc b/glyptodon/__pycache__/annotation.cpython-311.pyc index 144a111b6c306fdcee4af542ab141f65de321a9f..d9c2fdf0e1229ac1a3687c0e144b3fc5437fb36e 100644 GIT binary patch literal 5064 zcmcInOK%(36`tV?AL5XDQ*2@>T*K0klv61Mwn@A}CxN_QF5G1&VI6Ap;r_1`rS+)xx_GtZcGr&$+`ltu9*R zlJoK2Gxv4ghkuJk!yL4KeDf6{JskHP4yw&p>AYH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ZQ>0E7z0I5aTHhiHs#Jv0!W4bX|{PyEbSBA=bRegX7&1OwwM VSgt38OhqO}FcLT&qG?1w{~Kn^y`%sD diff --git a/glyptodon/__pycache__/classes.cpython-311.pyc b/glyptodon/__pycache__/classes.cpython-311.pyc index 61b470c9f12e734cae835bee5072218e6f28f296..275c403efa2851db3506bf680cd6e1d400af2896 100644 GIT binary patch delta 20 acmX@)cF2u;IWI340}vd!etILfxiSDm+XiC* delta 20 acmX@)cF2u;IWI340}wo~JGqhDTp0jEum&pt diff --git a/glyptodon/__pycache__/export.cpython-311.pyc b/glyptodon/__pycache__/export.cpython-311.pyc index 1b436781ac3c6c09a6ca7d3d2e52f9384bfcaa1c..3d32b611eb90c03a2fc20ca57574338d3eb3990d 100644 GIT binary patch literal 3203 zcmaJ@O>7%Q6rSDn|2jW5cG{$-njj!`l^=d8RH}kR8=#R&QmH=@IS@9UjlJ!9*UYXP zY!38*1W36cMJfkQ9D=I!&?83<9FVv;QY504A|at1dUMqD(i88^t{tz_WaRxkKW}E< zoA=%~^V`5cia`1EpTF4#)c(Upr^rF&*&V1nBxSgmRsdhKd5;vpXRAkhnM@D0jQ{P;ciP zi5u@o5^^`vsWWK<=4~F%?UjmlrQ{Q&VjZc_4&8N_a>Cq0sYqC=eA14I&W;;U+3YmJ z79Q#z?OVC89Ug_Kh|PO3KOCBW-KrQ4t?E{tYNlzgIutxdU7PA6T&P>oX;ri8PKg^e zmueQHF4ru-i6MgW6ZdtxYV&(KqqapghibHG)N0UNu}!A)Y5F-VTGA|Ppub_*f}n#z zF4hmpiY*+7jgm`OE1FB83hKEIwO52RZX}dk)hrh^b+r5XCEEOQZYA7Z(YP*V7*(yT zi}|1{?=feR1{rB#;X_W5ujx39O6$h%( z6~ojint|C08k#0u*2{)PoeI!`*`Oucay7#;tg=`m@^!cZ50CFcBi5Fsd_&q-luY)306b5SOnyDSce?OP zyiLgXRe7I~(OLOG;BKe;mgv4Mx^K(vsFEMqSE9HE!1J_Nk%gmbBi{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JPaAvSHI#GPRJEE13wDO5oMtUXerUn6_ zi5^+M%umC5qSp#E;kY)NE`cG4OI#IyNam6hWvxJcvs$$sr&{%OW_Pwj&Br&TjnCFz((D8ygOCbRGW diff --git a/glyptodon/__pycache__/information.cpython-311.pyc b/glyptodon/__pycache__/information.cpython-311.pyc index 3b80729a43760a2f9f25b69ae81c547ae2ccec6f..fb8f622b7cf0557cc5100cbdd904cbb0f4c2c9ed 100644 GIT binary patch delta 20 acmbQIGEaqjIWI340}vd!etILfun+(`Vg;fA delta 20 acmbQIGEaqjIWI340}${(Ikk~nSO@?$xCHqC diff --git a/glyptodon/__pycache__/manuscriptFiles.cpython-311.pyc b/glyptodon/__pycache__/manuscriptFiles.cpython-311.pyc index 7913ac6f1a109ce2f3c04b1a3169f3e56f25134d..08302a3c49469e5a4d91f60290a6ddfbcfe109d8 100644 GIT binary patch delta 20 acmX>Vbt;N`IWI340}vd!etILfy)FPq^#-i~ delta 20 acmX>Vbt;N`IWI340}!OvpWMi8uL}S~LIv~y diff --git a/glyptodon/__pycache__/selection.cpython-311.pyc b/glyptodon/__pycache__/selection.cpython-311.pyc index 4571b0b57cd3e27e0bdfba66969d903e09b8520e..0032c64056051dfea7cba56e9c5f877b51a93ee5 100644 GIT binary patch delta 1036 zcmZXTO=uHA6vtPiY*Ga$RVm_*v$EIa*q6mtYFha}FI^nA88A8*6 z^_)tbxA-e1VQyY9j#6aI3y$XsxvZPFOO;PNDUbHs%*?W!<>pMwEamQ-MXOYHvMfL2 z4)dq-&AF7qVz9d>pS2kEG{F&@&N6XdPZ~Yq;VW+t+W|e+Cm=NV*aeAm88D9;MtI>^ zLo*gaKO^y)`odU=46R0n8qiUi67IQ&TZBYoZ3Jirl&)}#XhFS=00&z{4=HT~Xd*qJ z_$Osy*NqU`{lXoF!tI=+5+!ftB^X&2qke$&z*r@AAz!iz`AW{*sDY=>uzb;Cvz6Gb zwaK)zUZ9lZ1+sR*W-J1`q@+$Al##OQ+9fs!WB%KGrfGKk z73F3EhoL!l`JlRg{Nj_$LZ%VwUKsrmA8N!CwTsnEEz^h}T#2Vw(!MM7b)6)=CHnM9$)i{831P?rb%(xgKCnYts{M=j^hjVar99hX@%H?nqd#xCVb zuESz{Q61j1*@VB^iK0!*h1@AN43`tXic{mi)T8>oI$C@9Zf(y=1H;F(fh5M)a1;GU NErQJ^+6w<}{{S?q=qmsK delta 760 zcmZXR!D|yi6vk(Eb~m%T&9;rJ-B7hDwb)HbQLk1H#e`nWr6AHv44srlw+YN92qD@c zA|8qm=b(7=5)nPYI(miVxmz-y3%3ec#N-6A#AiSIMM_ zAimuH#6rDeyLhQ{{_HGas;_Qps~Sd3dx%zbrUMf!0i=uq4Q6zB^ZnPCSmOyeKs-@i zU`u$UYZ7Q>{>+MfGI^2VE=K4LVA(s1k)j*4Pw0q# zhyW3ynjY_4gMWshLKUlDfZ`cy40R)P8;kFRZZXW1x1_6pDab*9DYe*26{@weUu{+X z+G?fNf3M|&KUO`=$6y=Spz!JGOU*{3UgM{sIp#wO;SwHXApJ=nqdO-rhZFPRg=?Xe z-?j34Rz6hoJS{$uG=3*Soh65&+PGneY3zy{>X^*YdrBL%m30Nw;-aUCFyYvP5rjK( z+{9DrIPooNvX#g|1|=~^=WZ^4cFr9*^Se%N&&fp^8Bg_zmb4EMAkwH|_K9i3|?*BipcxPT*cjMT=N2>p*(#t|(8qw@d& diff --git a/glyptodon/_modidx.py b/glyptodon/_modidx.py index 671b824..f1efa52 100644 --- a/glyptodon/_modidx.py +++ b/glyptodon/_modidx.py @@ -54,6 +54,7 @@ 'glyptodon.export.createExportButton': ('export.html#createexportbutton', 'glyptodon/export.py'), 'glyptodon.export.createExportDownload': ('export.html#createexportdownload', 'glyptodon/export.py'), 'glyptodon.export.createExportInfo': ('export.html#createexportinfo', 'glyptodon/export.py'), + 'glyptodon.export.createExportLayout': ('export.html#createexportlayout', 'glyptodon/export.py'), 'glyptodon.export.createExportName': ('export.html#createexportname', 'glyptodon/export.py')}, 'glyptodon.information': { 'glyptodon.information.createCenturiesSlider': ( 'information.html#createcenturiesslider', 'glyptodon/information.py'), @@ -80,6 +81,8 @@ 'glyptodon/manuscriptFiles.py'), 'glyptodon.manuscriptFiles.saveImages': ( 'manuscriptfiles.html#saveimages', 'glyptodon/manuscriptFiles.py'), + 'glyptodon.manuscriptFiles.saveTranscripts': ( 'manuscriptfiles.html#savetranscripts', + 'glyptodon/manuscriptFiles.py'), 'glyptodon.manuscriptFiles.updateMetadata': ( 'manuscriptfiles.html#updatemetadata', 'glyptodon/manuscriptFiles.py'), 'glyptodon.manuscriptFiles.zipManuscript': ( 'manuscriptfiles.html#zipmanuscript', diff --git a/glyptodon/annotation.py b/glyptodon/annotation.py index 5b917fc..de049d9 100644 --- a/glyptodon/annotation.py +++ b/glyptodon/annotation.py @@ -35,27 +35,27 @@ def createAnnotationInfo(): ) ) -# %% ../nbs/04_annotation.ipynb 9 +# %% ../nbs/04_annotation.ipynb 10 def createAnnotationTextArea(): - return dbc.Textarea(id="annotation-text-area",value="Enter transcription text here!",style={"width":"100%","height":285}) + return dbc.Textarea(id="annotation-text-area",value="Enter transcription text here!",style={"width":"100%","height":800}) -# %% ../nbs/04_annotation.ipynb 12 +# %% ../nbs/04_annotation.ipynb 13 def createPageSelector(): return dcc.Dropdown(id="page-selector") -# %% ../nbs/04_annotation.ipynb 15 +# %% ../nbs/04_annotation.ipynb 16 def createSaveShapes(): return dbc.Button("Save Shapes", color="info", id="save-shapes") -# %% ../nbs/04_annotation.ipynb 17 +# %% ../nbs/04_annotation.ipynb 18 def createSaveAnnotation(): return dbc.Button("Save Transcription", color="info", id="save-annotation") -# %% ../nbs/04_annotation.ipynb 19 +# %% ../nbs/04_annotation.ipynb 20 def createNextTab(): return dbc.Button("Next Tab", color="primary", id="next-tab") -# %% ../nbs/04_annotation.ipynb 21 +# %% ../nbs/04_annotation.ipynb 22 def createAnnotationFigure(path): img = cv2.imread(path) # This reorders the color channels (the first two indices relate to the intensity values of individual colors while the last index indicates what @@ -67,7 +67,7 @@ def createAnnotationFigure(path): opacity=0.6)) return fig -# %% ../nbs/04_annotation.ipynb 25 +# %% ../nbs/04_annotation.ipynb 26 def createFigureLayout(): return dbc.Card( [ @@ -81,16 +81,20 @@ def createFigureLayout(): "eraseshape", ] }, + style={ + "height": 800, + "width": 800, + }, ), createSaveShapes(), ] ) -# %% ../nbs/04_annotation.ipynb 28 +# %% ../nbs/04_annotation.ipynb 29 def createTextareaLayout(): return dbc.Card([createAnnotationTextArea(), createSaveAnnotation()]) -# %% ../nbs/04_annotation.ipynb 31 +# %% ../nbs/04_annotation.ipynb 32 def createAnnotationLayout(): return html.Div( [ @@ -99,12 +103,18 @@ def createAnnotationLayout(): dbc.Card( [ dbc.Container( - dbc.Row( - children=[ - dbc.Col(createFigureLayout(), md=7), - dbc.Col(createTextareaLayout(), md=5), - ] - ) + [ + dbc.Row( + children=[ + dbc.Col(createFigureLayout(), md=7), + dbc.Col(createTextareaLayout(), md=5), + ] + ) + ], + style={ + "height": "95%", + "width": "95%", + }, ), createNextTab(), ] diff --git a/glyptodon/app.py b/glyptodon/app.py index 4ccd576..8ffadc5 100644 --- a/glyptodon/app.py +++ b/glyptodon/app.py @@ -1,13 +1,10 @@ # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/07_app.ipynb. # %% auto 0 -__all__ = ['selectionKey', 'manuscriptSelect', 'selectionInfo', 'finalizeSelection', 'inputObjects', 'centuries', - 'centuriesSlider', 'uploadImages', 'uploadManuscripts', 'informationInfo', 'saveNContinue', - 'annotationTextArea', 'pageSelector', 'saveShapes', 'saveAnnotation', 'nextTab', 'exportInfo', 'exportName', - 'directoryOptions', 'exportButton', 'exportDownload', 'app', 'newManuscript', 'selectedManuscript', - 'selectManuscript', 'finalizeSelectionCallback', 'pageSelectorCallback', 'saveShapesCallback', - 'lineNumberCallback', 'saveAnnotationCallback', 'saveNContinuteCallback', 'nextTabCallback', - 'exportManuscriptCallback'] +__all__ = ['selectionKey', 'selectionLayout', 'centuries', 'informationLayout', 'annotationLayout', 'exportLayout', 'app', + 'newManuscript', 'selectedManuscript', 'selectManuscript', 'finalizeSelectionCallback', + 'pageSelectorCallback', 'saveShapesCallback', 'lineNumberCallback', 'saveAnnotationCallback', + 'saveNContinuteCallback', 'nextTabCallback', 'exportManuscriptCallback'] # %% ../nbs/07_app.ipynb 4 from dash import Dash, State, Input, Output, callback, dcc, html @@ -21,50 +18,20 @@ import re import os -# %% ../nbs/07_app.ipynb 6 -################# -### SELECTION ### -################# -selectionKey, manuscriptSelect = createManuscriptSelect() -selectionInfo = createSelectionInfo() -finalizeSelection = createFinalizeSelection() - -# Global Variables: selectionKey - -################### -### INFORMATION ### -################### -# the ids for objects in inputObjects are: "work", "author", "language", "country", "city", "institution" -inputObjects = createInputObjects() -centuries, centuriesSlider = createCenturiesSlider() -uploadImages, uploadManuscripts = createUploadObjects() -informationInfo = createInformationInfo() -# the id for saveNContinue is "save-and-continue" -saveNContinue = createSaveNContinue() - -# Global Variables: centuries - -################## -### ANNOTATION ### -################## -annotationTextArea = createAnnotationTextArea() -pageSelector = createPageSelector() -saveShapes = createSaveShapes() -saveAnnotation = createSaveAnnotation() -nextTab = createNextTab() - - -############## -### EXPORT ### -############## -exportInfo = createExportInfo() -exportName = createExportName() -directoryOptions = createDirectoryOptions() -exportButton = createExportButton() -exportDownload = createExportDownload() - -# %% ../nbs/07_app.ipynb 9 -app = Dash(__name__) +# %% ../nbs/07_app.ipynb 8 +selectionKey, selectionLayout = createSelectionLayout() + +centuries, informationLayout = createInformationLayout() + +annotationLayout = createAnnotationLayout() + +exportLayout = createExportLayout() + +# %% ../nbs/07_app.ipynb 10 +app = Dash( + external_stylesheets=[dbc.themes.BOOTSTRAP] +) + app.layout = html.Div( [ dcc.Tabs( @@ -75,89 +42,33 @@ label="Selection", value="selection", children=[ - html.Div( - [ - selectionInfo, - html.Br(), - manuscriptSelect, - html.Br(), - finalizeSelection, - ] - ) + selectionLayout ], ), dcc.Tab( label="Information", value="information", children=[ - html.Div( - [ - informationInfo, - html.Br(), - html.Div(inputObjects), - html.Br(), - html.Div( - [ - uploadImages, - uploadManuscripts, - ], - id="uploader-container", - ), - html.Br(), - centuriesSlider, - html.Br(), - saveNContinue, - ] - ) + informationLayout ], ), dcc.Tab( label="Annotation", value="annotation", children=[ - html.Div( - [ - pageSelector, - dcc.Graph( - id="annotation-figure", - config={ - "modeBarButtonsToAdd": [ - "drawline", - "drawrect", - "eraseshape", - ] - }, - style={ - "height": 800, - "width": 800, - }, - ), - saveShapes, - annotationTextArea, - saveAnnotation, - nextTab, - ] - ) + annotationLayout ], ), dcc.Tab( label="Export", value="export", children=[ - html.Div( - [ - exportInfo, - exportName, - directoryOptions, - exportButton, - exportDownload, - ] - ) + exportLayout ], ), ], ), - html.Div(id="current-tab"), +# html.Div(id="current-tab"), html.Div( children="no callback", id="dummy-output", @@ -166,7 +77,7 @@ ] ) -# %% ../nbs/07_app.ipynb 11 +# %% ../nbs/07_app.ipynb 14 newManuscript = False selectedManuscript = selectionKey[ "Stavronikita Monastery Greek handwritten document Collection no.53" @@ -217,7 +128,7 @@ def selectManuscript(work): ] return work, author, language, country, city, institution, centuriesValue, {"display": "none"} -# %% ../nbs/07_app.ipynb 13 +# %% ../nbs/07_app.ipynb 16 @callback( Output("page-selector", "options"), Output("page-selector", "value"), @@ -239,7 +150,7 @@ def finalizeSelectionCallback(clicks): return dropdownOptions, dropdownOptions[0]["value"], "information" -# %% ../nbs/07_app.ipynb 15 +# %% ../nbs/07_app.ipynb 18 @callback( Output("annotation-figure", "figure"), Input("page-selector", "value"), @@ -294,7 +205,7 @@ def pageSelectorCallback(path): return fig -# %% ../nbs/07_app.ipynb 17 +# %% ../nbs/07_app.ipynb 20 @callback( Output("dummy-output","children", allow_duplicate=True), Input("save-shapes", "n_clicks"), @@ -360,7 +271,7 @@ def saveShapesCallback(clicks, shapes, path): dummy = ["1","2","3"] return dummy -# %% ../nbs/07_app.ipynb 19 +# %% ../nbs/07_app.ipynb 22 @callback( Output("annotation-text-area","value"), Input("annotation-figure", "relayoutData"), @@ -395,7 +306,7 @@ def lineNumberCallback(shapes, currentText): return newValue -# %% ../nbs/07_app.ipynb 21 +# %% ../nbs/07_app.ipynb 24 @callback( Output("dummy-output", "children", allow_duplicate=True), Input("save-annotation", "n_clicks"), @@ -477,7 +388,7 @@ def saveAnnotationCallback(clicks, shapes, path, currentText): dummy = ["1", "2", "3"] return dummy -# %% ../nbs/07_app.ipynb 23 +# %% ../nbs/07_app.ipynb 26 @callback( Output("tabs-object", "value", allow_duplicate=True), Input("save-and-continue", "n_clicks"), @@ -492,8 +403,8 @@ def saveAnnotationCallback(clicks, shapes, path, currentText): # Upload objects State("upload-images", "contents"), State("upload-images", "filename"), - # State("upload-manuscripts","contents"), - # State("upload-manuscripts","filename"), + State("upload-manuscripts","contents"), + State("upload-manuscripts","filename"), # Conditional object State("manuscript-select", "value"), prevent_initial_call=True, @@ -509,8 +420,8 @@ def saveNContinuteCallback( centuriesValue, # State centuries-slider imContents, # State upload-images imFilenames, # State upload-images - # manContents, - # manFilenames, + manContents, + manFilenames, manSelect, # State manuscript-select ): global selectedManuscript @@ -539,12 +450,13 @@ def saveNContinuteCallback( if manSelect == "Create New Manuscript": selectedManuscript = (createManuscriptDirectory(information), information) saveImages(imContents, imFilenames, selectedManuscript[0]) + saveTranscripts(manContents, manFilenames, selectedManuscript[0]) else: updateMetadata(selectedManuscript[0], information) return "annotation" -# %% ../nbs/07_app.ipynb 25 +# %% ../nbs/07_app.ipynb 28 @callback( Output("tabs-object", "value", allow_duplicate=True), Input("next-tab", "n_clicks"), @@ -553,7 +465,7 @@ def saveNContinuteCallback( def nextTabCallback(clicks): return "export" -# %% ../nbs/07_app.ipynb 27 +# %% ../nbs/07_app.ipynb 30 @callback( Output("export-download", "data"), Input("export-button", "n_clicks"), @@ -566,6 +478,6 @@ def exportManuscriptCallback(clicks, name, options): path = zipManuscript(options, selectedManuscript[0], name) return dcc.send_file(path) -# %% ../nbs/07_app.ipynb 29 +# %% ../nbs/07_app.ipynb 32 if __name__ == "__main__": app.run(debug=True) diff --git a/glyptodon/export.py b/glyptodon/export.py index d50096f..49e8287 100644 --- a/glyptodon/export.py +++ b/glyptodon/export.py @@ -1,28 +1,39 @@ # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/06_export.ipynb. # %% auto 0 -__all__ = ['createExportInfo', 'createExportName', 'createDirectoryOptions', 'createExportButton', 'createExportDownload'] +__all__ = ['createExportInfo', 'createExportName', 'createDirectoryOptions', 'createExportButton', 'createExportDownload', + 'createExportLayout'] # %% ../nbs/06_export.ipynb 5 from dash import dcc, html +import dash_bootstrap_components as dbc from .information import labeledInput # %% ../nbs/06_export.ipynb 7 def createExportInfo(): - return dcc.Markdown( - """ - # Export - - This menu allows you to export the manuscript and transcriptions you've worked on as a zipped folder. - - You can input a name for the zipped folder and select what elements of the work you want to save: - - If you want to share the images of your manuscript, select the 'Images' option from the dropdown. - - If you want to share your transcription with another *glyptodon* user, select the 'States' option from the dropdown. - - Once you have selected the export options, click the export button and a file download will begin shortly containing the zipped folder. - """ + return dbc.Card( + dbc.CardBody( + [ + html.H1("Export"), + html.P( + "This menu allows you to export the manuscript and transcriptions you've worked on as a zipped folder. " + "You can input a name for the zipped folder and select what elements of the work you want to save: " + ), + html.Ul( + [ + html.Li("If you want to share the images of your manuscript, select the 'Images' option from the dropdown"), + html.Li("If you want to share your transcription with another glyptodon user, select the 'States' option from the dropdown") + ] + ), + html.Br(), + html.P( + "Once you have selected the export options, click the export button and a file download will begin shortly containing the zipped folder." + ), + ] + ) ) + # [Reach] - If you want to share xml transcriptions, select the 'Export Transcripts' option from the dropdown. # %% ../nbs/06_export.ipynb 10 @@ -44,8 +55,29 @@ def createDirectoryOptions(): # %% ../nbs/06_export.ipynb 16 def createExportButton(): - return html.Button("Export Manuscript", id="export-button") + return dbc.Button("Export Manuscript", color="primary", id="export-button") # %% ../nbs/06_export.ipynb 19 def createExportDownload(): return dcc.Download(id="export-download") + +# %% ../nbs/06_export.ipynb 21 +def createExportLayout(): + return html.Div( + [ + createExportInfo(), + html.Br(), + dbc.Card( + [ + dbc.CardBody( + [ + createExportName(), + createDirectoryOptions(), + ] + ), + createExportDownload(), + createExportButton(), + ] + ), + ] + ) diff --git a/glyptodon/manuscriptFiles.py b/glyptodon/manuscriptFiles.py index 4b3f7c8..895f83c 100644 --- a/glyptodon/manuscriptFiles.py +++ b/glyptodon/manuscriptFiles.py @@ -1,8 +1,8 @@ # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/01_manuscriptFiles.ipynb. # %% auto 0 -__all__ = ['createManuscriptDirectory', 'dictToList', 'directoryNameClean', 'saveImages', 'currentManuscripts', 'zipManuscript', - 'updateMetadata', 'manuscriptImages'] +__all__ = ['createManuscriptDirectory', 'dictToList', 'directoryNameClean', 'saveImages', 'saveTranscripts', 'currentManuscripts', + 'zipManuscript', 'updateMetadata', 'manuscriptImages'] # %% ../nbs/01_manuscriptFiles.ipynb 3 import os @@ -143,7 +143,24 @@ def saveImages(contents, filenames, targetDirectory): os.chdir(baseDirectory) -# %% ../nbs/01_manuscriptFiles.ipynb 26 +# %% ../nbs/01_manuscriptFiles.ipynb 19 +def saveTranscripts(contents, filenames, targetDirectory): + baseDirectory = os.getcwd() + os.chdir(os.path.join(targetDirectory, "importTranscripts")) + + if type(contents) != list: + contents = [contents] + filenames = [filenames] + + for i in range(0, len(contents)): + string64 = contents[i].encode("utf8").split(b";base64,")[1] + message = base64.b64decode(string64).decode('utf-8') + f = open(filenames[i], 'w') + f.write(message) + + os.chdir(baseDirectory) + +# %% ../nbs/01_manuscriptFiles.ipynb 23 def currentManuscripts(): # If this is run on any computer, it will have a unique file structure. This implementation works with that file structure. baseDirectory = os.getcwd() @@ -176,7 +193,7 @@ def currentManuscripts(): os.chdir(baseDirectory) return manuscriptMetadata -# %% ../nbs/01_manuscriptFiles.ipynb 29 +# %% ../nbs/01_manuscriptFiles.ipynb 26 def zipManuscript(directoryOptions: list, manuscriptDirectory, name: str): import zipfile # standard call here to avoid getting the system lost in directories @@ -221,7 +238,7 @@ def zipManuscript(directoryOptions: list, manuscriptDirectory, name: str): return os.path.join(manuscriptDirectory, name + ".zip") -# %% ../nbs/01_manuscriptFiles.ipynb 32 +# %% ../nbs/01_manuscriptFiles.ipynb 29 def updateMetadata(directory, information): baseDirectory = os.getcwd() @@ -235,7 +252,7 @@ def updateMetadata(directory, information): os.chdir(baseDirectory) -# %% ../nbs/01_manuscriptFiles.ipynb 35 +# %% ../nbs/01_manuscriptFiles.ipynb 32 def manuscriptImages(targetDirectory): baseDirectory = os.getcwd() # Now, getting a relative pathway to the manuscript diff --git a/nbs/01_manuscriptFiles.ipynb b/nbs/01_manuscriptFiles.ipynb index 7e56ca1..78b3edd 100644 --- a/nbs/01_manuscriptFiles.ipynb +++ b/nbs/01_manuscriptFiles.ipynb @@ -443,144 +443,102 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, + "execution_count": 19, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ - "#| hide\n", - "def saveTranscript(files:dict, targetDirectory):\n", - " pass" + "#| export\n", + "def saveTranscripts(contents, filenames, targetDirectory):\n", + " baseDirectory = os.getcwd()\n", + " os.chdir(os.path.join(targetDirectory, \"importTranscripts\"))\n", + " \n", + " if type(contents) != list:\n", + " contents = [contents]\n", + " filenames = [filenames]\n", + " \n", + " for i in range(0, len(contents)):\n", + " string64 = contents[i].encode(\"utf8\").split(b\";base64,\")[1]\n", + " message = base64.b64decode(string64).decode('utf-8')\n", + " f = open(filenames[i], 'w')\n", + " f.write(message)\n", + " \n", + " os.chdir(baseDirectory)" ] }, { - "cell_type": "code", - "execution_count": null, + "cell_type": "markdown", "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "67cb3e95f7fb46bf98037416306f03e9", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "FileUpload(value=(), description='Upload Manuscript Transcripts', layout=Layout(height='auto', width='auto'), …" - ] - }, - "execution_count": null, - "metadata": {}, - "output_type": "execute_result" - } - ], "source": [ - "#| hide\n", - "import ipywidgets as widgets\n", - "\n", - "uploader = widgets.FileUpload(\n", - " accept = '', # Accepted file extension e.g. '.txt', '.pdf', 'image/*', 'image/*,.pdf'\n", - " multiple = True, # True to accept multiple files upload else False\n", - " description = 'Upload Manuscript Transcripts',\n", - " layout = widgets.Layout(height='auto', width='auto')\n", - ")\n", - "uploader" + "Just a cell" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, + "execution_count": 18, + "metadata": { + "tags": [] + }, "outputs": [ { "data": { + "text/html": [ + "\n", + " \n", + " " + ], "text/plain": [ - "({'name': '15_01_0053_0006_f_3r_res.xml',\n", - " 'type': 'text/xml',\n", - " 'size': 18246,\n", - " 'content': ,\n", - " 'last_modified': datetime.datetime(2021, 7, 9, 16, 4, 20, tzinfo=datetime.timezone.utc)},\n", - " {'name': '15_01_0053_0007_f_3v_res.xml',\n", - " 'type': 'text/xml',\n", - " 'size': 27037,\n", - " 'content': ,\n", - " 'last_modified': datetime.datetime(2021, 7, 9, 16, 4, 20, tzinfo=datetime.timezone.utc)},\n", - " {'name': '15_01_0053_0008_f_4r_res.xml',\n", - " 'type': 'text/xml',\n", - " 'size': 26795,\n", - " 'content': ,\n", - " 'last_modified': datetime.datetime(2021, 7, 9, 16, 4, 20, tzinfo=datetime.timezone.utc)})" + "" ] }, - "execution_count": null, "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "uploader.value" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ + "output_type": "display_data" + }, { "name": "stdout", "output_type": "stream", "text": [ - "\n" + "\n", + "\n" ] } ], "source": [ - "#| hide\n", - "import xml.etree.ElementTree as ET\n", - "input_stream = ET.parse(io.BytesIO(uploader.value[0]['content']))\n", - "root = input_stream.getroot()\n", + "# testing for saveTranscript\n", + "from dash import Dash, State, Input, Output, callback, dcc, html\n", + "import base64\n", "\n", - "print(root)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "\n", - " \n" - ] - } - ], - "source": [ - "print(type(root))\n", + "app = Dash(__name__)\n", + "app.layout = html.Div(\n", + " [\n", + " dcc.Upload(html.Button(\"upload\"), id=\"test-upload\", multiple = True),\n", + " html.Button(\"test\", id=\"query\"),\n", + " html.Pre(id=\"annotations-data-pre\"),\n", + " ]\n", + ")\n", "\n", - "print(root[1][0].text)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": null, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "root.keys" + "@callback(\n", + " Output(\"annotations-data-pre\", \"children\"),\n", + " Input(\"query\",\"n_clicks\"),\n", + " State(\"test-upload\",\"contents\"),\n", + " State(\"test-upload\",\"filename\"),\n", + " prevent_initial_call=True,\n", + ")\n", + "def simplePrint(clicks, contents, filenames):\n", + " print(type(contents))\n", + " print(type(filenames))\n", + " return contents\n", + "\n", + "if __name__ == \"__main__\":\n", + " app.run(debug=True)" ] }, { diff --git a/nbs/04_annotation.ipynb b/nbs/04_annotation.ipynb index 09c7e9d..813a4aa 100644 --- a/nbs/04_annotation.ipynb +++ b/nbs/04_annotation.ipynb @@ -153,7 +153,7 @@ "source": [ "#| export\n", "def createAnnotationTextArea():\n", - " return dbc.Textarea(id=\"annotation-text-area\",value=\"Enter transcription text here!\",style={\"width\":\"100%\",\"height\":285})" + " return dbc.Textarea(id=\"annotation-text-area\",value=\"Enter transcription text here!\",style={\"width\":\"100%\",\"height\":800})" ] }, { @@ -400,6 +400,10 @@ " \"eraseshape\",\n", " ]\n", " },\n", + " style={\n", + " \"height\": 800,\n", + " \"width\": 800,\n", + " },\n", " ),\n", " createSaveShapes(),\n", " ]\n", @@ -486,12 +490,18 @@ " dbc.Card(\n", " [\n", " dbc.Container(\n", - " dbc.Row(\n", - " children=[\n", - " dbc.Col(createFigureLayout(), md=7),\n", - " dbc.Col(createTextareaLayout(), md=5),\n", - " ]\n", - " )\n", + " [\n", + " dbc.Row(\n", + " children=[\n", + " dbc.Col(createFigureLayout(), md=7),\n", + " dbc.Col(createTextareaLayout(), md=5),\n", + " ]\n", + " )\n", + " ],\n", + " style={\n", + " \"height\": \"95%\",\n", + " \"width\": \"95%\",\n", + " },\n", " ),\n", " createNextTab(),\n", " ]\n", diff --git a/nbs/06_export.ipynb b/nbs/06_export.ipynb index ea0a5cd..8f3432f 100644 --- a/nbs/06_export.ipynb +++ b/nbs/06_export.ipynb @@ -313,12 +313,14 @@ " html.Br(),\n", " dbc.Card(\n", " [\n", - " dbc.CardBody([\n", - " createExportName(),\n", - " createDirectoryOptions(),\n", - " ]\n", + " dbc.CardBody(\n", + " [\n", + " createExportName(),\n", + " createDirectoryOptions(),\n", + " ]\n", " ),\n", - " createExportButton()\n", + " createExportDownload(),\n", + " createExportButton(),\n", " ]\n", " ),\n", " ]\n", diff --git a/nbs/07_app.ipynb b/nbs/07_app.ipynb index a6be11a..b184ee8 100644 --- a/nbs/07_app.ipynb +++ b/nbs/07_app.ipynb @@ -72,12 +72,10 @@ ] }, { - "cell_type": "code", - "execution_count": 4, + "cell_type": "raw", "metadata": { "tags": [] }, - "outputs": [], "source": [ "#| export\n", "\n", @@ -127,8 +125,89 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Bootstrap Declarations\n", - "\n" + "## Bootstrap Object Calls" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "#| export\n", + "selectionKey, selectionLayout = createSelectionLayout()\n", + "\n", + "centuries, informationLayout = createInformationLayout()\n", + "\n", + "annotationLayout = createAnnotationLayout()\n", + "\n", + "exportLayout = createExportLayout()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Bootstrap Application\n", + "\n", + "This makes the bootstrap version of the application" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "#| export\n", + "app = Dash(\n", + " external_stylesheets=[dbc.themes.BOOTSTRAP]\n", + ")\n", + "\n", + "app.layout = html.Div(\n", + " [\n", + " dcc.Tabs(\n", + " id=\"tabs-object\",\n", + " value=\"selection\",\n", + " children=[\n", + " dcc.Tab(\n", + " label=\"Selection\",\n", + " value=\"selection\",\n", + " children=[\n", + " selectionLayout\n", + " ],\n", + " ),\n", + " dcc.Tab(\n", + " label=\"Information\",\n", + " value=\"information\",\n", + " children=[\n", + " informationLayout\n", + " ],\n", + " ),\n", + " dcc.Tab(\n", + " label=\"Annotation\",\n", + " value=\"annotation\",\n", + " children=[\n", + " annotationLayout\n", + " ],\n", + " ),\n", + " dcc.Tab(\n", + " label=\"Export\",\n", + " value=\"export\",\n", + " children=[\n", + " exportLayout\n", + " ],\n", + " ),\n", + " ],\n", + " ),\n", + "# html.Div(id=\"current-tab\"),\n", + " html.Div(\n", + " children=\"no callback\",\n", + " id=\"dummy-output\",\n", + " style={\"display\": \"none\"},\n", + " ),\n", + " ]\n", + ")" ] }, { @@ -143,12 +222,10 @@ ] }, { - "cell_type": "code", - "execution_count": 5, + "cell_type": "raw", "metadata": { "tags": [] }, - "outputs": [], "source": [ "#| export\n", "app = Dash(__name__)\n", @@ -811,8 +888,8 @@ " # Upload objects\n", " State(\"upload-images\", \"contents\"),\n", " State(\"upload-images\", \"filename\"),\n", - " # State(\"upload-manuscripts\",\"contents\"),\n", - " # State(\"upload-manuscripts\",\"filename\"),\n", + " State(\"upload-manuscripts\",\"contents\"),\n", + " State(\"upload-manuscripts\",\"filename\"),\n", " # Conditional object\n", " State(\"manuscript-select\", \"value\"),\n", " prevent_initial_call=True,\n", @@ -828,8 +905,8 @@ " centuriesValue, # State centuries-slider\n", " imContents, # State upload-images\n", " imFilenames, # State upload-images\n", - " # manContents,\n", - " # manFilenames,\n", + " manContents,\n", + " manFilenames,\n", " manSelect, # State manuscript-select\n", "):\n", " global selectedManuscript\n", @@ -858,6 +935,7 @@ " if manSelect == \"Create New Manuscript\":\n", " selectedManuscript = (createManuscriptDirectory(information), information)\n", " saveImages(imContents, imFilenames, selectedManuscript[0])\n", + " saveTranscripts(manContents, manFilenames, selectedManuscript[0])\n", " else:\n", " updateMetadata(selectedManuscript[0], information)\n", " \n", @@ -951,7 +1029,7 @@ " " ], "text/plain": [ - "" + "" ] }, "metadata": {}, @@ -975,7 +1053,6 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'autosize': True}\n", "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n", "\u001b[1;31mKeyError\u001b[0m Traceback (most recent call last)\n", "\u001b[1;31mKeyError\u001b[0m: 'shapes'\n",