Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise or delete load-leo.html #3005

Closed
tbpassin opened this issue Dec 13, 2022 · 19 comments
Closed

Revise or delete load-leo.html #3005

tbpassin opened this issue Dec 13, 2022 · 19 comments
Assignees
Labels
Milestone

Comments

@tbpassin
Copy link
Contributor

tbpassin commented Dec 13, 2022

See PR #3441.

Temporary solution

The PR rewrites load-leo.html to say that vscode.dev will (eventually!?!) support leoInteg.

Original report

In Leo's Readme om Github, there is a link near the bottom : A web page that displays .leo files. Trying to load the default outline offered, my browser gave an error "File is too large":

Upload from the Internet.
Enter the URL below.
https://github.com/leo-editor/leo-editor/raw/master/leo/doc/LeoDocs.leo

File is too large

Error uploading file

A smaller outline should be found for this demonstration.

@tbpassin tbpassin added this to the 6.7.2 milestone Dec 13, 2022
@edreamleo edreamleo self-assigned this Dec 18, 2022
@edreamleo
Copy link
Member

@tbpassin I see the behavior you describe. Notes:

  • Loading LeoDocs.leo from disk does work, so the problem is something other than the file's size.

  • I also get the "too large" message when trying to upload a smaller file, say leo/test/test.leo.

Conclusion: load-leo.html is buggy in a way I do not understand. I'll investigate, but no promises.

@edreamleo edreamleo changed the title Link To Display Leo Outline In Browser Does Not Work For The Example load-leo.html can not load files from the web Dec 24, 2022
@edreamleo
Copy link
Member

Fixing the JS is beyond me at present.

Someone else will have to fix this issue.

@edreamleo edreamleo modified the milestones: 6.7.2, Later Dec 24, 2022
@tbpassin
Copy link
Contributor Author

I think the error is coming from the php file do-leo.php. The error message wording appears in lines 635 and 683.

@tbpassin
Copy link
Contributor Author

Currently, the php file mungs the LeoDocs.leo outline to insert a stylehseet PI (Process Instruction). If the stylesheet PI (<?xml-stylesheet ...) could be permanently put into LeoDocs.leo, there would be no need for the php file, jquery, or any of that. When a browser loads the .leo file, it would automatically be displayed using the xslt stylesheet.

If the current code that opens a Leo outline in Leo cannot accept (and ignore) a stylesheet PI, then I would regard that as a bug that should be fixed. (I have not yet tested for this).

@tbpassin
Copy link
Contributor Author

I added a stylesheet PI to my workbook outline and Leo opened it without a problem.

However, when I opened the same outline in the browser from the filesystem, the xslt stylesheet didn't get applied. That surprises me because it does get applied when the LeoDoecs.leo outline is downloaded from the internet (i.e., the Leo site).

@edreamleo
Copy link
Member

@tbpassin Thanks, Thomas, for these comments. With your permission, I'll delegate this issue to you.

@tbpassin
Copy link
Contributor Author

The page in question uses a server-side php file on leoeditor.com. I'd need admin permissions to make changes.

@edreamleo edreamleo removed their assignment Jun 19, 2023
@LewisNeal
Copy link
Contributor

If you use URL https://leoeditor.com/load-leo.html
pressing [Upload From Your Hard Drive] button works and displays your selected file in the browser.

The [Upload From the Internet] button does not work.

However if you use new URL https://leo-editor.github.io/leo-editor/load-leo.html neither button works.

@tbpassin
Copy link
Contributor Author

This issue fell off my radar. I'll look at it again. But something about @LewisNeal's description puzzles me. I just tried _[Upload From Your Hard Drive] _ on a Leo outline on my hard drive, and the file was displayed in the browser as expected.

It sounds like @LewisNeal entered the url into the file dialog, and didn't get a document displayed. I assumed up til now that this dialog was intended for an outline on one's file system, not a url. When I tried it with @LewisNeals's url, I found that the requested page was in fact downloaded. But it was served with the content type application/xml. However, the document was actually an HTML5 document starting with <!doctype html>, and that's not well-formed for an XML file. An XML file must start with <?xml (can be omitted), and must not start with <!doctype or anything similar. So - quite properly - the browser was unable to display it.

