diff --git a/README.md b/README.md index f119ce20..fedf8332 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ List of available parameters: ## Contributing -### Testing you Code +### Testing Your Code Before pushing your code you should verify that it will pass our online test suite. diff --git a/packages/webapp/src/components/CodeExamples/Code.js b/packages/webapp/src/components/CodeExamples/Code.js index 695a4634..9c5d01c2 100644 --- a/packages/webapp/src/components/CodeExamples/Code.js +++ b/packages/webapp/src/components/CodeExamples/Code.js @@ -1,3 +1,30 @@ +export const curl = `# upload +curl -X POST "https://siasky.net/skynet/skyfile" -F file=@src.jpg + +# download +curl "https://siasky.net/[skylink]" -o dst.jpg`; + +export const browserjs = `import { SkynetClient } from "skynet-js"; + +// create a client +const client = new SkynetClient(); + +// Assume we have a file from an input form. + +async function example() { + try { + // upload + const { skylink } = await client.uploadFile(file); + console.log(\`Upload successful, skylink: \${skylink}\`); + + // download + await client.downloadFile(skylink); + console.log('Download successful'); + } catch (error) { + console.log(error) + } +}`; + export const python = `import siaskynet as skynet # create a client @@ -11,12 +38,6 @@ print("Upload successful, skylink: " + skylink) client.download_file("./dst.jpg", skylink) print("Download successful")`; -export const curl = `# upload -curl -X POST "https://siasky.net/skynet/skyfile" -F file=@src.jpg - -# download -curl "https://siasky.net/[skylink]" -o dst.jpg`; - export const node = `const { SkynetClient } = require('@nebulous/skynet'); // create a client @@ -39,6 +60,7 @@ import ( skynet "github.com/NebulousLabs/go-skynet" ) +// create a client var client = skynet.New() func main() { @@ -56,7 +78,3 @@ func main() { } fmt.Println("Download successful") }`; - -export const ruby = ``; - -export const php = ``; diff --git a/packages/webapp/src/components/CodeExamples/CodeExamples.js b/packages/webapp/src/components/CodeExamples/CodeExamples.js index 75c58df6..65753ba9 100644 --- a/packages/webapp/src/components/CodeExamples/CodeExamples.js +++ b/packages/webapp/src/components/CodeExamples/CodeExamples.js @@ -25,12 +25,15 @@ export default function CodeExamples() { CURL + @@ -43,18 +46,24 @@ export default function CodeExamples() { )} {active === 2 && ( + + {interpolateSnippet(snippets.browserjs)} + + )} + + {active === 3 && ( {interpolateSnippet(snippets.python)} )} - {active === 3 && ( + {active === 4 && ( {interpolateSnippet(snippets.node)} )} - {active === 4 && ( + {active === 5 && ( {interpolateSnippet(snippets.go)}