Граф коммитов

577 Коммитов

Автор SHA1 Сообщение Дата
Julie Qiu a51cf23a47 internal/frontend: implement package imports details
fetchImportsDetails now returns imports for a package from the
database. imports.tmpl is also updated to display the name and path of
imports, grouped by whether or not they are in the standard library.

A bug is fixed where the insert for to_name and to_path were
swapped.

Fixes b/124308480

Change-Id: Ic325aee1ee9be37aad7f13948d68ea85461dc92b
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/450576
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:35 -04:00
Rob Findley 2fc2cd3b6f internal/frontend, content: add licenses page
Add content to the licenses page, along with anchored links to specific
licenses that apply to the package, as well as a disclaimer.

Updates b/124309095

Change-Id: Id394c8acd2ca60cf711f64bc15541429e77715d1
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/450766
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:35 -04:00
Julie Qiu c5fba95a79 content: display number of importers in search results
Search results now show the number of packages that a given result is
imported by.

Updates b/130797141

Change-Id: I64dbaf66f7cbb09971c533ad72e77fc94aac6394
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/450855
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:35 -04:00
Julie Qiu 11d13e80a1 internal/frontend: use last element of package path as display name
frontend.Package now has the fields:
* Name: displays the package suffix as the name is main
* IsCommand: returns true if the package name is main.
* Title: displays Name, prefixed by "Command" or "Package"

These are generated inside createPackageHeader.

seriesPathForModule is deprecated in favor of module.SplitSemverPathVersion.

The content for helpers/_mod_header.tmpl and helpers/_modules_nav.tmpl
are moved to pages/details.tmpl. The package header now displays:
* "Command <name>" instead of "Package <name>" if IsCommand is true
* import "<path>" only if IsCommand is false

The links are versions.tmpl fixed to use the new v query param.

Fixes b/130320811

Change-Id: Ib4bb25ad54ff454e3b6b0a837f77a86dbfb60ccb
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/450575
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:35 -04:00
Rob Findley 82e7982fa9 content: add CSS properties corresponding to our palette
At least during the development phase, this will make it easier to
implement consistent styling across the site. If needed, we can later
either revert to constant values, or use a preprocessor.

Change-Id: I94d5987d69f2e251304c9c2907b0892c82c6ac76
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/450849
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:35 -04:00
Julie Qiu 2fe6825c0f revert: "internal/frontend: use last element of package path as display name"
This reverts commit c1492636321da6147394178b967e2df9ba630554.

Change-Id: I89507bc029d73c6acad8b993c4d5b4cbba3023c9
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/450573
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:35 -04:00
Julie Qiu 1f56288fca internal/frontend: use last element of package path as display name
frontend.Package now has the methods:
* Name() string: displays the package suffix as the name is main
* IsCommand() bool: returns true if the package name is main.
* Title() string: displays Name(), prefixed by "Command" or "Package"

seriesPathForModule is deprecated in favor of module.SplitSemverPathVersion.

content/static/html/helpers/_mod_header.tmpl now displays:
* Package name using the Name() method
* "Command <name>" instead of "Package <name>" if IsCommand() is true
* import "<path>" only if IsCommand() is false

The links are versions.tmpl fixed to use the new v query param.

Fixes b/130320811

Change-Id: I32160d80df6312292c78007a84ac98867e9e7bf8
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/445774
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:35 -04:00
Julie Qiu 959a354979 internal/frontend: modify fetch*Page handlers to return *DetailsPage
All of the handlers named fetch*Page (now renamed to fetch*Details)
return a PackageHeader and other details. They now all return a *DetailsPage,
with their corresponding details embedded, instead of different types.

The search handler logic is also moved to its own file at
internal/frontend/search.go

Fixes b/130721889

Change-Id: I5eca8cdda8fa658ec935f06521da2c8fe179b8d1
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/450569
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:35 -04:00
Julie Qiu 701b01e3fa internal/frontend,content: refactor to use shared layout; add skeletons for import(er)s pages
The templates for the package details pages are refactored so that they
use a shared base layout.

Skeleton templates are also added for the imports and importers page.

Fixes b/130638124

Change-Id: I0e4072e91cd53ee61ff1a108592bcc2c4ed74235
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/450209
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:35 -04:00
Julie Qiu da16b63db8 cmd/frontend,content: add favicon.ico
The route /favicon.ico is added, which returns a gopher as a favicon.