When I uploaded an outline from my hard drive, it was converted correctly to an XML file, so the MIME type was correct.

My conclusion - there is nothing wrong with the _[Upload From Your Hard Drive] _ button. If you try use it to upload something that is not on your hard drive, don't be surprised if it doesn't work. Ideally, I suppose that this condition could be detected and an error message given. Alternatively, there could be one upload button that would accept a URL or a file system outline. But I don't know as it would be worth the effort since the __[Upload From Your Hard Drive] _ button works as advertised.

The problem with the [Upload From the Internet] button remains.

@LewisNeal
Copy link
Contributor

To clarify - I did not load a url into the file dialog.
Use new URL https://leo-editor.github.io/leo-editor/load-leo.html and the [Upload From Your Hard Drive] button does NOT work. There is no response.

But use old URL https://leoeditor.com/load-leo.html and the [Upload From Your Hard Drive] button works correctly, opening a File Open window dialog asking you to select a file, and press Open.

@tbpassin
Copy link
Contributor Author

To clarify - I did not load a url into the file dialog.
Use new URL https://leo-editor.github.io/leo-editor/load-leo.html and the [Upload From Your Hard Drive] button does NOT work

Well, you just wrote that you used a url and the [Upload From Your Hard Drive] didn't work. That button opens a file dialog. It does not use the url you type into the url box, as best as I know. If you did not "load a url into the file dialog", then how did you try to open it with the button?

@LewisNeal
Copy link
Contributor

I only wanted to show that for
https://leo-editor.github.io/leo-editor/load-leo.html the [Upload From Your Hard Drive] button does NOT work. There is no response.
And for https://leoeditor.com/load-leo.html the [Upload From Your Hard Drive] button works correctly.

@tbpassin
Copy link
Contributor Author

When you click the [Upload From Your Hard Drive] button, you should get a file dialog. If you don't get it, there is something wrong at your end, possibly because javascript is not allowed (e.g., by NoScript). When I tried it, I had to allow scripts (I use NoScript) before the button would work.

If you do get the File Open dialog, and navigate it to a Leo outline on your computer's drive, that will work, or at least it works on my system.

If you do get a file dialog and type in a URL instead of a file path, that will not work as I explained earlier, because the script expects a file, not a url.

The file dialog will not make use of https://leo-editor.github.io/leo-editor/load-leo.html, or any other entry displayed in the URL box, so far as I know.

@LewisNeal
Copy link
Contributor

I am only using the [Upload From Your Hard Drive] button.
Note that the web links behave differently.

@tbpassin
Copy link
Contributor Author

Oh, now I get it. I had loaded the upload page from the old link, and it worked as expected. I just got it from the link on the current Leo-editor page on GitHub and clicking the button had no effect. I'm sorry I misunderstood you.

I think what is wrong is that two support scripts probably didn't get copied over to the new github.io site:

<script type="text/javascript" src="scripts/upclick-min.js"></script>
<script type="text/javascript" src="scripts/jquery.min.js"></script>

At any rate, the page is failing because these two scripts aren't being found.

I guess it is up to @edward to provide them...

@edreamleo
Copy link
Member

@tbpassin Thanks for your investigation. I may have removed the two .js file because of a dependabot complaint.

@edreamleo edreamleo modified the milestones: Later, 6.7.4 Jun 26, 2023
@edreamleo
Copy link
Member

I have reopened this issue and assigned it to 6.7.4. A simple fix may be possible.

@edreamleo edreamleo reopened this Jun 26, 2023
@tbpassin
Copy link
Contributor Author

As long as the scripts don't import other scripts, they could be embedded into the HTML output file using <script> elements (though that might make it pretty large).

@edreamleo edreamleo changed the title load-leo.html can not load files from the web Revise or delete load-leo.html Jul 16, 2023
@edreamleo
Copy link
Member

Completed via PR #3441.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants