Page MenuHomeSoftware Heritage

Add option to select code language
ClosedPublic

Authored by kalpitk on Jul 12 2019, 8:26 PM.

Details

Summary

Related T1909

Diff Detail

Repository
rDWAPPS Web applications
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

kalpitk created this revision.Jul 12 2019, 8:26 PM
kalpitk updated this revision to Diff 5840.Jul 15 2019, 7:41 PM
  • Refactor updateLanguage
  • Add chosen plugin for searchable dropdown
kalpitk updated this revision to Diff 5841.Jul 15 2019, 9:29 PM
  • add dropdown
  • import css for chosen

I have added chosen-js plugin for searching and filtering of languages dropdown.

Importing chosen-js in swh/web/assets/src/bundles/vendors/index.js doesn't import the css. On adding imports for css and png separately, webpack fails. I am not able to figure out why ?

kalpitk updated this revision to Diff 5850.Jul 16 2019, 1:05 PM
  • Fix webpack error and trigger updateLanguage with dropdown

CSS needs to be updated for the dropdown.
Rest everything is done.

swh/web/assets/config/webpack.config.development.js
297

Not sure why (\?v=\d+\.\d+\.\d+) is used here. Should this be used with images also?

311

Will directory 'img/imports' be fine for outputPath?

vlorentz added inline comments.
swh/web/assets/config/webpack.config.development.js
297

I don't know... don't use it if it's not needed.

306

Do we need GIF and JPEG for now?

311

What about img/thirdParty (to match the name used elsewhere)?

swh/web/templates/includes/top-navigation.html
134

What does this line do?

kalpitk added inline comments.Jul 16 2019, 2:45 PM
swh/web/assets/config/webpack.config.development.js
297

ok

306

No. Should I remove gif and jpeg from here?

311

ok

swh/web/templates/includes/top-navigation.html
134

It was for initialising chosen on select.

It works without this line, because of the next line.
Will remove it.

vlorentz added inline comments.Jul 16 2019, 3:41 PM
swh/web/assets/config/webpack.config.development.js
306

If we don't need it, yes.

kalpitk updated this revision to Diff 5854.Jul 16 2019, 7:39 PM
  • Add css

I had to use !important everywhere to override the default css. I guess, there must be a way to avoid it.

kalpitk retitled this revision from [WIP] Add option to select code language to Add option to select code language.Jul 17 2019, 1:22 PM
kalpitk updated this revision to Diff 5857.Jul 17 2019, 1:24 PM
kalpitk retitled this revision from Add option to select code language to [WIP] Add option to select code language.

Update CSS and refactor

kalpitk updated this revision to Diff 5859.Jul 17 2019, 2:57 PM
  • Fix failing tests
kalpitk updated this revision to Diff 5860.Jul 17 2019, 3:04 PM

Update commit msg

kalpitk retitled this revision from [WIP] Add option to select code language to Add option to select code language.Jul 17 2019, 3:04 PM

It's really nice!

Just a few remarks:

  • it's unclear what language_select does, especially as it's used both as a list of languages and a boolean to tell whether the language selector should be shown. It should be renamed to available_languages
swh/web/browse/views/utils/snapshot_context.py
457

"Override language with user-selected language"

swh/web/templates/includes/content-display.html
69

This currently works because there are no other params, but it would be nice to support other parameters in the URL, so we don't get unexpected bugs later.

swh/web/templates/includes/top-navigation.html
134
kalpitk added inline comments.Jul 17 2019, 8:19 PM
swh/web/browse/views/utils/snapshot_context.py
457

ok

swh/web/templates/includes/content-display.html
69

I tested it with other params like origin_url, it works.
I mean for links like "http://127.0.0.1:5004/browse/content/sha1_git:33217f73631dbfa1860b41060e5a6a5a62420f69/?origin_url=https%3A%2F%2Fgithub.com%2Fusartkom%2Flearning_pyhon&language=gherkin", everything works.

(URLSearchParams stores all params in url)

swh/web/templates/includes/top-navigation.html
134

Django auto-escapes template variables by default.

kalpitk updated this revision to Diff 5870.Jul 17 2019, 8:28 PM

language_select renamed available_languages

vlorentz accepted this revision.Jul 18 2019, 10:25 AM
vlorentz added inline comments.
swh/web/templates/includes/content-display.html
69

Indeed, my bad

This revision is now accepted and ready to land.Jul 18 2019, 10:25 AM
This revision was automatically updated to reflect the committed changes.