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

Fix styling #62

Merged
merged 12 commits into from
Jul 28, 2018
Merged

Fix styling #62

merged 12 commits into from
Jul 28, 2018

Conversation

pyokagan
Copy link
Contributor

No description provided.

pyokagan added 5 commits July 28, 2018 15:28
asciidoctor.css is meant to be used with asciidoctor-generated
documents.

This repo uses MarkBind for documentation generation, and MarkBind
primarily uses Bootstrap for styling.

Having asciidoctor.css present in the page may conflict with Bootstrap's
styling, resulting in awkward looking pages.

So, let's remove asciidoctor.css.
We currently link the gh-pages.css stylesheet, which contains our
website-specific style rules, in the <body> element.

This is not valid HTML.

Fix this by using Markbind's `head` feature to link the gh-pages.css
stylesheet in the <head> element.

This is done by introducing the _markbind/head/head.md document, and by
adding the following to the frontmatter of every markdown file:

    head: head.md

The following script is used to accomplish this:

    for x in *.md $(find contents -name '*.md'); do
        sed -i '/^  footer: footer\.md/a\  head: head.md' "$x"
    done
The items of the navigation bar are displayed as a column, which looks
ugly and is not consistent with the rest of the SE-EDU website.

Fix this by adding the `navbar-expand` class, which is a facility
provided by Bootstrap to display the navigation bar items in a row at
all times.
Some of the links in the navigation bar point to invalid locations.
Let's fix them.
This makes the Learning Resources website more consistent with the other
SE-EDU sites, which all have a similar secondary navigation bar.
@pyokagan
Copy link
Contributor Author

@damithc Heh nice, I see Netlify has already been set up.

@pyokagan pyokagan requested a review from damithc July 28, 2018 07:30
pyokagan added 7 commits July 28, 2018 15:34
MarkBind automatically wraps the entire document in a div with the
`container-fluid` style class set:

    <div id="app" class="container-fluid">
        ... the document ...
    </div>

Bootstrap defines the container-fluid style class to have padding on the
left and right:

    .container-fluid {
        width: 100%;
        padding-right: 15px;
        padding-left: 15px;
        margin-right: auto;
        margin-left: auto;
    }

This makes our top navigation bar have empty space on the left and
right, which looks ugly.

Unfortunately, we can't remove the container-fluid style class since
MarkBind controls that part of the rendering.

So, let's fix this by overriding the container-fluid style rules on #app
in our gh-pages.css file.

MarkBind's default footer styling actually uses a (rather strange)
workaround:

    footer {
        margin-left: -15px;
        margin-right: -15px;
    }

Once the #app.container-fluid padding is overridden, footer's workaround
is no longer needed (and in fact will produce worse results by adding
scrollbars to the document since its margins will extend outside the
document).

So, let's workaround footer's workaround by overriding it.
We override .nav-link in gh-pages.css to perform some SE-EDU specific
styling.

However, Bootstrap's CSS uses a more specific selector:

    .navbar-expand .navbar-nav .nav-link

which overrides our styling.

Fix this by making our selector more specific.
This makes the rendered documents consistent with the rest of the
website.
This allows us to style the body of each document by adding style rules
on .website-content.

This was accomplished by running the following script:

    for x in *.md $(find contents -name '*.md'); do
        sed -i '/^{{ navbar | safe }}/a\<div class="website-content">' "$x" &&
        sed -i '/^{{ navbar | safe }}/G' "$x" &&
        echo >> "$x" &&
        echo '</div>' >> "$x"
    done
This makes it consistent with the overall design of SE-EDU websites.
Bootstrap sets the line-height of navbars to 1.5.

This makes the top SE-EDU navbar have a lot of extra vertical space,
which is inconsistent with the rest of the SE-EDU website.

Fix this by setting the line-height of large navbars (.navbar-lg) to 1.
The styling of the other SE-EDU websites (e.g. AddressBook-Level4) is
such that headers will have some margins to separate them with
whitespace from the rest of the document.

This is not so with Bootstrap, where headers have extremely tiny
margins. This causes the document body to be uncomfortably close to the
site navigation bar, which looks bad.

Fix this by adding some space below the #site-header.
Copy link
Contributor

@damithc damithc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍 Thanks for doing this.
Hope it wasn't a lot of work to figure out the MarkBind stuff. We haven't optimized the author-friendliness aspect to our target levels yet.

@damithc
Copy link
Contributor

damithc commented Jul 28, 2018

@pyokagan do you want to keep the commits or shall I squash?

@pyokagan
Copy link
Contributor Author

@damithc

Nah, took about 1 hour tops. I copied most of the stuff from se-book/website-base.

Keep the commits please.

@pyokagan
Copy link
Contributor Author

btw, I needed to do some workarounds with strange MarkBind defaults in d8f206f . cc @yamgent

@damithc damithc merged commit d8b1eb2 into se-edu:master Jul 28, 2018
@damithc
Copy link
Contributor

damithc commented Jul 28, 2018

Deployed.

@pyokagan
Copy link
Contributor Author

