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 je comprends que
-
@ihf For instance, I've spent some hours today to try to solve the problem of "the display gets messed up in that lines are overlapping." when sorting dates. But without success.
-
@ihf Version mac_outline_viewer.py V00.05 with
V0.05 - support sort on dates
Even if I 'm sincerely not proud of my quick and dirty script/html/JavaScript and maybe it could be very slow with long outlines, I don't know.
Feed-back hoped
-
@cvp It works great!
-
@ihf As you know, a TableView does not remember all TableViewCells but rebuilds them when they are visible. If scrolling makes them disappear, their memory is freed and if they reappear, they are built and displayed. It is therefore a saving of memory but a waste of time if the scrolling causes cells to appear and disappear often. But it seems that most of our problems would come from the possible desynchronization between the management of the table of items and their display.
I more and more want to try to replace the TableView with a simple ScrollView where I would manage the position of the rows myself. The cells would be subviews of the scrollview and would only be rebuilt if their content changes.
this solution, for which I cannot yet estimate the development time, would only be valid if your outlines did not contain too many lines (but how many = too many?). Could you tell me approximately how many lines are in your outlines?
And, would you agree to test a different version? -
@cvp To answer your last question first, of course, I would be happy to test any future version. As far as how large my outlines are, Were you referring to how many lines in the outline or in a particular item?
-
-
@cvp Another option is that you can store TableViewCells rather than returning new ones. That way the objc references never change .
Rather than starting cell_for_row with
cell=ui.TableViewCell()
like normal, you could manage your cells on your own, and build them all in advance, and then in cell_for_row, you simply return the pre-built value:cell=self.cells[section][row]
Since you probably won't have outlines with thousands of rows, that's probably safe memory-wise.
I also wonder if it wouldn't be possible to use one of the omz text view classes (say extending the markdown formatter. ). That would require a lot of swizzling, or at least making implementing subclasses of objc classes that we don't have good documentation on (and just have to rely on swizzlelog to figure out the interfaces) ... so probably is not heading in the right direction...
-
@JonB that would not solve the problem we had for which you adviced to use begin /end update.
The internal code will still decide to call cell_for_row and perhaps still be désynchronised.and yet, I followed the omz doc, namely modify my items and call reload for any modification or deletion
Édit: for info, I already stored cell in my own array self.cells, for usage when I'm sure that the row is still on screen, when the TextView in the row is edited
-
@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.