summaryrefslogtreecommitdiff
path: root/pgweb/docs/views.py
AgeCommit message (Collapse)Author
2023-05-04Don't look at developer docs when getting released release notesMagnus Hagander
This could cause a crash when the devel version of the docs had a placeholder entry for a major version that had not yet been released.
2023-05-04Move variable assignments to correct levelMagnus Hagander
Fixes redirect from "naked major version" URLs when major version is 2-digit.
2023-05-04Fix copy/paste for .0 versions of 3-digit version numbersMagnus Hagander
2023-05-04Refactor release notes renderingMagnus Hagander
Move to use core_version for more information, making some purges easier and more predictable as well. Just create a hardcoded list of versions prior to what we have real version entries for, it's just a couple that we need to reference old release notes for (pre-6.3), so it simplifies a lot. Fixes (again) the release notes purging to use xkeys as set, which was accidentally and partially undone in ac618d1b. Generally makes the code easier to read and fixes a few cornercases. Templates also much simplified, with the list template accidentally already committed as part of 19682de8. Reviewed-by: Jonathan Katz
2023-02-21Allow unsafe-inline styling on SVG images in docsMagnus Hagander
We already allow it on the docs pages themselves, but not on images served up. Seems it can't get worse, and hopefully this fixes the reported issues. Reported by: Peter Geoghegan
2022-06-20Store the git hash of developer docs loadedMagnus Hagander
This will require some further updates on the loading side of things before it's fully valid, but for now track and show a link to the git hash used to build developer docs *if* one is specified. We only track it for devel (because releases have release numbers) and we only show it in the cases where we would already show the loading time.
2022-03-21Add canonical page references to documentationJonathan S. Katz
This sets the documentation pages to use the "/docs/current/" prefix to be the canonical docs. This follows SEO guidance to help improve which doc pages show up higher in search, per: https://developers.google.com/search/docs/advanced/crawling/consolidate-duplicate-urls Reviewed-by: Magnus Hagander <magnus@hagander.net> Reviewed-by: Andres Freund <andres@anarazel.de>
2021-09-15Re-allow framing of images in docsMagnus Hagander
Commit fff74828 disallowed the loading of docs in frames, but apparently svg images count as framing, so re-allow those. We could limit it to specific URLs, but it's just images so it's good to be able to load them from different places. Discussion: https://postgr.es/m/CAH2-WzkpfQROHTx_F3RM6AUbxquxHy4QWXfVkNPWm3s9AFmtkg@mail.gmail.com
2021-08-20Disallow framing of the documentation pagesMagnus Hagander
We previously had an exception on the documentation pages, because pgadmin4 used to load them in an iframe. This is no longer the case and hasn't been for a while, so remove the exception. Confirmed "shuold be ok" by Dave Page :)
2021-08-16Add proper xkey tags to docs 404 pagesMagnus Hagander
Since we purge docs pages based on the version they are for, we need to tag the 404 pages with version as well, when available. Without that, any page that had been requested returning a 404 (such as somebody or some tool polling for release notes on a version that hasn't been released yet) would not get purged when new docs are loaded, which results in the 404 staying around even after the actual docs are updated.
2021-08-16Fix typoMagnus Hagander
2021-05-18Enhance the xkey tags set on documentation pagesMagnus Hagander
* For 'current' docs, *also* set the xkey pgdocs_current. Otherwise when a new major release is turned into current, the loader purge wouldn't be able to replace it, only replace the devel version. * Set the pgdocs_<version> key on the release notes pages under /release/ (this is what triggered me to look at this) * Set the pgdocs_all key for index pages such as /docs/ and /docs/release/. This will be purged every time, making sure we have an up-to-date list of versions. * Set the key pgdocs_pdf for any pages that have PDF file information in them, so we can purge the list when new PDFs are uploaded.
2020-11-24Update layout of documentation navigation pagesMagnus Hagander
* Move links to current manuals to /docs/, decommission /docs/manuals/ * Add link to /docs/current/ with a large button * Add links to /docs/devel/ at the bottom of the version table * Remove translated manuals from left nav menu, since they are in the right one * Remove redundant wording around "comprehensive manual" * Clean up some incorrect template tags Discussion: https://www.postgresql.org/message-id/CABUevEymaWDL4JywHxBDBATUUPPrAf4_tGwin4CtGFdQ5tx5Hg@mail.gmail.com
2020-11-23Add per-version xkey tags to documentation pagesMagnus Hagander
This is not used for anything yet, we need it to propagate into all long-term caches before we can start using it.
2020-10-22Add opengraph tags to some pagesMagnus Hagander
Add template support for opengraph tags (which will enable things like icons and preview on posts to twitter and facebook and other places) to both base pages and documentation pages. Use this to actually add the tags to docs pages (only v10+ will get text previews, but all should get the titles and image) and news (only news from the project will get an image, all get both title and text)
2020-10-21Reduce number of queries to render a docs pageMagnus Hagander
One query for each version, supported or unsupported, now replaced with a single query to get all of them.
2020-10-12Allow for direct URLs to abbreviated legacy PostgreSQL releasesJonathan S. Katz
For example, while a link to "/docs/release/9.1.0/" would work, going to "/docs/release/9.1/" would not; in this case, it would show the release details for "9.0.1". While the probability of someone modifying the links to see the different release notes is low, we would still need to take action on what is an incorrect link. Instead of returning a 404, this transposes the major/minor version to point at the canonical version number and render the expected page. This is set up to work for the 6, 7, 8, 9 series. Reported by: Nikolay Samokhvalov <samokhvalov@gmail.com>
2020-09-10Turn off usergenerated flags for email from our own addressesMagnus Hagander
News, docs and bugs are all sending from our own noreply addresses these days, so they should not be flagged as usergenerated (flagging as usergenerated will revent dkim signing, amongst other things)
2020-04-24Introduce documentation redirects for doc pages that are renamedJonathan S. Katz
The web documentation used to suffer from a problem that if a documentation page were renamed in a newer version, any references pointing to said documentation would be lost. For example, the feature known as "Default Roles" was renamed to "Privileged Roles" but caused a change in the URL. This patch introduces the ability to create a "DocPageRedirect" by specifying the previous name of the documentation page (e.g. "default-roles.html") and the new name (e.g. "privileged-roles.html") such that the continuity is preserved between versions.
2020-01-09Fix a number of incorrect escapesMagnus Hagander
Pointed out by newer versions of pep8, but they were never correct.
2020-01-09Stop using bare exceptionsMagnus Hagander
This is frowned upon in newer versions of pep8, so fix it once and for all.
2019-10-30Ensure all release notes are accessible from "devel"Jonathan S. Katz
When a new PostgreSQL branch is created, any "devel" notes for that branch become immediately unavailable, which would make any shared devel links around that dead. This adjusts this logic such that any release notes for a release, beta or otherwise, is now available by redirect the user to the release notes' permanent home. Reported By: Andres Freund <andres@anarazel.de>, who also mostly authored the patch over email.
2019-03-31Allow displaying SVG images in documentationMagnus Hagander
PostgreSQL 12 adds SVG images in the documentation, so the website should be able to display them. The images themselves were already loaded by the docsloader, but the regexps in the URL would block them from being seen. Fix this by creating a separate function for the SVGs, since we also don't want to render them inside teh templates. This new view must also be tagged with @allow_frames, since the browser considers the <object> tag used to be a subframe. Without this, they would be blocked from viewing even on our own site.
2019-03-31Only get the current version for docs pages if we need itMagnus Hagander
2019-03-21Provide a 404 error for nonexistent minor versions of release notes.Jonathan S. Katz
2019-03-20Enable redirects to older release notes from the development doc builds.Jonathan S. Katz
Prior to this, if you referenced a version of the release notes that was outside of the current development build (e.g. 9.6) the URL would 404. Reported by Andres Freund.
2019-03-10Style fixups to pass pep checksMagnus Hagander
This fixes the style issues introduced in the patches for the new release notes styles. Clearly a broken verification hook somewhere.
2019-03-10Further fixes for bad urls in docs redirectMagnus Hagander
2019-03-10Ensure the new "release-prior" page can be accessed.Jonathan S. Katz
This fixes a bug where the "release-prior" page was being evaluated as a legacy release notes page in the supported docs.
2019-03-08Ensure release notes from older version still load without 404 errors.Jonathan S. Katz
An upcoming change in PostgreSQL keeps only release notes in their current versions. So e.g., PostgreSQL 11 only has the release notes for 11.0, 11.1, 11.2 etc. Thus, for PostgreSQL 9.4 on up, any URLs such as /docs/10/release-9-6-8.html would return a 404. Additonal, URLs with /current/ and /devel/ would break as well. This patch prevents these 404s from occuring by redirecting users accessing release notes in the 9.4 and above documentation to the older versions of the release notes by redirecting them to the notes in the specific version. So in the above example, a user would be redirect to /docs/9.6/release-9-6-8.html As we do not have documentation on the website past 7.2, any release notes from an older version are redirected to the release notes tree in 7.2
2019-03-08Create Release Notes archive in the Documentation section.Jonathan S. Katz
This creates a consolidated area to reference all of the notes from previous releases of PostgreSQL, as current releases only keep the the notes for that specific major release of PostgreSQL.
2019-01-28Make docs comment suggestions do a redirectMagnus Hagander
This is the same as b2ed4946551c098079d1a156b222d4ebf5c85cba did for bug reports. This changes the regexps for all the doc comment suggestions forms to be a little bit more specific than before.
2019-01-28Fix docs comment form for version = "current"Magnus Hagander
Normally not reachable with "current", only with explicit version, but as proven by some live crashes, there is some way to. So make sure we look up the current version instead of crashing.
2019-01-26Update syntax for relative importsMagnus Hagander
2019-01-17Fix whitespace and indentation, per pep8Magnus Hagander
2019-01-17Tabs, meet your new overlords: spacesMagnus Hagander
In a quest to reach pep8, use spaces to indent rather than tabs.
2018-12-22Allow unsafe inline style on docsMagnus Hagander
Our new docs build seems to put this in there, and only older docs were tested it seems.
2018-12-21Enable setting of security http headersMagnus Hagander
The following security policy headers are set: X-XSS-Protection: 1; mode=block -- always set X-Frame-Options: DENY is set for all pages except for the documentation pages, primarily because pgadmin4 loads them in an iframe which would break. Content-Security-Policy: <x>-src Is set to allow the default of self only, then allowing scripts for google analytics and fonts for google fonts. Images are allowed from everywhere. frame-ancestors 'none' is set by the same rules as X-Frame-Options This also adds a decorator for @script_sources to have a single view allow extra sources, and this is used for recaptcha. A generic decorator is also made for other types of exclusions, though we don't have any at this point. If the setting SECURITY_POLICY_REPORT_ONLY is set to True then the policy will be report-only and not enforced (for testing), otherwise enforcing mode is enabled. The setting SECURITY_POLICY_REPORT_URI sets where to send security policy reports, if any.
2018-11-05Use "old-style" string format on doc URL redirect.Jonathan S. Katz
This eliminates a unicode error.
2018-11-05Remove "/static/" from doc URLs.Jonathan S. Katz
This creates a permanent redirect for any doc URL that references the "static" path (i.e. all doc URLs), which allows a format similar to: /docs/current/index.html This is in response to not having "interactive" as an available option, which should lead to shorter, less confusing URLs.
2018-10-16Apply modern pgweb styles to web-based documentation.Sarah Conway
This patch brings the web-based documentation to match the current styles on the main postgresql.org website. The CSS supports the generated markup from the main PostgreSQL documentation and supports the new/old class that are visible in the documentation (e.g. uppercase classes pre-v10). Authors: Sarah Conway, Jonathan Katz
2018-06-29Remove leftover testing codeMagnus Hagander
2018-05-03Don't allow docs comments on unsupported versionsMagnus Hagander
2018-04-15Update language on "Submit Documentation Comment" page.Jonathan S. Katz
The language is more thorough in describing how to use the form, in an effort to help improve the overall quality of submissions to pgsql-docs.
2018-04-05Change field labels for docs comments formMagnus Hagander
Clearly indicate what's subject, what's body, and that it's sending an email.
2018-03-23Pdf wrapper should not inherit from django modelMagnus Hagander
It was already storing the version as a field, the inheriting from the actual model was never used. Remove it, since newer django tries to access a table based on the class name..
2018-03-10Replace NavContext and render_to_response with render_pgwebMagnus Hagander
render_to_response does not work on newer django, so it needs to be replaced. And using a speicfic context actually overcomplicates things, it's easier to just use a wrapper function. For those cases where we don't need NavContext, just use render() (the new shortcut function from django), which also removes the need to use RequestContext.
2018-01-06Fix doc comments for devel versionMagnus Hagander
Don't say version 0.0 in the emails that are sent out. That's what we call it internally, but the URL should have /devel/ in it. Fix this both in the template, and then if it comes through in the form again in case the user picked up a link elsewhere that is incorrect.
2017-12-18Fix reply-to address for docs comments emailsMagnus Hagander
2017-12-18Set sender name on bug report and docs comments emailMagnus Hagander