Hope it wasn't a lot of work to figure out the MarkBind stuff. We haven't optimized the author-friendliness aspect to our target levels yet.

Oh, I realized I probably should have left some usability feedback for MarkBind:

  • I found MarkBind constantly clearing the console kind of annoying, esp for non-daemon usage like markbind build.

  • I locally installed MarkBind (i.e. in the node_modules directory). MarkBind tried to convert the Markdown documents inside the node_modules directory. I tried to ignore it by adding node_modules/* to the site.json, but it didn't seem to work? In the end I hacked my way out by doing the following: (Note, I didn't read the user guide)

    commit f1f32e4a2b4c4793af8707476e853b6b8562fbd2
    Author: Paul Tan <pyokagan@pyokagan.name>
    Date:   Sat Jul 28 13:55:21 2018 +0800
    
        TMP
    
    diff --git a/site.json b/site.json
    index fcbb30b..43ea59e 100644
    --- a/site.json
    +++ b/site.json
    @@ -5,11 +5,21 @@
         "_markbind/logs/*",
         "_site/*",
         "site.json",
    -    "*.md"
    +    "*.md",
    +    "node_modules/*"
       ],
       "pages": [
         {
    -      "glob": "**/*.md"
    +      "glob": "contents/**/*.md"
    +    },
    +    {
    +        "glob": "index.md"
    +    },
    +    {
    +        "glob": "GuidelinesForContributors.md"
    +    },
    +    {
    +        "glob": "Contact.md"
         }
       ],
       "deploy": {
  • node printed the following on markbind serve, which is quite scary :-P

    (node:25288) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit
    
  • The navbar variable is used in almost all the markdown documents. However, when I modified the navbar in _markbind/variables.md, none of the documents got rebuilt. In the end I just resorted to Ctrl-C-ing markbind serve and restarting it each time.

  • A progress indicator for markbind build would be nice.

@pyokagan
Copy link
Contributor Author

Also feels kind of obtuse to be adding head: head.md to every document as in 90f6492 , can it be set in the site.json?

@damithc
Copy link
Contributor

damithc commented Jul 29, 2018

Thanks for the comments @pyokagan Good points.
Hope to fix them in a future release (focus for this summer was reader-friendliness. Hope to switch focus to author-friendliness in the coming semester). Your comments will be useful at that time.

@yamgent Please create issues as necessary, when you have time.

@yamgent
Copy link
Member

yamgent commented Jul 30, 2018

I found MarkBind constantly clearing the console kind of annoying, esp for non-daemon usage like markbind build.

Yes, I agree (I use the terminal constantly, and the clearing of console just seems to be counter-intuitive). Does the big logo printed at the beginning annoys you too as well? :P

I locally installed MarkBind (i.e. in the node_modules directory). MarkBind tried to convert the Markdown documents inside the node_modules directory. I tried to ignore it by adding node_modules/* to the site.json, but it didn't seem to work? In the end I hacked my way out by doing the following: (Note, I didn't read the user guide)

Not sure what the "hack" here is, because the change that you made is actually correct.

node printed the following on markbind serve, which is quite scary :-P

(node:25288) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added. Use emitter.setMaxListeners() to increase limit

This looks quite familiar, will look into it. Does it always happen for you?

The navbar variable is used in almost all the markdown documents. However, when I modified the navbar in _markbind/variables.md, none of the documents got rebuilt. In the end I just resorted to Ctrl-C-ing markbind serve and restarting it each time.

A progress indicator for markbind build would be nice.

👌

Also feels kind of obtuse to be adding head: head.md to every document as in 90f6492 , can it be set in the site.json?

We will be reconsidering the design of this in the coming semester (footer and site-nav currently suffers the same problem).

@damithc
Copy link
Contributor

damithc commented Jul 30, 2018

node printed the following on markbind serve, which is quite scary :-P

Happened to me several times. In my case it was always caused by a mistake in my nunjucks code e.g., an array not closed properly.

@pyokagan
Copy link
Contributor Author

@yamgent

Not sure what the "hack" here is, because the change that you made is actually correct.

I was surprised that the ignore configuration did not affect pages.

(Looking at the User Guide now, I see that there is no way to exclude files from a pages glob?)

@pyokagan
Copy link
Contributor Author

This looks quite familiar, will look into it. Does it always happen for you?

Yeah it always happens on this repo, even from the start. Dunno if its different depending on node version, I'm using v9.11.2.

@yamgent
Copy link
Member

yamgent commented Jul 30, 2018

I was surprised that the ignore configuration did not affect pages.

It is not supposed to. pages affects what files are getting rendered from markdown to html. ignore affects what files are being copied over to the final built site.

I know it can get quite confusing. I also found it confusing when I first started with the MarkBind project, but apparently no one else was disturbed by this problem, so... ¯\_(ツ)_/¯

(Looking at the User Guide now, I see that there is no way to exclude files from a pages glob?)

Nope. This problem is raised in MarkBind/markbind#228.

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

Successfully merging this pull request may close these issues.

3 participants