mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-20 11:45:50 +00:00
First draft code samples page
This commit is contained in:
59
assets/img/logos/cli.svg
Normal file
59
assets/img/logos/cli.svg
Normal file
@@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="144.77597"
|
||||
height="113.576"
|
||||
viewBox="0 0 38.305308 30.050315"
|
||||
version="1.1"
|
||||
id="svg832"
|
||||
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
|
||||
sodipodi:docname="cli.svg"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<sodipodi:namedview
|
||||
id="namedview834"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:document-units="mm"
|
||||
showgrid="false"
|
||||
fit-margin-top="20"
|
||||
fit-margin-left="20"
|
||||
fit-margin-right="20"
|
||||
fit-margin-bottom="20"
|
||||
units="px"
|
||||
inkscape:zoom="0.5"
|
||||
inkscape:cx="279"
|
||||
inkscape:cy="26"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1047"
|
||||
inkscape:window-x="3000"
|
||||
inkscape:window-y="840"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="layer1" />
|
||||
<defs
|
||||
id="defs829" />
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(-31.491723,-141.29313)">
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:25.4px;line-height:0;font-family:'Source Han Sans';-inkscape-font-specification:'Source Han Sans';letter-spacing:0px;word-spacing:0px;fill:none;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
x="35.950481"
|
||||
y="162.18568"
|
||||
id="text3799"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3797"
|
||||
style="font-style:normal;font-variant:normal;font-weight:600;font-stretch:normal;font-size:25.4px;font-family:'Source Han Sans';-inkscape-font-specification:'Source Han Sans Semi-Bold';fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583px"
|
||||
x="35.950481"
|
||||
y="162.18568">>_</tspan></text>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
55
assets/img/logos/golang.svg
Normal file
55
assets/img/logos/golang.svg
Normal file
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 24.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 205.4 76.7" style="enable-background:new 0 0 205.4 76.7;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:#00ACD7;}
|
||||
</style>
|
||||
<g>
|
||||
<g>
|
||||
<g>
|
||||
<g>
|
||||
<path class="st0" d="M15.5,23.2c-0.4,0-0.5-0.2-0.3-0.5l2.1-2.7c0.2-0.3,0.7-0.5,1.1-0.5h35.7c0.4,0,0.5,0.3,0.3,0.6l-1.7,2.6
|
||||
c-0.2,0.3-0.7,0.6-1,0.6L15.5,23.2z"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g>
|
||||
<g>
|
||||
<g>
|
||||
<path class="st0" d="M0.4,32.4c-0.4,0-0.5-0.2-0.3-0.5l2.1-2.7c0.2-0.3,0.7-0.5,1.1-0.5h45.6c0.4,0,0.6,0.3,0.5,0.6l-0.8,2.4
|
||||
c-0.1,0.4-0.5,0.6-0.9,0.6L0.4,32.4z"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g>
|
||||
<g>
|
||||
<g>
|
||||
<path class="st0" d="M24.6,41.6c-0.4,0-0.5-0.3-0.3-0.6l1.4-2.5c0.2-0.3,0.6-0.6,1-0.6h20c0.4,0,0.6,0.3,0.6,0.7L47.1,41
|
||||
c0,0.4-0.4,0.7-0.7,0.7L24.6,41.6z"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<g>
|
||||
<g id="CXHf1q_3_">
|
||||
<g>
|
||||
<g>
|
||||
<path class="st0" d="M128.4,21.4c-6.3,1.6-10.6,2.8-16.8,4.4c-1.5,0.4-1.6,0.5-2.9-1c-1.5-1.7-2.6-2.8-4.7-3.8
|
||||
c-6.3-3.1-12.4-2.2-18.1,1.5c-6.8,4.4-10.3,10.9-10.2,19c0.1,8,5.6,14.6,13.5,15.7c6.8,0.9,12.5-1.5,17-6.6
|
||||
c0.9-1.1,1.7-2.3,2.7-3.7c-3.6,0-8.1,0-19.3,0c-2.1,0-2.6-1.3-1.9-3c1.3-3.1,3.7-8.3,5.1-10.9c0.3-0.6,1-1.6,2.5-1.6
|
||||
c5.1,0,23.9,0,36.4,0c-0.2,2.7-0.2,5.4-0.6,8.1c-1.1,7.2-3.8,13.8-8.2,19.6c-7.2,9.5-16.6,15.4-28.5,17
|
||||
c-9.8,1.3-18.9-0.6-26.9-6.6c-7.4-5.6-11.6-13-12.7-22.2c-1.3-10.9,1.9-20.7,8.5-29.3c7.1-9.3,16.5-15.2,28-17.3
|
||||
c9.4-1.7,18.4-0.6,26.5,4.9c5.3,3.5,9.1,8.3,11.6,14.1C130,20.6,129.6,21.1,128.4,21.4z"/>
|
||||
</g>
|
||||
<g>
|
||||
<path class="st0" d="M161.5,76.7c-9.1-0.2-17.4-2.8-24.4-8.8c-5.9-5.1-9.6-11.6-10.8-19.3c-1.8-11.3,1.3-21.3,8.1-30.2
|
||||
c7.3-9.6,16.1-14.6,28-16.7c10.2-1.8,19.8-0.8,28.5,5.1c7.9,5.4,12.8,12.7,14.1,22.3c1.7,13.5-2.2,24.5-11.5,33.9
|
||||
c-6.6,6.7-14.7,10.9-24,12.8C166.8,76.3,164.1,76.4,161.5,76.7z M185.3,36.3c-0.1-1.3-0.1-2.3-0.3-3.3
|
||||
c-1.8-9.9-10.9-15.5-20.4-13.3c-9.3,2.1-15.3,8-17.5,17.4c-1.8,7.8,2,15.7,9.2,18.9c5.5,2.4,11,2.1,16.3-0.6
|
||||
C180.5,51.3,184.8,44.9,185.3,36.3z"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
@@ -3923,7 +3923,22 @@ pages:
|
||||
targets:
|
||||
- ja
|
||||
|
||||
# Code Samples page (final location TBD)
|
||||
- name: Code Samples
|
||||
html: code-samples.html
|
||||
parent: docs.html
|
||||
template: page-code-samples.html.jinja
|
||||
sidebar: left_only
|
||||
filters:
|
||||
- code_samples
|
||||
top_nav_grouping: Online Tools
|
||||
blurb: Browse sample code for building common use cases on the XRP Ledger.
|
||||
targets:
|
||||
- en
|
||||
- ja
|
||||
|
||||
# Dev Tools --------------------------------------------------------------------
|
||||
|
||||
- md: dev-tools/dev-tools.md
|
||||
html: dev-tools.html
|
||||
parent: docs.html
|
||||
|
||||
77
template/page-code-samples.html.jinja
Normal file
77
template/page-code-samples.html.jinja
Normal file
@@ -0,0 +1,77 @@
|
||||
{% extends "base.html.jinja" %}
|
||||
|
||||
{% block bodyclasses %}no-sidebar{% endblock %}
|
||||
{% block mainclasses %}landing page-community{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
|
||||
<section class="py-26 text-center">
|
||||
<div class="col-lg-8 mx-auto text-center">
|
||||
<div class="d-flex flex-column-reverse">
|
||||
<h1 class="mb-0">{% trans %}Solutions to Accelerate Development{% endtrans %}</h1>
|
||||
<h6 class="eyebrow mb-3">{% trans %}Code Samples{% endtrans %}</h6>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="container-new py-26">
|
||||
<div class="d-flex flex-column-reverse col-sm-8 p-0">
|
||||
<h3 class="h4 h2-sm">{% trans %}Browse sample code for building common use cases on the XRP Ledger{% endtrans %}</h3>
|
||||
<h6 class="eyebrow mb-3">{% trans %}Explore Code Samples{% endtrans %}</h6>
|
||||
</div>
|
||||
<div class="row row-cols-1 row-cols-lg-3 card-deck mt-10" id="code-samples-deck">
|
||||
{# {% set code_samples = [
|
||||
{ "href": "https://github.com/XRPLF/xrpl-dev-portal/tree/master/content/_code-samples/checks",
|
||||
"title": _("Checks Tutorials"),
|
||||
"langs": [
|
||||
"js",
|
||||
"json-rpc",
|
||||
"websocket",
|
||||
"cli"
|
||||
],
|
||||
"description": _("Create, cash, and cancel Checks for exact or flexible amounts.")
|
||||
},
|
||||
] %} #}
|
||||
{% set code_samples = all_code_samples() %}
|
||||
|
||||
{% set lang_icons = {
|
||||
"cli": "assets/img/logos/cli.svg",
|
||||
"go": "assets/img/logos/golang.svg",
|
||||
"java": "assets/img/logos/java.svg",
|
||||
"js": "assets/img/logos/javascript.svg",
|
||||
"json-rpc": "assets/img/logos/globe.svg",
|
||||
"py": "assets/img/logos/python.svg",
|
||||
"websocket": "assets/img/logos/globe.svg",
|
||||
} %}
|
||||
|
||||
{% for card in code_samples %}
|
||||
<a class="card" href="{{target.prefix}}{{card.href}}">
|
||||
<div class="card-header">
|
||||
{% for lang in card.langs %}
|
||||
<span class="circled-logo"><img src="{{lang_icons[lang]}}" /></span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h4 class="card-title h5">{{card.title}}</h4>
|
||||
<p class="card-text">{{card.description}}</p>
|
||||
</div>
|
||||
<div class="card-footer"> </div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
||||
{% block analytics %}
|
||||
<script type="application/javascript">
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
window.dataLayer.push({
|
||||
"event": "page_info",
|
||||
"page_type": "Hub Page",
|
||||
"page_group": "Code Samples"
|
||||
})
|
||||
</script>
|
||||
{% endblock analytics %}
|
||||
52
tool/filter_code_samples.py
Normal file
52
tool/filter_code_samples.py
Normal file
@@ -0,0 +1,52 @@
|
||||
################################################################################
|
||||
## Code Sample Functions ##
|
||||
## Author: Rome Reginelli ##
|
||||
## Copyright: Ripple Labs, Inc. 2021 ##
|
||||
## License: MIT https://github.com/XRPLF/xrpl-dev-portal/blob/master/LICENSE ##
|
||||
## ##
|
||||
## Find code samples in the repository contents and figure out metadata about ##
|
||||
## them automatically. ##
|
||||
################################################################################
|
||||
|
||||
import os
|
||||
from markdown import markdown
|
||||
|
||||
cs_dir = "content/_code-samples/" #TODO: make a configurable field
|
||||
skip_dirs = [
|
||||
"node_modules",
|
||||
".git",
|
||||
"__pycache__"
|
||||
]
|
||||
|
||||
def all_code_samples():
|
||||
cses = []
|
||||
|
||||
for dirpath, dirnames, filenames in os.walk(cs_dir):
|
||||
if dirpath == cs_dir:
|
||||
continue
|
||||
# limit depth to just the code samples and language folders
|
||||
depth = dirpath.count(os.sep) - cs_dir.count(os.sep) + 1
|
||||
if depth > 1:
|
||||
continue
|
||||
for sd in skip_dirs:
|
||||
if sd in dirnames:
|
||||
dirnames.remove(sd)
|
||||
|
||||
cs = {
|
||||
"path": dirpath,
|
||||
"langs": dirnames,
|
||||
}
|
||||
|
||||
if "README.md" in filenames:
|
||||
with open(os.path.join(dirpath, "README.md"), "r") as f:
|
||||
md = f.read()
|
||||
cs["description"] = markdown(md)
|
||||
else:
|
||||
cs["description"] = os.path.basename(dirpath)
|
||||
cses.append(cs)
|
||||
|
||||
return cses
|
||||
|
||||
export = {
|
||||
"all_code_samples": all_code_samples,
|
||||
}
|
||||
Reference in New Issue
Block a user