weixin_40008644
2020-12-27 22:26 阅读 0

Export a page/form textarea to a downloadable file

Is your feature request related to a problem?

Nope.

What is the feature?

A button or icon to export the contents of a page / form textarea to a downloadable text file, similar to the way we do it in the installer with config.php.

From a UI perspective, probably best suited as an icon in the same fashion as 'New page / form' and 'Duplicate'.

Considerations:

  • The textarea is editable, so export option would perhaps require a page / form to be saved, then be activated. Subsequent edits may deactivate the export option.
  • If it's a case of 'take the contents of the textarea and export to a file regardless of its save state', then that's all client-side, but might have dependencies.

该提问来源于开源项目:textpattern/textpattern

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

7条回答 默认 最新

  • weixin_39862794 weixin_39862794 2020-12-27 22:26

    Steps to try:

    • Visit Presentation>Themes
    • Select checkbox alongside one or more in-use themes
    • Multi-edit > Export to disk and confirm
    • Visit page/form/style panel and edit an asset in an exported theme
    • Check 'Export to disk' checkbox beneath textarea prior to Save

    Is that close enough? Or do you think we need a dedicated export as well, that prompts to save to a different location?

    点赞 评论 复制链接分享
  • weixin_40008644 weixin_40008644 2020-12-27 22:26

    Is that close enough? Or do you think we need a dedicated export as well, that prompts to save to a different location?

    Good question. In my head, it was all done in a browser. Your route saves to /themes/example/etc, I was envisaging a browser-side download as a .txt file like the config.php during setup. The route outlined above also involves an FTP client to retrieve the files saved to the (server) drive, unless I'm being a bit dim and I've missed something. This is obviously OK if you're using an IDE with FTP stuff baked in, but plain text editor on a desktop, not so integrated.

    ~~Aside: does the page / form 'Export to disk' checkbox only appear after a certain route in? I swear that wasn't there until I went in via the route you listed. Might be snow blindness, not sure.~~ Edit: answered my own question - checkbox only there when theme assets are saved to drive.

    Second aside: given that we can write theme assets to a writable location, are we missing a trick by not offering to save config.php in place during install?

    点赞 评论 复制链接分享
  • weixin_39862794 weixin_39862794 2020-12-27 22:26

    Yep, the export to disk only appears if the asset of the theme you're editing has a presence in the /themes directory. Otherwise, there's nowhere for it to save/sync to.

    And yes, if your theme files are on the server, you'll need ftp/rsync to get at them after saving.

    As far as "make a copy of this textarea" is concerned, I'm not sure. What's the use case, just out of curiosity? What do you intend to do with the file after you've saved it? Is this for version control of individual files?

    Also, would the export take the current copy of what's in the textarea - that may not yet have been saved - or take the last saved content from the server (as far as the database/file system is concerned)?

    given that we can write theme assets to a writable location, are we missing a trick by not offering to save config.php in place during install?

    Yes and no. Yes, it could be done (test if writable and give it a whirl, then fallback on download if it fails).

    No we don't do it because that file is so massively important, it's a security risk to permit it to be overwritten from a browser. If someone doesn't delete their /setup directory, anyone could just blat the config.php. At least the way we have it, there's an air gap - albeit not the most user friendly method to adopt.

    点赞 评论 复制链接分享
  • weixin_40008644 weixin_40008644 2020-12-27 22:26

    As far as "make a copy of this textarea" is concerned, I'm not sure. What's the use case, just out of curiosity? What do you intend to do with the file after you've saved it?

    Version control, basically.

    Edit: ha, you beat me to it.

    点赞 评论 复制链接分享
  • weixin_40008644 weixin_40008644 2020-12-27 22:26

    No worries - I'll do the theme export dance, no trouble. Thanks for your insight, invaluable as always!

    点赞 评论 复制链接分享
  • weixin_39862794 weixin_39862794 2020-12-27 22:26

    Exporting to local machine vs exporting to the server does have value if you're version controlling away from the server environment. It's just a bit of a faff to hit Save to commit to the server and then hit a button after that to download it to a local place and pick the directory (assuming you want to keep the same/similar dir structure as the theme).

    Most times when you download, the browser remembers the last location, which may not be the place you want. And if you're version controlling in a single directory, how will you know the difference between default.txp (Page) and default.txp (Form)? Plus there's the ambiguity of what happens if you hit the download button before you've saved.

    Certainly not saying it can't be done. Just needs some thought. And since we have export ability already (albeit to the server) I'd waver towards this being plugin territory. Hope that's not too dismissive.

    点赞 评论 复制链接分享
  • weixin_40008644 weixin_40008644 2020-12-27 22:26

    Not even remotely dismissive! All very valid points.

    点赞 评论 复制链接分享

相关推荐