Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Outliner with drag/drop reordering - part 2
-
Please, copy it into your web server and give me some feedback.
Don't worry too much, this is just a first draft. And probably, given the level of my knowledge in html, css and JavaScript, a real "quick and dirty", as usual. Please, have also a look into the code it-self, not so long as I thought before, thus no so complex. -
@cvp I tested outline_viewer.html and the first outline I tried gave this interesting result: https://imgur.com/a/TOPpJur (I am only showing the left hand side).
-
@ihf is it possible that you asked a sort before? I think that the bug comes from the fact that sort = none does not change the sequence, but not sure. I'll check,
But, if no bug, are you happy with the html?Edit: not yet solved but identified: bug comes from my poor knowledge of JavaScript, I used array.sort() to sort an array, hoping it was generating another array but, in reality, it replaces the original array... sorry for that.
Édit: new V00.01 of outline_viewer.html should correct this problem
-
@cvp This seems to be working better but I just opened an outline and one line looked like this:
⬜️ 9.0 ', {'dates': ('2021-09-04 16:49:34', '2021-09-05 17:59:10', None, None), 'hidden': False, 'checkmark': 'no
It seems to be showing the dates and format but not the text. The rest of the outline looked fine -
@ihf As I can't check the content of your outline file, it is difficult to identify the problem.
But I'll modify the html to "protect against old or corrupted line where text field is absent in a line".
This last case could generate such an error. -
@cvp This is very strange. I ran the new version and line 9 is blank (no errors). I then went back to run the outline.py script and I immediately get an error:
Traceback (most recent call last):
File "/private/var/mobile/Containers/Shared/AppGroup/05D14C00-CCAC-4E98-A3CC-96C6944B8534/Pythonista3/Documents/outline.py", line 1167, in layout
ws,hs = self.get_screen_size()
File "/private/var/mobile/Containers/Shared/AppGroup/05D14C00-CCAC-4E98-A3CC-96C6944B8534/Pythonista3/Documents/outline.py", line 1158, in get_screen_size
app = UIApplication.sharedApplication().keyWindow()
File "/var/containers/Bundle/Application/8778D1CF-1C08-48BA-9714-9D2CFE524EA1/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/objc_util.py", line 801, in call
ordered_args = list(args) + [kwargs[key] for key in kwarg_order]
TypeError: 'builtin_function_or_method' object is not iterableI tried again and got same error. I closed pythonista and ran it again and managed to open the same outline and it worked though line 9 has text. Short of sending the full outline, is there something I can post that would help?
-
@cvp That error is now popping up whenever I start the script.
-
@ihf I don't understand correctly all your posts.
The error has already happened in The past, not really from my py code.
Is the error coming only for the outline with blank line 9?
Of course, I would be happy to get your outline or at least line 9 (you can always edit the .outline as text in Pythonista, find "9.0" and extract via select/copy/post the line to post). -
@cvp Here is line 9.0 which shows as blank in the html view but shows the text otherwise:
([8], '9.0 ', {'dates': ('2021-09-04 16:49:34', '2021-09-05 17:59:10', None, None), 'hidden': False, 'checkmark': 'no'}, {'text': "Return Peter's fluke"}),
-
@ihf thanks. I don't know (Ho yes, text includes a quotE) why but it is the first time that I meet
{'text': "xxxxxxx"}
in place of
{'text': 'xxxxxxx'}
In a py script, no problem, a dictionary is understood in both cases, but in my JavaScript code, I have to do it my self.
Next version will follow today
PS that does not explain the (old, already met) Pythonista crash
-
-
@cvp That fixed it!. Thank you!
-
@ihf Finally, is this html what you wanted to replace the Mac py?
-
@cvp I know JS is not what you want to work on, but if you are open to any enhancements to the .html file, one thing that would be nice is if it could default to the last file that was selected, rather than to have to select it each time. Or, perhaps it could open the file selection directly rather than have you click Select File which is always going to be required.
-
@ihf I don't think that html5 allows to set a default path, for security reasons. At least, I don't see how.
Édit: I'm busy to try (actually without success) to simulate a tap on the input file selector at page load.
I think I I'll give up. Finally, it is only to win one tap, isn' it?
-
@cvp Is it also difficult to have a version which just opens a specific file (i.e., no memory of file last used and no selection). If so, I could create a few .html files wach of which would open a different outline. Not elegant but it would avoid any selection.
-
@ihf said
Is it also difficult to have a version which just opens a specific file
So far as I have already read, I think it is not authorized in html5 to access a predefined path/file.
But, if you find a way, I agree to incorporate it in the html. -
@cvp I don’t know about html5 limitations/restrictions. Perhaps it could all be done in a Python executable on the web server.
-
@ihf said:
Perhaps it could all be done in a Python executable on the web server.
Wow. what an imagination! That, if possible, seems very far of my skills. But, who knows?
In the mean time, what will you use: mac_outline_viewer.py or outline_viewer.html?But, would you be able to configure iCloud access on the web server?
-
@cvp I will probably use outline_viewer.html as it is accessible from any web browser that is on a machine that is logged into my iCloud account. Unless I am mistaken, the web server does not need iCloud access as you are accessing the file from the client.