-
Notifications
You must be signed in to change notification settings - Fork 3
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
Create static ToC for Html output #79
Comments
A static ToC means we give up on the smoothScrooling functionality, of synchronising the scrolling of the ToC and the content window. If you can run the Javascript to do smoothScrooling, you can also run the Javascript the generate the table of contents dynamically. Because I will not code Javascript, if that's a problem, I'm not going to be the one to solve it. |
I think it's fine to first create the static ToC , and have someone else code up the smooth scrolling. @strogonoff could you help here? |
That's not the only Javascript you may need to deal with, if you want to use crippled obsolete junk versions of browsers like Internet Explorer 11. There's also the scroll to the top HTML button, and the rendering of footnotes inline. See https://github.com/riboseinc/metanorma-iso/blob/master/lib/isodoc/iso/html/scripts.html |
Point remains that our HTML output needs to degrade gracefully. I believe @strogonoff could handle this. |
I've generated the static ToC, but this needs the Javascript from the existing ToC script to be cannibalised, in order for it to deliver the same functionality. I will release the gems without the static ToC, and I am attaching a version with the static ToC content here, for Anton or Pierre to work on. I am also attaching a version with the dynamic ToC script, for comparison. rice.html.dynamic.zip The table of contents script is at https://cdn.rawgit.com/jgallen23/toc/0.3.2/dist/toc.min.js The table of contents script is invoked as:
The functionality of "selectors", "container", "prefix", "headerText", "itemClass" has already been reproduced in the static code, and does not need to be replicated. There are two pieces of functionality missing from the static version, and the ToC script needs to be cannibalised to replicate that functionality:
|
I'm asking that any Javascript be included in the HTML file; I will add it back into the gem when done. |
@opoudjis are you asking me to send you patched HTML, and you’ll diff & commit the changes later? |
Yes. |
@strogonoff Any progress on this? I am way overcommitted on other projects, but this does still need to be done. |
@strogonoff Re-ping. |
@strogonoff Please action. The task is to extract from the existing JS we use a smaller subset, which will just do mouseover highlighting and smooth scrolling; the remaining ToC functionality will be moving into statically generated code. |
Sure, this slipped through the cracks, let me put some resources on it |
As I’m looking into it, I don’t believe it’s worth mucking around with the jQuery plugin, since generating ToC from headers is its core feature. May be more straightforward to just generate ToC HTML and have a simple script to handle some UX niceties. @opoudjis, you wrote
Is this in a branch? How can I generate the sample document with the static ToC? So that I can play around with the JS side of things on it |
It's commented out code in isodoc: isodoc/lib/isodoc/html_function/html.rb
Note that the XPath selector which headings to include in the ToC is now being handled by this supplied piece of Javascript, generated dynamically by Ruby:
That is in effect a dynamic version of I think you and Ronald need to discuss the point in generating Static ToC for HTML at all, given that Ronald now is talking about bundling jQuery with the HTML code in metanorma/metanorma#59 This is a ticket that has not been actioned in a year, but it is pointless to action it if the distribution strategy for HTML output is going to change so radically. Which I myself think is insane, but that's now a discussion between @ronaldtse and you, @strogonoff. @ronaldtse, be clear on what you are trying to achieve here, because I think metanorma/metanorma#59 (if you're going to implement this) renders this ticket obsolete. |
After a quick exchange with Ronald, I’ll get static ToC done. jQuery may still need to be bundled, even if new ToC doesn’t use it other parts would. |
@opoudjis I may be missing something, but the document works with static ToC as is. Meaning: — With code commented and JS disabled, ToC doesn’t work (as expected) Could you clarify why the script may need to be modified? |
Tested on |
@opoudjis To be more precise:
This works for me the same with or without static ToC. (Obviously not with JS disabled.)
This does not work for me, again with or without static ToC. (Maybe I misunderstand how it’s supposed to work, I just don’t see any difference in behavior when scrolling. Sidebar scroll position is never affected by main window scroll in my tests.) |
Huh. These are indeed broken. Ok, I'll regenerate, hold on. |
OK, sorry. This is what's meant to happen:
The missing activeClass functionality is:
so basically, function("onclick", e.addClass("toc-active")). Or however it is meant to work. Rather than play middleman about dodgy functionality in a 10 year old ToC script, I invite @ronaldtse to communicate to you direct. You now have a dynamic and a static version of the ToC page attached here. Ronald, you tell Anton what you see missing (apart from the on-click class functionality.) rice_alt.html.dynamic.zip That may include implementing simultaneous scrolling... Oh, I see: this was never implemented in the source ToC script, this was something Ronald asked for. metanorma/metanorma-iso#190. So Anton, you may or may not choose to take that ticket on too, as part of this work. But this is between you two now. |
So the original scope of the ticket is now minimal: it's merely giving me a one line javascript command to change css class on click. But the potential scope of this ticket is a lot bigger: implement whatever @ronaldtse would like to make the HTML ToC pretty, including simultaneous scrolling. When you've worked out what the JS should be, let me know, and I will add it to the isodoc template. |
Nick, the highlight of the active item in sidebar works for me with the uncommented version & ToC fully static, with existing JS. I’ll attach a screencast.
… On 30 Jul 2019, at 10:26 AM, Nick Nicholas ***@***.***> wrote:
So the original scope of the ticket is now minimal: it's merely giving me a one line javascript command to change css class on click.
But the potential scope of this ticket is a lot bigger: implement whatever @ronaldtse would like to make the HTML ToC pretty, including simultaneous scrolling.
When you've worked out what the JS should be, let me know, and I will add it to the isodoc template.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@opoudjis Here’s what I see. Tab on the left is the original (without static ToC), tab on the right the version with uncommented code you pointed to (with static ToC). This is isodoc-rice built using the documented method. I uncommented your code in the isodoc gem, and verified that ToC appears in HTML after that. No JS modifications made so far. Active item highlight works on both. Scrolling sync does not work on either. |
Scrolling sync indeed does not exist anywhere, it was a feature request by Ronald. You are looking at the .html file in the screenshot. Look at the .alt.html file, which highlights the clicked on TOC item by adding a CSS class to it. The static version can't be doing it, because I've commented out the TOC script that does that. |
Uncommenting the isodoc code is not sufficient. The point of uncommenting the isodoc code is that we should no longer need to call the ToC script, as is done e.g. in the first script in, metanorma-iso/lib/isodoc/iso/html/scripts.html, If you do not remove the ToC script call from the HTML file, then the ToC script still ends up being run, and building the ToC dynamically. Which means there is no point in generating the ToC statically. That script also highlights clicked ToC entries, by assigning a CSS class to it. If you do remove the ToC script call from the HTML file, then there is nothing to highlight the clicked on ToC entry. I don't need help doing that, that is a one-line JS function. However, your task is to liaise with Ronald, work out if anything else needs to accompany the ToC as a javascript script (especially his request for synchronised scrolling), and give me whatever is needed as a new javascript script, which does not construct the ToC dynamically, but which does do whatever other rendering control is needed. |
I disagree:
A proper longer-term solution can follow this. However, I believe we should address the problem ASAP and then refactor if we want to. (If ToC was broken in presence of new static ToC, then this would be necessary right away, but it looks like it’s not.) |
I think we agree on principle, I just suggest that we uncomment the static ToC as soon as customer confirms it solves their problem (dynamic ToC doesn’t break static ToC from my tests), and later refactor & improve on that (filed #113 for that) |
Agree with you, I've discussed this independently with Ronald. So, I am now going to uncomment the isodoc code, and make sure it responds to gem-specific settings of permitted ToC styles. |
It looks like html_toc function in this |
No, under this ticket, I need to remove all overriding html_toc function from gems, I hadn't realised they had been there (effectively disabling static HTML TOC). |
No description provided.
The text was updated successfully, but these errors were encountered: