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
-
@cvp My Outline lengths are (up to now) <100 items. I can imagine them being somewhat longer but certainly <<1000.
-
@ihf ok. Thus I'll try to replace the base TableView of rows by a ScrollView. I know that it is not an easy job and that it should take a long time but so, if it works, it should avoid some bugs where invisible code is performed without I can manage it. So, Vital bugs excepted, you would not get new versions during some time...
-
@cvp I was thinking about whether there was a way to make your mac_outline_viewer work as a cgi-bin so that I could use the web to access outlines (for viewing). The problem I see (so far) is that the selection of the outline file requires access to the iCloud drive and I don't see an easy way to do that from a linux system that runs the webserver. Do you think the storage location of the outline files could (optionally) be another location that linux could access? Or perhaps you can think of another way to achieve access from the web?
-
@ihf I don't know anything about cgi-bin. Where would be your web server? On a Linux machine, no more on your Mac? Where do you want to store your outline files? No more on iCloud Drive? On a NAS?
Edit: perhaps could a web app read an iCloud calendar, like my Apple Watch shortcut does, get the file and display it...(shared public iCloud Calendar gets an url like webcal://...)
Edit2: perhaps could the outline.py script save a copy of the outline file on your web server, like it also does in the 2022 event.
PS For info, I'm still busy to convert my script for a ScrollView, I must admit that I am slow, for lack of desire/motivation, but I'll do it.
-
@ihf Said
Do you think the storage location of the outline files could (optionally) be another location that linux could access?
Could you store this little html file on your Linux web server and tell me on which machine you test it.
Is your iCloud configured on this machine (iDevice, Mac, PC)? It should have to be...<html> <head> <script> var openFile = function(event) { var input = event.target; var reader = new FileReader(); reader.onload = function(){ var text = reader.result; var node = document.getElementById('output'); node.innerText = text; console.log(reader.result.substring(0, 200)); }; reader.readAsText(input.files[0]); }; </script> </head> <body> <input type='file' accept='.outline' onchange='openFile(event)'><br> <div id='output'> ... </div> </body> </html>
For instance, on my iPad, I get this file selector, and the third line gives access to iCloud Drive
I copy this html on a Web server that I use sometimes, and I open this html in Safari on my iPad.
-
@cvp Sorry, didn't see your post until now. I just tried it on my server (which has no access to iCloud). When I run it on my iMac wwhich has access, I get a browse button in the browser and I can access iCloud files, including the Outlines. The outline is displayed unformatted.
-
@ihf said
Sorry, didn't see your post until now. I just tried it on my server (which has no access to iCloud). When I run it on my iMac wwhich has access, I get a browse button in the browser and I can access iCloud files, including the Outlines. The outline is displayed unformatted.
Display unformatted is normal with this very little html, this is only a test to check if it works.
I could write (at least, I think I could) a more complex html containing a JavaScript code which would display the outline like my mac_outline_viewer.py does, but It will never access iCloud Drive files if ICloud is not accessible on the machine where you use it. Thus, what do you hope? -
@cvp I think in this case the “machine” is any iDevice that has access to my iCloud files. The web server need not have access since it is the browser that is fetching the file. I just tested from my iPhone and iPad and it worked fine.
-
@ihf yes, you gave a good summary.
If the html and its included JavaScript code allow you to select the file, select the date and its sort type, and display the outline like the mac_outline_viewer.py script, is that what you want/hope?But, that should not be part of the Pythonista forum, nor even a Python forum 😀
And given my level in JavaScript, it will take some time. -
@cvp yes, I suppose it is, strictly speaking, off topic, but it is related. And yes, I was looking to have the outlines more accessible (having them on the Watch is great). Of course, this still requires that the browser be running where iCloud is accessible but that’s ok.
-
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