mu icon indicating copy to clipboard operation
mu copied to clipboard

Fix web asset dirs

Open ntoll opened this issue 1 year ago • 0 comments

This PR is adjacent to #923.

Sometimes the default templates, css and images directories were erroneously created in the wrong place (they were created relative to the file in the currently active tab). This was problematic since the currently active file might have been a CSS or template file and so new directories would be created.

This PR ensures that:

  • If there's too many different Flask app files in open tabs, report that Mu can't resolve the directory the user needs, and suggest the user have only a single Flask app Python source file open.
  • If there is only one tab containing a Python file that is a Flask app, then look up (and if required, create) the directory relative to the Flask app's Python file.
  • If there is no tab containing a Flask app, open the default directories in the mu_code directory.

If the templates/css/images directories are created relative to the Flask app's source file (and it's not in mu_code), then only an empty directory is created. The assumption being that the user doing this is advanced enough to copy files around the filesystem. :slightly_smiling_face:

The following GIF-y shows this feature in action:

asset_dirs

ntoll avatar Jul 17 '22 11:07 ntoll