Use a default path in the editor
When opening a think with no path specified, try some of the most common paths and show the first one that exists.
This commit is contained in:
parent
7fd6f8333e
commit
1b6a9956c5
1 changed files with 12 additions and 0 deletions
|
@ -82,6 +82,12 @@ class RemixThinkView(ThinkMixin, generic.UpdateView):
|
||||||
class ThinkView(ThinkMixin, generic.DetailView):
|
class ThinkView(ThinkMixin, generic.DetailView):
|
||||||
template_name = "thinks/think.html"
|
template_name = "thinks/think.html"
|
||||||
|
|
||||||
|
default_paths = [
|
||||||
|
'src/App.elm',
|
||||||
|
'script.js',
|
||||||
|
'index.html',
|
||||||
|
]
|
||||||
|
|
||||||
def get_context_data(self, *args, **kwargs):
|
def get_context_data(self, *args, **kwargs):
|
||||||
context = super().get_context_data(*args, **kwargs)
|
context = super().get_context_data(*args, **kwargs)
|
||||||
|
|
||||||
|
@ -93,6 +99,12 @@ class ThinkView(ThinkMixin, generic.DetailView):
|
||||||
|
|
||||||
path = think.file_path(strpath)
|
path = think.file_path(strpath)
|
||||||
|
|
||||||
|
if path is None:
|
||||||
|
for f in self.default_paths:
|
||||||
|
if (root / f).exists():
|
||||||
|
path = root / f
|
||||||
|
break
|
||||||
|
|
||||||
relpath = path.relative_to(root) if path is not None else None
|
relpath = path.relative_to(root) if path is not None else None
|
||||||
|
|
||||||
if path is None:
|
if path is None:
|
||||||
|
|
Loading…
Reference in a new issue