This also fixes a bug where each request to /<import-path> resulted in
two requests, since /favicon.io matches the syntax for /<import-path>.

Fixes b/130659698

Change-Id: I5aac0bea89832abfb57e70b3dd67441289e75d6b
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/450210
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:35 -04:00
Rob Findley 03521312ea internal/frontend, content: add a skeleton for the licenses page
License content will be added later, once license fetch is added.

Change-Id: Ic86989fe7562ed518dec9a1aaa89bef60b53fb7f
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/449571
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:35 -04:00
Rob Findley db22c1a2b9 discovery: add multiple license support
This CL changes our data model so that licenses are associated with
packages rather than module versions, and adds multiple license
detection.  As a result, given following file layout

  my.mod/LICENSE
  my.mod/pkgfoo/COPYING
  my.mod/pkgbar/LICENSE.md

both LICENSE and COPYING (but not LICENSE.md) will be associated with
the package my.mod/pkgfoo.

Additionally make some minimal UI changes to support the new data model,
though a proper implementation of the licenses tab is deferred to a
later CL.

Fixes b/130372424
Updates b/129371814
Updates b/129372226
Fixes b/129000846
Fixes b/129372204

Change-Id: Ife58498914fea75e4c58e7c713a8071887f87000
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/447910
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:35 -04:00
Dmitri Shuralyov b2e8ade79d internal/frontend, content: add a starting point for the documentation page
There's no godoc content yet, that will follow in future CLs.

Change the tab name from "docs" to just "doc". This is simpler and more
consistent with "godoc", etc. The current future plan is to make this
the default tab, so it won't have a name then. But it'll continue to be
"doc" while the page is in development.

Change-Id: If4ec229a6b7f49aee216f6ea845bcf3d1e2fa356
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/449355
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:35 -04:00
Andrew Bonventre 6b4b716926 content/static/html: move search snippet fragment into search template
Also removes a superfluous HTML self-closing tag since those are
optional in HTML5.

Change-Id: Ifa066a9cbd76a6f574757793a86d2492811f6184
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/449353
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:35 -04:00
Andrew Bonventre cd91bad772 internal/frontend: switch to using a get param for versions
Additionally passes the template context to the nav template
on all pages with some other small updates.

Fixes b/130230126

Change-Id: I10114822382c6fc6c0a9f547749aa4faa433a851
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/449352
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:35 -04:00
Andrew Bonventre 78a6b8a7c8 content/static/html: clean up some template logic
+ Disable autocomplete, spellcheck, autocorrect, etc. in the search
  input
+ Remove redundant "equal" template function in favor of the built-in
  "eq"
+ Populate the search input with the current query
+ Show the query first in the title since tabs are typically not
  wide enough to show everything
+ Redirect to the homepage if the q param is empty
+ Other very small cleanup changes

Change-Id: Ib9baa41c336088cb3e9555ddaf527545292bb118
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/449351
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:35 -04:00
Julie Qiu 4c70155b9e content,internal/frontend,internal/postgres: create module page
The module page is added, which displays the directory and synopsis
of all packages in the module and the README.

This change includes the following additions:
* frontend.fetchModulePage: returns data needed to populate module.tmpl
* postgres.GetVersionForPackage: returns the version for a given
  package_path and version, along with all of the packages for that
  version.

Note: At the moment, both the overview page and the module page display
the README. Once a decision is made on where the README will be displayed,
these pages will be updated.

Fixes b/130112117
Fixes b/130111944

Change-Id: Ib240b1744cf66be72a63683804b521beaec62307
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/444468
Reviewed-by: Andrew Bonventre <andybons@google.com>
2020-03-27 16:46:35 -04:00
Rob Findley 25fea74665 internal/frontend: rename 'tabName' to the more correct 'pageName'
Change-Id: Iadc768b1e5fad23f49f688cee857d59e2f72d9a2
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/446470
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:34 -04:00
Rob Findley 83c075957a frontend: refactor template parsing and fix active nav tab
This CL implements a pattern similar to that used in
github.com/golang/gddo to implement an active tab selector for the nav.
Along the way, refactor a bit so that the frontend package is fully
responsible for templates.

Also replace the pattern of Make*HandlerFunc with handler methods.

Also fix a minor typo in all.bash that was causing misspell not to be
installed.

Updates b/124309095

