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

115 Коммитов

Автор SHA1 Сообщение Дата
shaquilleq 6ed53dd70c internal/middleware: update cache to check AuthHeader and AcceptedAuthValues
The cache now performs the same checks as the quota server for a known
header to see if a request should bypass the cache. The shared header
name is now hardcoded since there's no point in keeping it in an
environment variable.

This functionality allows load-testing the frontend server without
hitting the cache.

Change-Id: I7c0fb0196ddc946e84b5fb95ea254f4ab85a3eec
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/246138
Reviewed-by: Julie Qiu <julie@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-08-04 18:59:37 +00:00
Jonathan Amsterdam 5e159604f7 internal/frontend: get a DataSource on each request
Reorganize the server so that each request gets its own DataSource,
instead of using a single DataSource for every request.

Currently, the behavior doesn't change because we do in fact use
the same DataSource for every request. But this paves the way
to having a pool of health-checked DB connections, while still
having each request work with a single connection.

For golang/go#40444.

Change-Id: I717450593a8dcfd5689a8d28f634324776305042
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/244603
Reviewed-by: Julie Qiu <julie@golang.org>
2020-07-28 13:14:05 +00:00
Julie Qiu 1fb4ec10c9 internal/frontend: fix basePage for custom error pages
This change fixes an issue in initiating the base page for a custom
error pages, which prevent fields such as the AppVersion and
GoogleTagManagerID to be set.

Change-Id: Ifdc7a058b1d6281132004036f678bebca9ef5811
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/244549
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
2020-07-23 20:34:08 +00:00
Jamal Carvalho d37103e11f content,internal: add badge generation for package authors
This change creates a badge generation tool page for package authors. A future change will add
documenation of this feature and a link to the about page.

Fixes golang/go#36982

Change-Id: Ia64ba9db73ed92b853f1f955330caf93d996da91
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/241273
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2020-07-14 18:56:54 +00:00
Julie Qiu a31de3da16 all: set GoogleTagManagerID using environment variable
The Google Tag Manager ID is now set using an environment variable,
instead of hardcoding in our templates. This prevent users from sending
traffic data. to the GTM for pkg.go.dev by default, when they fork the
repository.

Change-Id: I5a1f985db20fd19378612593bde3f640b2b40d09
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/241742
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-07-13 18:29:39 +00:00
Miguel Acero 329d947dae internal/frontend: add frontend server endpoint for proxying play.golang.org/share
This change adds a /play handler that mirrors requests
to play.golang.org/share which is used in implementing playground
integration in the frontend. This change also adds a test that
includes a mock server using net/httptest to check for proper
status codes.

Updates golang/go#36865

Change-Id: Ia3e902808534189ada747b270fed908e766c224b
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/241164
Reviewed-by: Julie Qiu <julie@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-07-09 14:37:36 +00:00
Julie Qiu 71c954f70e content,internal: allow POST requests for fetch endpoint
The frontend now accepts POST requests, which is used for the /fetch
endpoint. The /fetch endpoint will return the standard 404 page when a
GET request is made. When a POST request is made, it will return a
plain text response.

serveDetails and serveSearch now check the request method to ensure
a GET request is being made.

Fixes golang/go#39979.

Change-Id: Icc4d7f6ab7ebdbabdae43eab5a1c29a6446651bb
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/241378
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-07-08 13:28:41 +00:00
Jonathan Amsterdam 073d8fe5ef internal/frontend: use safehtml
Begin using github.com/google/safehtml for frontend templates.

The safehtml module replaces html/template to provide more secure
template execution.

- Templates must come from constant strings or trusted sources.
  This CL constructs TrustedSource values from the filesystem
  paths that we use.

- Injected HTML must be constructed from known safe values.  This CL
  does this in some places. In others, notably the documentation, it
  uses an escape hatch that we will close in a future CL.

- Identifiers must be constructed safely. We temporarily use an
  escape hatch for license identifiers.

