Updated docs routing
This commit is contained in:
+39
-19
@@ -3921,6 +3921,14 @@ func setBadMemcache(ctx context.Context, path string) {
|
|||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Result struct {
|
||||||
|
Success bool `json:"success"`
|
||||||
|
Reason string `json:"reason"`
|
||||||
|
List []string `json:"list"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var docs_list = Result{List: []string{}}
|
||||||
|
|
||||||
func getDocList(resp http.ResponseWriter, request *http.Request) {
|
func getDocList(resp http.ResponseWriter, request *http.Request) {
|
||||||
cors := handleCors(resp, request)
|
cors := handleCors(resp, request)
|
||||||
if cors {
|
if cors {
|
||||||
@@ -3939,11 +3947,24 @@ func getDocList(resp http.ResponseWriter, request *http.Request) {
|
|||||||
// return
|
// return
|
||||||
//}
|
//}
|
||||||
|
|
||||||
client := github.NewClient(nil)
|
if len(docs_list.List) > 0 {
|
||||||
_, item1, _, err := client.Repositories.GetContents(ctx, "shaffuru", "shuffle-docs", "docs", nil)
|
b, err := json.Marshal(docs_list)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Printf("Failed marshaling result: %s", err)
|
||||||
|
//http.Error(resp, err.Error(), 500)
|
||||||
|
} else {
|
||||||
|
resp.WriteHeader(200)
|
||||||
|
resp.Write(b)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
client := github.NewClient(nil)
|
||||||
|
_, item1, _, err := client.Repositories.GetContents(ctx, "frikky", "shuffle-docs", "docs", nil)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Github error: %s", err)
|
||||||
resp.WriteHeader(500)
|
resp.WriteHeader(500)
|
||||||
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Error listing directory"`)))
|
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "Error listing directory: %s"`, err)))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3964,16 +3985,12 @@ func getDocList(resp http.ResponseWriter, request *http.Request) {
|
|||||||
|
|
||||||
log.Println(names)
|
log.Println(names)
|
||||||
|
|
||||||
type Result struct {
|
|
||||||
Success bool `json:"success"`
|
|
||||||
Reason string `json:"reason"`
|
|
||||||
List []string `json:"list"`
|
|
||||||
}
|
|
||||||
|
|
||||||
var result Result
|
var result Result
|
||||||
result.Success = true
|
result.Success = true
|
||||||
result.Reason = "Success"
|
result.Reason = "Success"
|
||||||
result.List = names
|
result.List = names
|
||||||
|
docs_list = result
|
||||||
|
|
||||||
b, err := json.Marshal(result)
|
b, err := json.Marshal(result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(resp, err.Error(), 500)
|
http.Error(resp, err.Error(), 500)
|
||||||
@@ -4001,6 +4018,8 @@ func getDocList(resp http.ResponseWriter, request *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// r.HandleFunc("/api/v1/docs/{key}", getDocs).Methods("GET", "OPTIONS")
|
// r.HandleFunc("/api/v1/docs/{key}", getDocs).Methods("GET", "OPTIONS")
|
||||||
|
var alldocs = map[string][]byte{}
|
||||||
|
|
||||||
func getDocs(resp http.ResponseWriter, request *http.Request) {
|
func getDocs(resp http.ResponseWriter, request *http.Request) {
|
||||||
cors := handleCors(resp, request)
|
cors := handleCors(resp, request)
|
||||||
if cors {
|
if cors {
|
||||||
@@ -4016,16 +4035,15 @@ func getDocs(resp http.ResponseWriter, request *http.Request) {
|
|||||||
|
|
||||||
//ctx := context.Background()
|
//ctx := context.Background()
|
||||||
docPath := fmt.Sprintf("https://raw.githubusercontent.com/shaffuru/shuffle-docs/master/docs/%s.md", location[4])
|
docPath := fmt.Sprintf("https://raw.githubusercontent.com/shaffuru/shuffle-docs/master/docs/%s.md", location[4])
|
||||||
//if item, err := memcache.Get(ctx, docPath); err == memcache.ErrCacheMiss {
|
//location[4]
|
||||||
// // Not in cache
|
//var, ok := alldocs["asd"]
|
||||||
//} else if err != nil {
|
key, ok := alldocs[fmt.Sprintf("%s", location[4])]
|
||||||
// // Error with cache
|
// Custom cache for github issues lol
|
||||||
// log.Printf("Error getting item: %v", err)
|
if ok {
|
||||||
//} else {
|
resp.WriteHeader(200)
|
||||||
// resp.WriteHeader(200)
|
resp.Write(key)
|
||||||
// resp.Write([]byte(item.Value))
|
return
|
||||||
// return
|
}
|
||||||
//}
|
|
||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
req, err := http.NewRequest(
|
req, err := http.NewRequest(
|
||||||
@@ -4078,6 +4096,8 @@ func getDocs(resp http.ResponseWriter, request *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
alldocs[location[4]] = b
|
||||||
|
|
||||||
// Add to cache if it doesn't exist
|
// Add to cache if it doesn't exist
|
||||||
//item := &memcache.Item{
|
//item := &memcache.Item{
|
||||||
// Key: docPath,
|
// Key: docPath,
|
||||||
|
|||||||
@@ -338,11 +338,11 @@ const Apps = (props) => {
|
|||||||
<div>
|
<div>
|
||||||
<Paper square style={uploadViewPaperStyle}>
|
<Paper square style={uploadViewPaperStyle}>
|
||||||
<div style={{width: "100%", margin: 25}}>
|
<div style={{width: "100%", margin: 25}}>
|
||||||
<h2>App creation</h2>
|
<h2>App Creator</h2>
|
||||||
<Link to="/docs/apps" style={{textDecoration: "none", color: "#f85a3e"}}>What are apps?</Link>
|
<a href="https://github.com/frikky/OpenAPI-security-definitions" style={{textDecoration: "none", color: "#f85a3e"}} target="_blank">Security API's</a>
|
||||||
- <a href="https://swagger.io/specification/" style={{textDecoration: "none", color: "#f85a3e"}}>OpenAPI specification</a>
|
- <a href="https://apis.guru/browse-apis/" style={{textDecoration: "none", color: "#f85a3e"}} target="_blank">OpenAPI directory</a>
|
||||||
<div/>
|
<div/>
|
||||||
Apps are how you interact with workflows, and are used to execute workflows. They are created with the app creator, using OpenAPI specification or manually in python.
|
Apps interact with eachother in workflows. They are created with the app creator, using OpenAPI specification or manually in python. Use the links above to find potential apps you're looking for using OpenAPI or make one from scratch. There's 1000+ available.
|
||||||
<div/>
|
<div/>
|
||||||
<div style={{marginTop: 20}}>
|
<div style={{marginTop: 20}}>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
+72
-5
@@ -55,6 +55,71 @@ const Docs = (props) => {
|
|||||||
fetchDocs()
|
fetchDocs()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Continue this, and find the h2 with the data in it lol
|
||||||
|
if (window.location.hash.length > 0) {
|
||||||
|
console.log("HELLO")
|
||||||
|
|
||||||
|
var parent = document.getElementById("markdown_wrapper")
|
||||||
|
if (parent !== null) {
|
||||||
|
var elements = parent.getElementsByTagName('h2')
|
||||||
|
|
||||||
|
const name = window.location.hash.slice(1, window.location.hash.lenth).toLowerCase().split("%20").join(" ")
|
||||||
|
|
||||||
|
console.log(name)
|
||||||
|
var found = false
|
||||||
|
for (var key in elements) {
|
||||||
|
const element = elements[key]
|
||||||
|
if (element.innerHTML === undefined) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fix location..
|
||||||
|
if (element.innerHTML.toLowerCase() === name) {
|
||||||
|
element.scrollIntoView({behavior: "smooth"})
|
||||||
|
found = true
|
||||||
|
//element.scrollTo({
|
||||||
|
// top: element.offsetTop-100,
|
||||||
|
// behavior: "smooth"
|
||||||
|
//})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// H#
|
||||||
|
if (!found) {
|
||||||
|
var elements = parent.getElementsByTagName('h3')
|
||||||
|
console.log(name)
|
||||||
|
var found = false
|
||||||
|
for (var key in elements) {
|
||||||
|
const element = elements[key]
|
||||||
|
if (element.innerHTML === undefined) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fix location..
|
||||||
|
if (element.innerHTML.toLowerCase() === name) {
|
||||||
|
element.scrollIntoView({behavior: "smooth"})
|
||||||
|
found = true
|
||||||
|
//element.scrollTo({
|
||||||
|
// top: element.offsetTop-100,
|
||||||
|
// behavior: "smooth"
|
||||||
|
//})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//console.log(element)
|
||||||
|
|
||||||
|
//console.log("NAME: ", name)
|
||||||
|
//console.log(document.body.innerHTML)
|
||||||
|
// parent = document.getElementById(parent);
|
||||||
|
|
||||||
|
//var descendants = parent.getElementsByTagName(tagname);
|
||||||
|
|
||||||
|
// this.scrollDiv.current.scrollIntoView({ behavior: 'smooth' });
|
||||||
|
|
||||||
|
//$(".parent").find("h2:contains('Statistics')").parent();
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const fetchDocList = () => {
|
const fetchDocList = () => {
|
||||||
@@ -101,8 +166,8 @@ const Docs = (props) => {
|
|||||||
flex: "1",
|
flex: "1",
|
||||||
}
|
}
|
||||||
|
|
||||||
function Link(props) {
|
function OuterLink(props) {
|
||||||
return <a href={props.href} style={{color: "#f85a3e", textDecoration: "none"}}>{props.children}</a>
|
return <Link to={props.href} style={{color: "#f85a3e", textDecoration: "none"}}>{props.children}</Link>
|
||||||
}
|
}
|
||||||
|
|
||||||
function Img(props) {
|
function Img(props) {
|
||||||
@@ -139,11 +204,12 @@ const Docs = (props) => {
|
|||||||
})}
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div style={markdownStyle}>
|
<div id="markdown_wrapper" style={markdownStyle}>
|
||||||
<ReactMarkdown
|
<ReactMarkdown
|
||||||
|
id="markdown_wrapper"
|
||||||
escapeHtml={false}
|
escapeHtml={false}
|
||||||
source={data}
|
source={data}
|
||||||
renderers={{link: Link, image: Img}}
|
renderers={{link: OuterLink, image: Img}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -180,9 +246,10 @@ const Docs = (props) => {
|
|||||||
</Menu>
|
</Menu>
|
||||||
<div style={markdownStyle}>
|
<div style={markdownStyle}>
|
||||||
<ReactMarkdown
|
<ReactMarkdown
|
||||||
|
id="markdown_wrapper"
|
||||||
escapeHtml={false}
|
escapeHtml={false}
|
||||||
source={data}
|
source={data}
|
||||||
renderers={{link: Link, image: Img}}
|
renderers={{link: OuterLink, image: Img}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Divider style={{marginTop: "10px", marginBottom: "10px", backgroundColor: dividerColor}}/>
|
<Divider style={{marginTop: "10px", marginBottom: "10px", backgroundColor: dividerColor}}/>
|
||||||
|
|||||||
Reference in New Issue
Block a user