{"id":20279742,"url":"https://github.com/genieframework/stippledownloads.jl","last_synced_at":"2025-03-04T02:41:11.414Z","repository":{"id":210118363,"uuid":"725786597","full_name":"GenieFramework/StippleDownloads.jl","owner":"GenieFramework","description":"Donwload dynamically generated files with Stipple apps","archived":false,"fork":false,"pushed_at":"2024-12-20T23:11:22.000Z","size":29,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-22T11:17:01.107Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GenieFramework.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-30T21:48:42.000Z","updated_at":"2025-02-04T06:58:08.000Z","dependencies_parsed_at":"2024-11-14T13:47:11.010Z","dependency_job_id":null,"html_url":"https://github.com/GenieFramework/StippleDownloads.jl","commit_stats":null,"previous_names":["genieframework/stippledownloads"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenieFramework%2FStippleDownloads.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenieFramework%2FStippleDownloads.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenieFramework%2FStippleDownloads.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GenieFramework%2FStippleDownloads.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GenieFramework","download_url":"https://codeload.github.com/GenieFramework/StippleDownloads.jl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241773256,"owners_count":20018064,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T13:32:54.280Z","updated_at":"2025-03-04T02:41:11.391Z","avatar_url":"https://github.com/GenieFramework.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# StippleDownloads\n\nStippleDownloads is a plugin for Stipple to enable download of dynamically generated files.\nThe event-based handlers guarantee that only the requesting client receives a copy of the file.\n\nThere is support for text and binary files, filenames can be freely chosen.\n\n## Examples\n\n**Downloading a variable's content as raw data or as BSON**\n\n```julia\nusing Stipple, Stipple.ReactiveTools\nusing StippleUI, StippleDownloads\nusing BSON\n\n@app begin\n    @in data = randn(1000)\n\n    @event download_raw begin\n        download_binary(__model__, data, \"raw\")\n    end\n    @event download_bson begin\n        # calling @save on `data` throws an error because it is a reactive variable. Need to make a copy\n        data_var = data\n        io = IOBuffer()\n        BSON.@save io data_var\n        seekstart(io)\n        download_binary(__model__, take!(io), \"data.bson\")\n    end\n\nend\n\nfunction ui()\n    row([\n            cell(btn(class=\"q-ml-lg\", \"Raw\", icon=\"download\", @on(:click, :download_raw, :addclient), color=\"primary\", nocaps=true))\n            cell(btn(class=\"q-ml-lg\", \"BSON\", icon=\"download\", @on(:click, :download_bson, :addclient), color=\"secondary\", nocaps=true))\n        ])\n    \nend\n\n@page(\"/\", ui)\n\n```\n\n**Downloading a DataFrame as an Excel sheet**\n\n```julia\nusing Stipple, Stipple.ReactiveTools\nusing StippleUI\nusing StippleDownloads\n\nusing DataFrames\nusing XLSX\n\nimport Stipple.opts\nimport StippleUI.Tables.table\n\nfunction df_to_xlsx(df)\n    io = IOBuffer()\n    XLSX.writetable(io, df)\n    take!(io)\nend\n\n@app begin\n    @out table = DataTable(DataFrame(:a =\u003e rand(1:10, 5), :b =\u003e rand(1:10, 5)))\n    @in text = \"The quick brown fox jumped over the ...\"\n\n    @event download_text begin\n        download_text(__model__, :text)\n    end\n\n    @event download_df begin\n        try\n            download_binary(__model__, df_to_xlsx(table.data), \"file.xlsx\"; client = event[\"_client\"])\n        catch ex\n            println(ex)\n        end\n    end\nend\n\nfunction ui()\n    row(cell(class = \"st-module\", [\n\n        row([\n            cell(textfield(class = \"q-pr-md\", \"Download text\", :text, placeholder = \"no output yet ...\", :outlined, :filled, type = \"textarea\"))\n            cell(table(class = \"q-pl-md\", :table))\n        ])\n              \n        row([\n            cell(col = 1, \"Without client info\")\n            cell(btn(\"Text File\", icon = \"download\", @on(:click, :download_text), color = \"primary\", nocaps = true))\n            cell(col = 1, \"With client info\")\n            cell(btn(class = \"q-ml-lg\", \"Excel File\", icon = \"download\", @on(:click, :download_df, :addclient), color = \"primary\", nocaps = true))\n        ])\n    ]))\nend\n\n@page(\"/\", ui)\n\nup(open_browser = true)\n\n```\n\nTo see the difference between calling with or without client info, duplicate the applications's tab and click the 'Download Text' button.\n\nTwo identical files will be downloaded, because duplicating the tab establishes a synchronised copy of your app. To ensure that only the requesting client receives a file, you should restrict the download to the client via `event[\"_client\"]`\nand make sure that the triggering button has an additional `:addclient` to include this information.\n    \n![Demo App](./docs/demo.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenieframework%2Fstippledownloads.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgenieframework%2Fstippledownloads.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenieframework%2Fstippledownloads.jl/lists"}