Change-Id: I802ba69b91b81be13c6314140326fe8783608a0c
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/445973
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:34 -04:00
Julie Qiu 79fb951b9e content,internal/frontend: link versions to default details page
The links in versions.tmpl now route to the default tab instead of the
versions tabs.

An error with using the wrong type to format an arg for the
createPackageHeader error message is also fixed.

Change-Id: I5479895e13e04867aa00153e4276e0e6fc4aee43
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/444466
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:34 -04:00
Channing Kimble-Brown e16f400131 content, cmd/frontend, internal/fetch, internal/frontend: add search and home frontend
The following endpoints now have handler funcs HTML/CSS:
- "/" directs the user to the home page which contains just a search bar.
This endpoint is handled by MakeDetailsHandlerFunc.
- "/search?q=<query>" directs the user to a list of search results for the
specified query. This endpint is handled by MakeSearchHandlerFunc.

Fixes b/125408009.

Change-Id: I2d919e35b8d5d8d5f76a6895d47f99897b4f32ff
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/444660
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:34 -04:00
Channing Kimble-Brown a90ca55731 content, internal/frontend, internal/postgres: add ability to render versions tab
fetchVersionsTabPage takes in a package path and a version and then returns
all of the data needed to display the packages that have the same series and
package suffix to make the versions tab content. The data is displayed in a
hierarchical list of major (i.e. "v1") then major and minor (i.e. "1.2") and
lastly the entirety of the version (i.e. "1.2.3" or "1.2.2-alpha.1").

verisons.tmpl is the template that displays all of the data in the
VersionsTabPage struct.

The routing was changed so that MakeFrontendHandlerFunc handles both
/<import path>@<version> which brings up the overview page and
/<import path>@<version>?tab=versions which brings up the versions
tab.

Fixes b/124308701

Change-Id: I92bd86d050ab6e7e669c07a750b325b3e026d052
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/443954
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:34 -04:00
Channing Kimble-Brown c63f17b138 content/static/html, internal/frontend, internal/postgres: fix package header
The module overview page is being updated to be a package
overview page instead. The package header information
has been pulled out into its own struct because that information
will need to be used across various tabs and GetPackage was
updated to also return the module path and readme from the
database.

Fixes b/129020591

Change-Id: I09174c68077b3dc9c27da608b219cabf610639ee
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/441334
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:34 -04:00
Julie Qiu 7450e3c3c5 cmd/fetch,content: change default proxy url; link to path in details header
Change-Id: Id67a462ddd291a062d27651799f31b09a64cd22d
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/438030
Reviewed-by: Channing Kimble-Brown <ckimblebrown@google.com>
2020-03-27 16:46:34 -04:00
Julie Qiu d1a9c54f60 internal/frontend: display READMEs written in markdown as HTML
READMEs written in markdown will be displayed as HTML.

internal.Version.ReadMe is changed from type string to []byte.

Minor changes are made to the Overview page to reflect changes for
package discovery.

Change-Id: I52e5ae091cf8069154415e02c7d88c7911f3a205
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/437553
Reviewed-by: Andrew Bonventre <andybons@google.com>
2020-03-27 16:46:34 -04:00
Julie Qiu bb74654421 content,internal/frontend: fix error executing module page template
A bug introduced in commit cdaa29e is fixed. The bug was due to
Module.Name being renamed to Module.Path throughout the codebase, but
not in the templates inside content/.

Change-Id: Iadf2d85e0f33c2dfb57c2ff1f88e7914d9d6e5d7
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/437549
Reviewed-by: Channing Kimble-Brown <ckimblebrown@google.com>
2020-03-27 16:46:34 -04:00
Channing Kimble-Brown 8f815ef30a cmd/frontend, internal/frontend: create frontend binary and load overview
There is now a frontend binary that accepts HTTP requests for:

GET /name?v=<version>

This route renders an overview page, which displays the name, version
publish date and readme for a specified module. The readme has not yet
been rendered into HTML.

Also note that the tabs are not fully functional or accessible and
these issues will be thoroughly addressed in a future CL.

Fixes b/124438879
Fixes b/124438779
Fixes b/124438684

Change-Id: I569dd3549bdea781183e2d7d29be375141fb5c3d
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/425454
Reviewed-by: Andrew Bonventre <andybons@google.com>
2020-03-27 16:46:33 -04:00