{"id":638,"date":"2022-12-09T18:21:28","date_gmt":"2022-12-09T23:21:28","guid":{"rendered":"http:\/\/www.area46.com\/mjc\/?page_id=638"},"modified":"2022-12-12T12:56:05","modified_gmt":"2022-12-12T17:56:05","slug":"technical-writing","status":"publish","type":"page","link":"http:\/\/www.area46.com\/mjc\/technical-writing\/","title":{"rendered":"TECHNICAL Writing"},"content":{"rendered":"\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/miro.medium.com\/max\/1400\/1*Uo3aeNnFyexIsCs6wjJ_nw.png\" alt=\"\"\/><\/figure>\n\n\n\n<p id=\"28e9\">Hosting slate documentation on IPFS was a little different than simply adding static files. For the purpose of this tutorial, we\u2019ll use our slate documentation&nbsp;repository&nbsp;as the code-base we reference.<\/p>\n\n\n\n<p id=\"1136\">The other part to this was some issues we had loading images through CSS, and fonts. For CSS, we found the easiest solution was to reference versions of the images that were hosted on IPFS, linked through our gateway like so:<\/p>\n\n\n\n<p id=\"3642\">One of the main issues we found was that a lot of our files were referencing absolute paths\u00a0<code>\/index.html\u00a0<\/code>.The problem with this was that when viewing the documentation through our\u00a0gateway\u00a0navigating to those links would end up redirecting us to\u00a0https:\/\/gateway.temporal.cloud\/index.html\u00a0which wouldn\u2019t work for any IPFS gateway, but for ours these would trigger ACLs redirecting the user to google. The simplest fix was to alter some paths to relative links. However with the desire to not go through and edit a ton of source files, we were able to script this using simple\u00a0<code>find<\/code> and\u00a0<code>sed<\/code> statements.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">background-image: url('https:\/\/gateway.temporal.cloud\/ipfs\/QmQ8DTkjxE7emKkfbKxYcaaAeAiiXcSNk7kGhKdstgfAwY');<\/pre>\n\n\n\n<p id=\"19b8\">Fonts were something we had some initial trouble tackling. Due to the source code which gets imported through css imports, we would end up with code that looked like:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">@font-face{font-family:\"LLAkkuratWeb-Bold\";src:url(\"fonts\/lineto-akkurat-bold-s-da650f3e5d121ff3584d6d7df703def6.eot\");src:url(\"fonts\/lineto-akkurat-bold-s.eot#iefix\"<\/pre>\n\n\n\n<p id=\"fd7b\">When browsing through our gateway, we would get 404\u2019s for these fonts. When adding the file to IPFS, although the fonts were in a separate folder, IPFS would attempt to load\u00a0<code>fonts\u00a0<\/code>as if they were under our\u00a0<code>style sheets<\/code> folder. The trick to this was changing all\u00a0<code>fonts\/<\/code>to\u00a0<code>...fonts\/\u00a0<\/code>. This is something we were again able to fix using simple\u00a0<code>find\u00a0<\/code>and\u00a0<code>sed\u00a0<\/code>statements.<\/p>\n\n\n\n<p id=\"da75\">When adding the files to IPFS, in order to ensure that all relative links are properly parsed, you\u2019ll want to&nbsp;<code>cd&nbsp;<\/code>into the&nbsp;<code>build&nbsp;<\/code>directory that is created when running&nbsp;<code>bundle exec middleman build --clean&nbsp;<\/code>, and add files recursively, wrapping them in a directory object like so:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#! \/bin\/bash# used to prep slate build's for hosting on ipfs <br># example <br># .\/slate_ipfs.sh bilbobaggins 192.168.0.1 \/home\/solidity\/go\/src\/github.com\/RTradeLtd\/temporal-api-documentation <br># after uploading, you'll want to untar the file, and add it with `ipfs add -r -w &lt;directory&gt;`REMOTE_USER=\"$1\" <br>REMOTE_HOST=\"$2\" <br>SLATE_REPO=\"$3\"if [[ \"$REMOTE_HOST\" == \"\" ]]; then  <br>        echo \"first argument must be remote host to upload files to\"  <br>        exit 1 <br>fiif [[ \"$REMOTE_USER\" == \"\" ]]; then  <br>        echo \"second argument must be remote user of the remote host\"  <br>        exit 1 <br>fiif [[ \"$SLATE_REPO\" == \"\" ]]; then     <br>   echo \"third argument must be the absolute path to the slate repository\" <br>   exit 1 <br>fi# change directory to slate repository <br>cd \"$SLATE_REPO\" || exit <br># clean up old files <br>rm -rf build build.tar# used to build slate to serve as static files <br>bundle exec middleman build --clean# change to build directory, exiting if a failure is detected <br>cd build || exit# updates hrefs to work with ipfs and not redirect to an actual web url <br># for example if using non-prepped slate static files with an href like <br># href=\"\/account.html\" on a domain gateway.temporal.cloud, this will redirect # to gateway.temporal.cloud\/account.html <br># by trimming the leading \/ it will be redirected to the ipfs link instead find . -type f -name \"*.html\" -exec sed -i 's\/href=\"\\\/\/href=\"\/g' {} \\; <br># do the same as the above for css files <br>find . -type f -name \"*.css\" -exec sed -i 's\/url(\"\\\/\/url(\"\/g' {} \\; <br># do the same for content links <br>find . -type f -name \"*.html\" -exec sed -i 's\/content=\"\\\/\/content=\"\/g' {} \\; <br># do the same for css fonts <br>find . -type f -name \"*.css\" -exec sed -i 's\/url(\"fonts\/url(\"..\\\/fonts\/g' {} \\;# change back to parent directory <br>cd .. || exit# tarball the file <br>tar cvf build.tar build# upload tarballed file to remote host <br>scp build.tar \"$REMOTE_USER\"@\"$REMOTE_HOST\":~\/<\/pre>\n\n\n\n<p id=\"26af\">What can be improved?<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The main area we see for improvement would be a better way of embedding the images, so that they aren\u2019t also requested over a gateway.<\/li>\n\n\n\n<li>The last part we see room for improvement, would be an ansible playbook that is called after the shell script which logs onto the target IPFS server, and then untars the directory, followed by adding it to IPFS.<\/li>\n<\/ul>\n\n\n\n<p id=\"c08e\">We hope this has helped make things a little easier ! Please feel to check out our speedy gateway !&nbsp;<code>https:\/\/gateway.temporal.cloud\/ipfs<\/code>&nbsp;or&nbsp;<code>https:\/\/gateway.temporal.cloud\/ipns<\/code> <\/p>\n\n\n\n<p><a href=\"https:\/\/medium.com\/m\/signin?actionUrl=https%3A%2F%2Fmedium.com%2F_%2Fvote%2Ftemporal-cloud%2F9bc54272ca18&amp;operation=register&amp;redirect=https%3A%2F%2Fmedium.com%2Ftemporal-cloud%2Ftutorial-hosting-slate-documentation-on-ipfs-9bc54272ca18&amp;user=RTrade+Technologies%2C+Ltd.&amp;userId=36f641e4dfc2&amp;source=-----9bc54272ca18---------------------clap_footer-----------\"><\/a><a href=\"https:\/\/medium.com\/m\/signin?actionUrl=https%3A%2F%2Fmedium.com%2F_%2Fvote%2Ftemporal-cloud%2F9bc54272ca18&amp;operation=register&amp;redirect=https%3A%2F%2Fmedium.com%2Ftemporal-cloud%2Ftutorial-hosting-slate-documentation-on-ipfs-9bc54272ca18&amp;user=RTrade+Technologies%2C+Ltd.&amp;userId=36f641e4dfc2&amp;source=-----9bc54272ca18---------------------clap_footer-----------\"><\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/medium.com\/m\/signin?actionUrl=https%3A%2F%2Fmedium.com%2F_%2Fvote%2Ftemporal-cloud%2F9bc54272ca18&amp;operation=register&amp;redirect=https%3A%2F%2Fmedium.com%2Ftemporal-cloud%2Ftutorial-hosting-slate-documentation-on-ipfs-9bc54272ca18&amp;user=RTrade+Technologies%2C+Ltd.&amp;userId=36f641e4dfc2&amp;source=-----9bc54272ca18---------------------clap_footer-----------\"><\/a><a href=\"https:\/\/medium.com\/m\/signin?actionUrl=https%3A%2F%2Fmedium.com%2F_%2Fvote%2Ftemporal-cloud%2F9bc54272ca18&amp;operation=register&amp;redirect=https%3A%2F%2Fmedium.com%2Ftemporal-cloud%2Ftutorial-hosting-slate-documentation-on-ipfs-9bc54272ca18&amp;user=RTrade+Technologies%2C+Ltd.&amp;userId=36f641e4dfc2&amp;source=-----9bc54272ca18---------------------clap_footer-----------\"><\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/medium.com\/m\/signin?actionUrl=https%3A%2F%2Fmedium.com%2F_%2Fbookmark%2Fp%2F9bc54272ca18&amp;operation=register&amp;redirect=https%3A%2F%2Fmedium.com%2Ftemporal-cloud%2Ftutorial-hosting-slate-documentation-on-ipfs-9bc54272ca18&amp;source=--------------------------bookmark_footer-----------\"><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hosting slate documentation on IPFS was a little different than simply adding static files. For the purpose of this tutorial, we\u2019ll use our slate documentation&nbsp;repository&nbsp;as the code-base we reference. The other part to this was some issues we had loading images through CSS, and fonts. For CSS, we found the easiest solution was to reference [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-638","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.area46.com\/mjc\/wp-json\/wp\/v2\/pages\/638","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.area46.com\/mjc\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.area46.com\/mjc\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.area46.com\/mjc\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.area46.com\/mjc\/wp-json\/wp\/v2\/comments?post=638"}],"version-history":[{"count":3,"href":"http:\/\/www.area46.com\/mjc\/wp-json\/wp\/v2\/pages\/638\/revisions"}],"predecessor-version":[{"id":704,"href":"http:\/\/www.area46.com\/mjc\/wp-json\/wp\/v2\/pages\/638\/revisions\/704"}],"wp:attachment":[{"href":"http:\/\/www.area46.com\/mjc\/wp-json\/wp\/v2\/media?parent=638"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}