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

Feature - Issue #170 - Update YAML Viewer #191

Merged

Conversation

richmahn
Copy link
Member

@richmahn richmahn commented Jun 5, 2017

Simply removes rendering ALL .yaml files as tables, and just does it for toc.yaml.

For example, http://test.door43.org:3000/richmahn/en_ta/src/master/checking/toc.yaml uses this update, showing a table with clickable "link"s, and a proper rendering of the array of arrays of maps.

Where as http://test.door43.org:3000/richmahn/en_ta/src/master/manifest.yaml shows the YAML using the default view, highlighting YAML syntax.

This also fixes how the new en_ta's toc.yaml is an array of arrays which broke the production view (https://git.door43.org/Door43/en_ta/src/master/checking/toc.yaml) showing the section data as an ugly string.

It also links "link" to <link>/01.md where as before it mapped "slug" to content/<link>.md (old way: https://git.door43.org/Door43/en-ta-translate-vol1/src/master/toc.yaml)

@richmahn richmahn changed the title Changes tabular YAML view to only work with toc.yaml files Feature - Issue #170 - Update YAML View Jun 5, 2017
@richmahn richmahn changed the title Feature - Issue #170 - Update YAML View Feature - Issue #170 - Update YAML Viewer Jun 5, 2017
@ChrisJarka
Copy link

Copy link
Contributor

@ethantkoenig ethantkoenig left a comment

Choose a reason for hiding this comment

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

Depending on how large the files we're rendering are, it might be worth using a bytes.Buffer instead of string concatenation

@@ -42,6 +42,13 @@ func renderHorizontalHtmlTable(m yaml.MapSlice) string {

if value != nil && reflect.TypeOf(value).String() == "yaml.MapSlice" {
value = renderHorizontalHtmlTable(value.(yaml.MapSlice))
} else if value != nil && reflect.TypeOf(value).String() == "[]interface {}" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we use a type switch instead of manually using the reflection library for the checks on lines 43 and 45?

@richmahn
Copy link
Member Author

richmahn commented Jun 5, 2017

toc.yaml files are not that big. Plus that code was written months ago.

@richmahn
Copy link
Member Author

richmahn commented Jun 5, 2017

@ethantkoenig Ok, got it all switched up.

@@ -35,13 +35,22 @@ func renderHorizontalHtmlTable(m yaml.MapSlice) string {
key := mi.Key
value := mi.Value

if key != nil && reflect.TypeOf(key).String() == "yaml.MapSlice" {
switch reflect.TypeOf(key).String() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not a type switch. I'd prefer a type switch to a regular switch (which is basically the same as what we originally had) to avoid having magic strings like "[]interface {}" floating around (which breaks if it's missing an easy-to-forget space).

Ditto elsewhere.

Copy link
Member Author

Choose a reason for hiding this comment

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

This wasn't even something I wrote this time, so you could me asking me to change this all over Gogs if you wanted, but ok, will look into it.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was originally using .String() as well. For this update I just added another if. Didn't know that then warrants a whole new rewrite. Will see if I can do this without the type being written as a string...new to this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I can do it if you want

@richmahn
Copy link
Member Author

richmahn commented Jun 5, 2017

Ok, uses the type switch now.

Copy link
Contributor

@ethantkoenig ethantkoenig left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@phillip-hopper phillip-hopper left a comment

Choose a reason for hiding this comment

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

The yaml in the demo link is not displaying correctly: http://test.door43.org:3000/richmahn/en_ta/src/master/checking/toc.yaml

image

@phillip-hopper
Copy link

Also, testing locally it seems to work with *.yaml but not *.yml.

@richmahn
Copy link
Member Author

richmahn commented Jun 7, 2017

@phillip-hopper: Odd that this has changed since the PR was merged. Will figure out why it isn't showing the HTML . Probably due to the template settings.

@richmahn
Copy link
Member Author

richmahn commented Jun 7, 2017

Oh, I guess this never was merged. Thought it had been. That means I need to put test back onto this branch.

@richmahn
Copy link
Member Author

richmahn commented Jun 7, 2017

@phillip-hopper Works now, going to merge this in since Ethan already approved. http://test.door43.org:3000/richmahn/en_ta/src/master/checking/toc.yaml

@richmahn richmahn merged commit 7600743 into unfoldingWord:develop Jun 7, 2017
@richmahn
Copy link
Member Author

richmahn commented Jun 7, 2017

I've merged in and now test.dor43.org:3000 is on our 'develop' branch, for the time being (will be using it for the DCS branding when done, but should have this commit as well)

@phillip-hopper
Copy link

You can't merge it yourself, especially when one of the reviewers still hasn't approved.

richmahn added a commit that referenced this pull request Jun 7, 2017
* Changes tabular YAML view to only work with toc.yaml files

* Used switch for YAML module per code review

* Uses a 'type' switch as per code review
richmahn added a commit that referenced this pull request Jun 7, 2017
* Changes tabular YAML view to only work with toc.yaml files

* Used switch for YAML module per code review

* Uses a 'type' switch as per code review
richmahn added a commit that referenced this pull request Jun 7, 2017
* Changes tabular YAML view to only work with toc.yaml files

* Used switch for YAML module per code review

* Uses a 'type' switch as per code review
@richmahn
Copy link
Member Author

richmahn commented Jun 7, 2017

Sorry about that. Thought Ethan approved but forgot to merge. I had assumed it was already in so put the test site back on develop branch. Are we needing more than one person to approve now?

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants