-
Notifications
You must be signed in to change notification settings - Fork 6
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
Self host redoc #284
Open
Zanda256
wants to merge
4
commits into
opentofu:main
Choose a base branch
from
Zanda256:38/self-host-redoc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,056
−17
Open
Self host redoc #284
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package internal | ||
|
||
//go:generate go run github.com/opentofu/registry-ui/internal/tools/pull-redoc --version v2.3.0 --checksum 87e6d82ac43f8f797369dab7616381d06a1f9a55455a3dc47e8366afd73fb9d0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>OpenTofu Registry UI API</title> | ||
<meta charset="utf-8"/> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<style> | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<redoc spec-url='/openapi.yml'></redoc> | ||
<!-- TODO self-host this --> | ||
<script src="https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js"> </script> | ||
</body> | ||
<head> | ||
<title>OpenTofu Registry UI API</title> | ||
<meta charset="utf-8"/> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<style> | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<redoc spec-url='./openapi.yml'></redoc> | ||
<script src="redoc.standalone.js"> </script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
102 changes: 102 additions & 0 deletions
102
backend/internal/server/redoc.standalone.js.LICENSE.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/*! | ||
Copyright (c) 2018 Jed Watson. | ||
Licensed under the MIT License (MIT), see | ||
http://jedwatson.github.io/classnames | ||
*/ | ||
|
||
/*! | ||
* ReDoc - OpenAPI/Swagger-generated API Reference Documentation | ||
* ------------------------------------------------------------- | ||
* Version: "2.3.0" | ||
* Repo: https://github.com/Redocly/redoc | ||
*/ | ||
|
||
/*! | ||
* Stickyfill -- `position: sticky` polyfill | ||
* v. 1.1.1 | https://github.com/wilddeer/stickyfill | ||
* Copyright Oleg Korsunsky | http://wd.dizaina.net/ | ||
* | ||
* MIT License | ||
*/ | ||
|
||
/*! | ||
* perfect-scrollbar v1.5.3 | ||
* Copyright 2021 Hyunje Jun, MDBootstrap and Contributors | ||
* Licensed under MIT | ||
*/ | ||
|
||
/*! @license DOMPurify 3.1.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.3/LICENSE */ | ||
|
||
/*!*************************************************** | ||
* mark.js v8.11.1 | ||
* https://markjs.io/ | ||
* Copyright (c) 2014–2018, Julian Kühnel | ||
* Released under the MIT license https://git.io/vwTVl | ||
*****************************************************/ | ||
|
||
/** | ||
* @license React | ||
* react-dom.production.min.js | ||
* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
/** | ||
* @license React | ||
* react.production.min.js | ||
* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
/** | ||
* @license React | ||
* scheduler.production.min.js | ||
* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
/** | ||
* @license React | ||
* use-sync-external-store-shim.production.min.js | ||
* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
/** | ||
* Prism: Lightweight, robust, elegant syntax highlighting | ||
* | ||
* @license MIT <https://opensource.org/licenses/MIT> | ||
* @author Lea Verou <https://lea.verou.me> | ||
* @namespace | ||
* @public | ||
*/ | ||
|
||
/** @license React v16.13.1 | ||
* react-is.production.min.js | ||
* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
/** @license React v17.0.2 | ||
* react-is.production.min.js | ||
* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package main | ||
|
||
import ( | ||
"crypto/sha256" | ||
"encoding/hex" | ||
"flag" | ||
"fmt" | ||
"io" | ||
"log" | ||
"net/http" | ||
"os" | ||
) | ||
|
||
func main() { | ||
version := "" | ||
checksum := "" | ||
flag.StringVar(&version, "version", "latest", "The version of ReDoc to download.") | ||
flag.StringVar(&checksum, "checksum", "", "The checksum of the ReDoc script file corresponding to the version to be downloaded.") | ||
flag.Parse() | ||
|
||
fmt.Printf("checksum: %+v\n", checksum) | ||
|
||
// Pull Redoc script from Redocly CDN | ||
redocCDNURL := fmt.Sprintf("https://cdn.redoc.ly/redoc/%s/bundles/redoc.standalone.js", version) | ||
|
||
redocFileName := "redoc.standalone.js" | ||
redocFile, err := os.Create("server/redoc.tmp") | ||
if err != nil { | ||
log.Fatalf("err creating ReDoc script tmp file: %v", err) | ||
} | ||
defer redocFile.Close() | ||
|
||
resp, err := http.Get(redocCDNURL) | ||
if err != nil { | ||
log.Fatalf("err downloading ReDoc script file: %v", err) | ||
} | ||
defer resp.Body.Close() | ||
if resp.StatusCode < 200 || resp.StatusCode > 299 { | ||
err = fmt.Errorf("err downloading ReDoc script file: %+v\n", resp) | ||
log.Fatal(err) | ||
} | ||
|
||
// Copy downloaded contents to a local file | ||
if _, err = io.Copy(redocFile, resp.Body); err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
// Reset file pointer to the beginning before reading it into the hash | ||
if _, err = redocFile.Seek(0, 0); err != nil { | ||
log.Fatal(err) | ||
} | ||
hash := sha256.New() | ||
_, err = io.Copy(hash, redocFile) | ||
if err != nil { | ||
log.Fatalf("err hashing script file: %+v\n", err) | ||
} | ||
|
||
// compare hashed value with supplied checksum | ||
if checksum != hex.EncodeToString(hash.Sum(nil)) { | ||
log.Fatalf("could not verify checksum for the file : %+v\n", redocFileName) | ||
} | ||
|
||
err = os.Rename("server/redoc.tmp", fmt.Sprintf("server/%s", redocFileName)) | ||
if err != nil { | ||
log.Fatalf("Error renaming ReDoc script file: %v", err) | ||
} | ||
|
||
// Pull ReDoc LICENSE file | ||
licenseFileURL := fmt.Sprintf("https://cdn.redoc.ly/redoc/%s/bundles/redoc.standalone.js.LICENSE.txt", version) | ||
|
||
licenseFile, err := os.Create("server/license.tmp") | ||
if err != nil { | ||
log.Fatalf("err creating ReDoc license tmp file: %v", err) | ||
} | ||
resp1, err := http.Get(licenseFileURL) | ||
if err != nil { | ||
log.Fatalf("err downloading ReDoc license file: %v", err) | ||
} | ||
|
||
defer resp1.Body.Close() | ||
|
||
if resp1.StatusCode < 200 || resp1.StatusCode > 299 { | ||
err = fmt.Errorf("err downloading ReDoc license file: %+v\n", resp1) | ||
log.Fatal(err) | ||
} | ||
|
||
if _, err = io.Copy(licenseFile, resp1.Body); err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
err = os.Rename("server/license.tmp", "server/redoc.standalone.js.LICENSE.txt") | ||
if err != nil { | ||
log.Fatalf("Error renaming ReDoc license file: %v", err) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also write
record.standalone.js.LICENSE.txt
here.