- There is a gotcha when using safehtml types: values that
  resolve to the empty string do not evaluate to false in the
  context of an `if`. We have to replace `.X` inside an `if`
  with `.X.String` when `.X` is a `safehtml.HTML` or the like.

Still to be done:

- Remove all `legacyconversions.RiskilyXXX` calls (https://golang.org/issue/39960).

- Remove `template.HTML` from internal/fetch/dochtml (https://golang.org/issue/39959).

Change-Id: Icf4793d70cb2441ba30abd4e7394c4696be64a7b
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/240499
Reviewed-by: Julie Qiu <julie@golang.org>
2020-07-07 17:14:32 +00:00
Julie Qiu 993436f73a content: update frontend fetch UI
The frontend fetch UI is updated with a styled button, and loading dots
to indicate that a fetch request is in progress.

The Fetch API is now used instead of AJAX to make requests.

Updates golang/go#36811
Updates golang/go#37002

Change-Id: Ia37113dd9976f8e147875371c099f7b2bfd4bd85
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/240459
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2020-07-01 17:52:00 +00:00
Jonathan Amsterdam 1940919ec2 many: change CSP to use hashes instead of nonces
Change our content security policy (CSP) for scripts.

Instead of using a nonce, which lends itself poorly to caching, use
hashes. See https://csp.withgoogle.com/docs/faq.html, search for "CSP
hashes".

To make hashes work, the hash of every inline script must appear in
our Content-Security-Policy header.

Also, not all browsers support hashing with scripts loaded from files,
so we must dynamically load the files by using an inline script that
builds a script tag with a src attribute. (We need to do this anyway
for the Google Tag Manager script.) See the link above for a
description of the technique. It works because the CSP header mentions
'strict-dynamic', which trusts everything loaded from a trusted
script.

Ideally, we would both generate all these hashes automatically,
and check that they are all correct. This CL doesn't do that.
A followup CL will.

List of changes:

- Replace script tags with scr attributes with inline scripts that
  load from the files.

- In internal/middleware/secureheaders.go, add the list of script
  hashes to the CSP header.

- Remove all references to nonces.

Updates b/159711607.

Change-Id: Ia9b78ecd85e24619e758f2580a370778708b9e71
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/239897
Reviewed-by: Roberto Clapis <robclap8@gmail.com>
Reviewed-by: Julie Qiu <julie@golang.org>
2020-06-29 21:25:26 +00:00
Julie Qiu 012f2a31b8 internal/frontend: add fetch endpoint to robots.txt
Disallow: /fetch/* is added to the robots.txt, so that search engines do
not crawl the endpoint and make unnecessary fetch requests.

Updates golang/go#36811
Updates golang/go#37002

Change-Id: I46d7691ba416413bdaac36ab50ed2f86dee3a7ff
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/240457
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-06-29 19:38:28 +00:00
Jonathan Amsterdam 8acea93dd9 internal/{source,frontend}: escape HTML
Escape any strings that may come from outside the program and will
be rendered as HTML.

Also, fix some typos.

Also, put args to a cmp.Diff call in the right order.

Change-Id: I1fc6013e200326af8719b14c28a607fc7936e20a
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/239478
Reviewed-by: Julie Qiu <julie@golang.org>
2020-06-23 13:36:35 +00:00
Jonathan Amsterdam 8c8a3b1d6e internal/config: remove global
Remove the `cfg` global and the functions that accessed it.

Fixes b/145301722.

Change-Id: I58ab9fbd4fc29f66dbc5b120f04c88ee0703ee57
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/238437
Reviewed-by: Julie Qiu <julie@golang.org>
2020-06-17 16:27:43 +00:00
Julie Qiu a2ecf39f2c internal/frontend: refactor details handlers
At the moment, there are three handlers for serving the details page,
which are now combined into one. This reduces duplicated logic, and
makes it easier to support logic for requests to path@master.

Change-Id: Iedde7430ff5106ea97a4c062f9e83123fa12c5a5
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/769963
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-06-15 13:17:20 +00:00
Jonathan Amsterdam 70674707f3 internal/frontend: use struct for args to NewServer
Also, fix bug where the worker change interval was being passed in.

Change-Id: Ia1fa19b231acd2d0d307ea418d1fd0d8c3a4c320
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/768541
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-06-12 16:15:30 +00:00
Julie Qiu ccee67b0a2 content,internal/frontend: make a request to /fetch on path 404
When a path page 404s, it will now render the notfound.tmpl page (once
the frontend-fetch feature flag is on), which provides a button for the
user to make a request to fetch the package.

Updates golang/go#36811
Updates golang/go#37002
Updates golang/go#37106

Change-Id: I17fedd018435e8d3e51e2a2a4a972d3cf673df56
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/753606
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-06-04 15:56:15 +00:00
Julie Qiu 45475dd537 {cmd,internal}/frontend: add handler to download paths that do not exist
A fetch endpoint is added to the frontend, which will queue a module to
be enqueued by the worker, if it doesn't already exist in the database.

After enqueuing, the fetch handler will poll the version_map table at a
constant rate, until the path returns or the request times out.

If the request fails, a corresponding statusCode and responseText will
be returned to be displayed to the user.

Updates golang/go#36811
Updates golang/go#37002
Updates golang/go#37106

Change-Id: Ic2e20146dc626bf296db05bc2abbfb50d6fd7991
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/743103
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-06-04 15:55:57 +00:00
Julie Qiu 0bbc5df5bf cmd,internal: move taskIDChangeInterval to config
At the moment, taskIDChangeInterval is a hardcoded value in
internal/queue. However, we will soon have two task queues running,
which require different change intervals, so this value is now set in
internal/config.

Additionally, the taskIDChangeInterval for the worker is changed to 3
hours.

Change-Id: I498abefce6543005463be7da99a5a778f3a6e973
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/758919
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-06-02 00:27:30 +00:00
Julie Qiu b92b3aeb6b internal/frontend: check for underlying serverError in serveError
At the moment, all errors for servePackagePageNew will return a 500,
because of derrors.Wrap. This is fixed by checking to see if the
err passed to serveError is of type serverError, and if so, return the
status code of the underlying serverError. Regardless of the error
type, the full error will be logged.

Change-Id: I502b174e1efb9f856f17ffb3614fedc909ef162c
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/754806
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-05-28 15:39:25 +00:00
Andrew Bonventre 5ab9d78a3e all: clean up some issues noticed by Lighthouse
+ Update the title suffix from go.dev to pkg.go.dev and some
  incorrect usages
+ Add a meta description for SEO purposes
+ Lazy-load images in the footer (requires setting heights and
  widths for both images because otherwise loading could cause
  reflow
  (see https://web.dev/native-lazy-loading/)
+ Use rel=noopener in places where it is not present or
  where it was redundant with noreferrer. Both are not needed
  (see https://web.dev/external-anchors-use-rel-noopener/)

Change-Id: I46767bd67e6db01c4d5921926381d5b32a89f018
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/752824
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
Reviewed-by: Alexander Rakoczy <rakoczy@google.com>
2020-05-26 17:21:35 +00:00
Andrew Bonventre dc3877069a internal/frontend, content/static/html: use GTM only
This change removes Google Analytics in favor of just Google
Tag Manager since you can use the latter to send page view data
to the former.

Additionally, adds Google Tag Manager’s debugging view CSS domain
to the content security policy.

Only renders GTM resources when not in development mode.

Change-Id: I54149c378f7226e24d836c730a8fed641d9bcb54
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/751128
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-20 22:27:41 +00:00
Andrew Bonventre 88b406e53e cmd/frontend, internal/frontend: add local development mode
This change replaces the reloadTemplates field with a more general
devMode that will allow for changes to ease ergonomics when
developing locally.

Change-Id: I87132830f51070cfc3905cf739d87ddc35f2f42b
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/751682
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-20 22:07:23 +00:00
Jonathan Amsterdam 5940769e5d internal/frontend: factor out test server creation
Create test servers, their handlers, and middleware in
a single function.

Also factor out adding experiments to a context.

Change-Id: I1a4046e1d190ed7c5f3fe3d12b999bc947821b5c
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/747787
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-05-18 16:14:37 +00:00
Julie Qiu 2c08c8685d internal/frontend: add queue
The frontend server is not initiated with a queue. The frontend task
queue will be used to support frontend fetches.

frontend.FetchAndUpdateState is added, which is a copy of
worker.FetchAndUpdateState for use in testing and locally.

Updates golang/go#36811
Updates golang/go#37002
Updates golang/go#37106

Change-Id: I41922d30462d2623a061aa1f207bb2b39f7b54e2
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/743102
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-05-13 17:29:52 +00:00
Andrew Bonventre 501dedc1d8 internal/frontend: update robots.txt to allow crawling
Allow crawling of all pages except for search results.

Change-Id: Id151e290cbf08cd21dfaa904652240507e9e7121
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/745555
Reviewed-by: Julie Qiu <julieqiu@google.com>
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
2020-05-12 18:36:49 +00:00
Andrew Bonventre 34a0e6a6e9 internal/frontend: update Google Tag Manager tag ID
Updates b/154628605

Change-Id: I60d34c1ab9e0126bc0fb7dc7941d7d8f78f8ff70
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/728395
Reviewed-by: Julie Qiu <julieqiu@google.com>
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
2020-04-24 22:37:52 +00:00
Julie Qiu 19794c8aeb all: rename module to golang.org/x/pkgsite
golang.org/x/discovery is renamed to golang.org/x/pkgsite.

When the repository is open sourced, it will be hosted at
go.googlesource.com/pkgsite.

Change-Id: Ifc3b45b771a385b99179e785447f2a87afcacf87
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/724273
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-04-23 16:18:43 +00:00
Andrew Bonventre 9ec03558a7 discovery: tweak godoc.org URL middleware to use placeholder
This changes the logic in the GodocURL middleware to use the placeholder
technique used by nonce and latest to avoid caching issues interacting
badly with the display of the “Back to godoc.org” button.

The button is shown (via CSS rules) if it has a non-empty href attribute.

Updates b/147492306

Change-Id: I978e9765df2fbf887ee89f4a30ed48a955434f0c
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/704879
Reviewed-by: Julie Qiu <julieqiu@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-04-06 17:09:52 -04:00
Julie Qiu 28f2ccbd9b Revert "content: add pkg.go.dev/about"
This reverts commit 0cac64d3f37dcbaa5df38ca33120b7669d381691.

Reason for revert: decided to keep all content on go.dev/about in weekly meeting

Change-Id: I901bb8951858c0af8b08da29d68a2ace044d0181
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/702040
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-04-06 17:09:52 -04:00
Andrew Bonventre 7796a18097 discovery: add UI for “Back to godoc.org” button
With the option to redirect automatically from godoc.org, there needs
to be a mechanism to return to godoc.org and turn it off if necessary.
Reliably knowing that a request is coming from a godoc.org redirect
is complicated as you can’t set cross-origin cookies and 3XX redirects
don’t alter the Referer header.

In order to reliably know that a request is coming to pkg.go.dev from
godoc.org, we look for a utm_source GET parameter set to 'godoc'.
If we see this, we set a temporary cookie and redirect to the
pkg.go.dev URL with the utm_source param stripped (so that it doesn’t
remain in all our URLs coming from godoc.org). If this temporary cookie
is seen, it is marked to be deleted and the correct value for the
“Back to godoc.org” link is set. The existence of this value will be
used to determine whether to show the button in the UI.

Updates b/147492306

Change-Id: I9c2e6b891ba4f23b7490c087d32583cd7f0f6ad8
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/696565
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-04-06 17:09:52 -04:00
Julie Qiu a62e10fd3a content: add pkg.go.dev/about
Fixes b/151943636

Change-Id: I167913003e9edbb37b51844e58ad72f4c39ff268
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/696059
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-04-06 17:09:52 -04:00
Andrew Bonventre 1832788466 discovery: move content/static/third_party to top-level directory
This is required per Google’s open source policies.

Change-Id: Iff06d489a30f051c024618e53f65e46d4f89df94
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/697023
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-04-06 17:09:52 -04:00
Julie Qiu d662c033ed all: clean up references
Change-Id: I6bed81cdc23a73fafbd382e856e9bc55c391eaa7
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/692499
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-04-06 17:09:52 -04:00
Jonathan Amsterdam 24cce3461a internal/frontend: only link to OSI licenses
On the license-policy page, remove links to licenses
that aren't on the OSI website.

If we later find links to the other licenses, it shouldn't
be hard to add them.

Fixes golang/go#37872.

Change-Id: Icadd9128b18c4d2b408e9726d5fec7dc9c9fe4ea
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/692259
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-04-06 17:09:52 -04:00
Jonathan Amsterdam 4c2bb765a1 internal/frontend: handlers return error
Instead of serving an error page themselves, top-level handlers return
an error with the information for serving the error page.

This is a largely mechanical rewrite that removes a lot of clumsiness
from the handling code. For example, instead of

   if err != nil {
      log.Errorf(ctx, "frobbing: %v", err)
      s.serveErrorPage(w, r, http.StatusInternalServerError, nil)
      return
   }

the code is both simpler and more idiomatic:

   if err != nil {
       return fmt.Errorf("frobbing: %v", err)
   }

It is still possible to include an errorPage with the error, like so:

  if err != nil {
      return &serverError{
          status: http.StatusBadRequest,
	  epage: &errorPage{...},
	  err: err,
      }
  }

Change-Id: Id076894b1cb912fe0731fdf6fbdb7b0e5b972bcb
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/686039
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-04-06 15:50:52 -04:00
Jonathan Amsterdam 1c9e2896c1 licenses: match filenames case-insensitively
Approved 

Fixes b/148715828.

Change-Id: I5bc87e7899cd08d408ff4798b33dc5286ff5e197
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/653253
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:52 -04:00
Julie Qiu 9e3a9fe8eb internal/frontend: redirect /about to go.dev/about
Pkg.go.dev/about now redirects to go.dev/about, with status 302. This is
to make it easier to redirect godoc.org/-/about, in case we decide to
have our own about page in the future.

Change-Id: I3acfc421c99148a834b765ef9a60cd4f411631c6
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/649302
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-03-27 16:46:52 -04:00
Jonathan Amsterdam f35b7eb88c internal/license: remove package
Remove the internal/license package, and all references to it.

Mostly I replace with equivalent functionality from licenses. But for
the dbpopulate command, I just remove the whole thing because it's
obsolete: it checks for NULL redistributable column but that column is
now NOT NULL.

Change-Id: I15bfe02f9f71b0adc3743b114b5d6b6dd442af6a
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/644662
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:51 -04:00
Julie Qiu 81ff962bc1 content,internal/frontend: add GoogleTagManager
Integrate Google Tag Manager, following instructions at:
https://developers.google.com/tag-manager/quickstart

Updates b/147106668

Change-Id: I2c7bab6f7477376c296cffbeb77d41ad96ddbdf9
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/626669
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-03-27 16:46:50 -04:00
Julie Qiu 7b33ae5fbe content,internal/frontend: use experiments library for autocomplete
Updates b/146052411

Change-Id: Ie109b7fafedca2c2077a03696c550b1439824879
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/620410
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-03-27 16:46:50 -04:00
Rob Findley 99be1755c9 internal/frontend: fix a stale error message
Change-Id: I6a795e6d47c73ebb80f849020c2f59211b51af30
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/623710
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-03-27 16:46:50 -04:00
Jonathan Amsterdam 193997f5c7 internal/{log,middleware}: add trace ID to context, use in logging
- The requestlog middleware gets the trace ID from the request and
  adds it to the request's context.

- The internal/log package retrieves the traceID and adds it to log
  messages. It also creates two logs instead of one, a "parent" log
  used in requestlog, and a "child" log used for all other logging.
  Together, these two changes will cause the Stackdriver log viewer to
  group all log messages for a request with the request start and end
  log messages.

- These changes require that all log functions take a context, so I
  plumbed one through everywhere. In a handful of cases it didn't seem
  worth doing the plumbing. I used context.TODO() for those so we can
  easily find and re-evalaute them.

Change-Id: I663588463520187d0549a8f802ba9cb44a893592
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/622940
Reviewed-by: Robert Findley <rfindley@google.com>
2020-03-27 16:46:50 -04:00
Jonathan Amsterdam 322d16763e all: remove xerrors
Now that we are on Go 1.13, we can use the errors package and remove
xerrors.

Change-Id: I8b30bcea97da25cc92b8e250299a68417a85143d
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/623768
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:49 -04:00
Rob Findley 3420f07cb6 internal/frontend,content: guard the autocomplete behind an experiment
A fake experiment handle is used to guard the autocomplete feature
behind a flag. It defaults to false (experiment off).

Change-Id: Ib9f26c00a6e0374277c27c605aa8c9809464623f
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/619084
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
Reviewed-by: Alexander Rakoczy <rakoczy@google.com>
2020-03-27 16:46:49 -04:00
Julie Qiu 1ab926d464 internal: move Datasource from frontend to internal package
frontend.Datasource is moved into internal.Datasource, so that it
can be used in future CLs in the internal/middleware package.

Change-Id: Id4823b46f36f114fd02ee3b8ac78c1e6d24c0cc5
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/611020
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-03-27 16:46:49 -04:00
Julie Qiu 2b87642aba internal: move postgres.SearchResults to internal
Previously, SearchResults was in the postgres package, but being used by
internal/frontend and internal/proxydatasource. SearchResults is now moved to
internal, so neither package has to import the internal/postgres
package.

Change-Id: I9119b6bacb07e006a9b404f6a5e71dbf483688e2
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/610961
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-03-27 16:46:49 -04:00
Jonathan Amsterdam 8e9667a691 internal/frontend: remove latest-version endpoint
It's been a while since we switched to using substitution
for the latest-version badge. It's unlikely there are many
loaded browser pages with the old code.

Change-Id: I1a963963940227f10a259ca0f0b10f80d5f36850
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/611021
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:49 -04:00
Jonathan Amsterdam 58b4f954d2 internal/frontend: distinguish titles
Distinguish the "page title," which is put in the <title> element
and thus appears in tabs, from the title that appears at the top
of a details page.

The title in a tab should start with the resource name (e.g. "io package")
so it's readable when many tabs are open.

The page title should read more naturally (e.g. "package io").

Fixes b/145124550.

Change-Id: I29d5a92f0f51c6b2f20691dd383695dacbdd1956
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/606800
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:49 -04:00
Julie Qiu 1795bf059b Revert "internal/frontend: distinguish titles"
This reverts commit a13a2bf99ae64c9cce01a5caaf441a9b8121afd6.

Reason for revert: tests are failing for TestServer

Change-Id: Icb3c23c158e7ea77190883e4441160535e257975
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/606421
Reviewed-by: Julie Qiu <julieqiu@google.com>
2020-03-27 16:46:48 -04:00
Rob Findley af03df5f97 content: update license disclaimer
.





Fixes b/144972991

Change-Id: I2e94bda5988bebdfb9dd7a3b90c55aba4fda5309
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/601086
CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2020-03-27 16:46:48 -04:00