<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Github-Pages on blog.iankulin.com</title><link>https://blog.iankulin.com/tags/github-pages/</link><description>Recent content in Github-Pages on blog.iankulin.com</description><generator>Hugo</generator><language>en-AU</language><lastBuildDate>Thu, 26 Jan 2023 00:00:00 +0000</lastBuildDate><atom:link href="https://blog.iankulin.com/tags/github-pages/index.xml" rel="self" type="application/rss+xml"/><item><title>Openlayers &amp; Vite</title><link>https://blog.iankulin.com/openlayers-vite/</link><pubDate>Thu, 26 Jan 2023 00:00:00 +0000</pubDate><guid>https://blog.iankulin.com/openlayers-vite/</guid><description>&lt;p&gt;In Randy Pausch&amp;rsquo;s &lt;a href="https://www.youtube.com/watch?v=ji5_MqicxSo"&gt;last lecture&lt;/a&gt; he talks about the benefit of brick walls in our lives - they tell us how much we really want something. Software development is full of these brick walls - things we want to do, but there&amp;rsquo;s a barrier to achieving it. Will we persevere and accomplish the thing, give up, or some other compromise.&lt;/p&gt;
&lt;p&gt;In heroic tales, the protagonist overcomes all obstacles to achieve the goal. In life and especially in software development, that&amp;rsquo;s not always the smart thing to do - to stubbornly invest in an outcome, often disproportionately to the benefit. Here&amp;rsquo;s my brick walls from today.&lt;/p&gt;
&lt;p&gt;I had made a web page showing text of the updated lat/long of the ISS. It met the requirements, but was not very exciting. The obvious thing to do with this information would be to show it on a map.&lt;/p&gt;
&lt;h4 id="moving-map"&gt;Moving map&lt;/h4&gt;
&lt;p&gt;Obviously there are lots of options for this, none of them were as simple as I would have liked, and I wanted a free one. &lt;a href="https://openlayers.org/"&gt;OpenLayers&lt;/a&gt; sounded like it would do the job, and the download to showing a map in the demo app time was about five minutes - we&amp;rsquo;re off to a good start.&lt;/p&gt;
&lt;h4 id="wall-1---complicated-library"&gt;Wall 1 - complicated library&lt;/h4&gt;
&lt;p&gt;I&amp;rsquo;m not joking when I say OpenLayers is comprehensive. It appears to do everything you could possibly want. The flipside of this is complexity. I managed to get the map scrolling so the ISS position was the centre of the map, and discovered how to add a dot as a feature to represent the ISS, but then when I wanted to get that dot to move I was increasingly out of my depth.&lt;/p&gt;
&lt;p&gt;Of course, there&amp;rsquo;s nothing magical here - it&amp;rsquo;s a gigantic, well documented API, and there&amp;rsquo;s a smattering on answers on StackOverflow. I&amp;rsquo;m smart enough to get my head around it, find some repos using it and dissect them and so on. The question is one of cost/benefit. I&amp;rsquo;m essentially building a toy for my own amusement - would the time be better spent on moving on to the next part of my course?&lt;/p&gt;
&lt;h4 id="wall-2---overlapping-images"&gt;Wall 2 - overlapping images&lt;/h4&gt;
&lt;p&gt;I have a better idea anyway - since the ISS should be at the centre of the map, I can just stick a picture of the ISS there. I assume this is possible with CSS?&lt;/p&gt;
&lt;p&gt;This turns out to be a low wall. The CSS for my image is:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#d8dee9;background-color:#2e3440;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;img {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; position: absolute;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; top: 50%;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; left: 50%;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The container (that holds the map and this image of the ISS) has &lt;code&gt;position:relative&lt;/code&gt; this all works on the first try, and my ISS png is positioned perfectly in the centre of the map at it&amp;rsquo;s correct location, and it changes correctly as the window is resized.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://blog.iankulin.com/images/screen-shot-2023-01-17-at-6.25.04-pm.jpg" alt=""&gt;&lt;/p&gt;
&lt;h4 id="wall-3---vite"&gt;Wall 3 - Vite&lt;/h4&gt;
&lt;p&gt;The process of creating the demo app from the Getting Started instructions for OpenLayers involves something called &lt;a href="https://vitejs.dev/"&gt;Vite&lt;/a&gt;. Apparently it&amp;rsquo;s a &amp;ldquo;Next Gen Frontend Tooling&amp;rdquo; which does not really tell me much. I&amp;rsquo;ve heard it mentioned in passing a couple of times, and know it&amp;rsquo;s pronounced veet. A bit like when I was using React, there&amp;rsquo;s a node build step that fills a directory with the distributed files - I&amp;rsquo;m guessing this is something to do with pulling in just the parts of the giant library I&amp;rsquo;m using - but there&amp;rsquo;s 260K of JavaScript and a 1.6MB .map in there, so I feel some handcrafting or a CDN should be involved.&lt;/p&gt;
&lt;p&gt;If the .map file is in fact the map, that&amp;rsquo;s actually pretty amazing for a map of the entire world that I can zoom down to individual street level - so it&amp;rsquo;s probably not, but either way it&amp;rsquo;s massive overkill for what this application needs. All I really need for this is a 1000x500 px image of a map of the world. Still here we are.&lt;/p&gt;
&lt;p&gt;So I don&amp;rsquo;t really understand Vite, but I can follow the instructions enough to get the live server running for development, and to build the distribution files.&lt;/p&gt;
&lt;h4 id="wall-4---github-pages"&gt;Wall 4 - GitHub Pages&lt;/h4&gt;
&lt;p&gt;I love GitHub pages, and have a couple of apps up on it &lt;a href="https://iankulin.github.io/calc/"&gt;here&lt;/a&gt; and &lt;a href="https://iankulin.github.io/todo001/"&gt;here&lt;/a&gt;. It works by specifying a branch (which can include main) in the repo to expose, or by starting a repo with your GitHub username - for example, mine would be &lt;a href="https://iankulin.github.io/"&gt;iankulin.github.io&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I had my original (non-map) version of the iss location working on Pages as a subdirectory of the main iankulin page. For the map version, I publish it directly from the docs directory of the main branch of it&amp;rsquo;s own repo. About this time, I realised that my original version was mysteriously not working. I would have been okay with that, but neither was the new version, which as usual &amp;lsquo;wOrKEd On mY mAChiNe&amp;rsquo;.&lt;/p&gt;
&lt;p&gt;I can see now what the problem was with my original version. I had copied the source files of the non-map version to the /iss folder of my main github.io page, so it&amp;rsquo;s address had been &lt;a href="https://iankulin.github.io/iss/"&gt;https://iankulin.github.io/iss/&lt;/a&gt;. Meanwhile, I&amp;rsquo;d named the new map-version repo &amp;lsquo;iss&amp;rsquo; and published it from that repo - so its link was, you guessed it &lt;a href="https://iankulin.github.io/iss/"&gt;https://iankulin.github.io/iss/&lt;/a&gt; After a bit of shuffling around, the old one is now working correctly at &lt;a href="https://iankulin.github.io/cwd/iss/"&gt;https://iankulin.github.io/cwd/iss/&lt;/a&gt;&lt;/p&gt;
&lt;h4 id="wall-5---vite-again"&gt;Wall 5 - Vite again?&lt;/h4&gt;
&lt;p&gt;Meanwhile, the new version, with the moving map was clearly loading the HTML, but no sign of the ISS image, the .css or .js&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;m in unfamiliar territory here with Vite, but since I started with the bundled my-app app, I&amp;rsquo;m sort of expecting everything to just work, unless it&amp;rsquo;s something to do this the GitHub Pages hosting. I do go down a rabbit hole about how they are designed for Jekyll. But a simpler explanation might be the links to those resources in the HTML. They all had a forward slash in front of them, like&lt;/p&gt;
&lt;p&gt;&lt;code&gt;/assets/iss.d6272ccf.png&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;where as I would have been expecting&lt;/p&gt;
&lt;p&gt;&lt;code&gt;assets/iss.d6272ccf.png&lt;/code&gt; or even &lt;code&gt;./assets/iss.d6272ccf.png&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;(a side note - I have no idea why *ix systems use &lt;code&gt;./&lt;/code&gt; to mean the current directory. It would be like prefixing everyone&amp;rsquo;s name with &lt;em&gt;parent&amp;rsquo;s child&lt;/em&gt; when you&amp;rsquo;re talking to them).&lt;/p&gt;
&lt;img src="https://blog.iankulin.com/images/soanyway.jpg" width="74" alt=""&gt;
&lt;p&gt;So anyway, I just started manually editing the built code which doesn&amp;rsquo;t seem like great practice:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://blog.iankulin.com/images/screen-shot-2023-01-18-at-10.16.35-am.png" alt=""&gt;&lt;/p&gt;
&lt;p&gt;It didn&amp;rsquo;t immediately solve my problem, but I&amp;rsquo;m not sure what the update rate for Pages is, and when I looked the next morning, it was working.&lt;/p&gt;
&lt;h4 id="wall-6---the-last-90"&gt;Wall 6 - The last 90%&lt;/h4&gt;
&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Ninety%E2%80%93ninety_rule"&gt;Tom Cargill&lt;/a&gt; (Bell Labs in the 80&amp;rsquo;s) is credited with noticing that the first 90% of the code accounts for the first 90% of the development time and the remaining 10% accounts for the remaining 90%. It certainly feels right that solving the problems and getting the MVP/prototype up and working - aka the fun bit, is not even the half way point in a project.&lt;/p&gt;
&lt;p&gt;Even in this very simple app, with the shortcuts I&amp;rsquo;ve made, there&amp;rsquo;s still significant work to do:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;I need to disable the user&amp;rsquo;s ability to scroll around the map - since it breaks the illusion that the ISS picture is map of the map (or correctly render it as a map layer).&lt;/li&gt;
&lt;li&gt;There needs to be a delay or something so the first render of the map is based on a fetched ISS position.&lt;/li&gt;
&lt;li&gt;It ISS picture is not quite in the centre - it&amp;rsquo;s not noticeable on a laptop, but on mobile it&amp;rsquo;s very evident.&lt;/li&gt;
&lt;li&gt;Actually, the whole mobile experience needs a bit of work. That lat/long display does not fit as written. Better to pop the elements into a grid so we can stack them when the screen gets narrow.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Will I do these things? Is the trip worth the gas? I need to balance progressing in the course with the things I can learn by finishing everything off carefully. In this case, since I&amp;rsquo;m way, way past what the course exercise was, I&amp;rsquo;ll leave it as is. Eventually I&amp;rsquo;ll work back through my GitHub with a recruiter&amp;rsquo;s eye, and things like this will need fixed to production standards or made private.&lt;/p&gt;</description></item></channel></rss>