Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1 месяц назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <!DOCTYPE html>
  2. <html>
  3. <meta charset="utf-8">
  4. <head>
  5. <link rel="stylesheet" href="../../style.css">
  6. </head>
  7. <body>
  8. <script data-goatcounter="https://services.opengamestudio.org:443/count" async src="//services.opengamestudio.org:443/count.js"></script>
  9. <div id="header">
  10. <div class="header2">
  11. <div class="menu">
  12. <a href="../../en/news/index.html">News</a>
  13. <a href="../../en/game/index.html">Games</a>
  14. <a href="../../en/tool/index.html">Tools</a>
  15. <a href="../../en/page/about.html">About</a>
  16. </div>
  17. <div id="lang">
  18. <a href="../../en/news/gitjs-intro.html">EN</a>
  19. <a href="../../ru/news/gitjs-intro.html">RU</a>
  20. </div>
  21. <div class="clear"></div>
  22. </div>
  23. </div>
  24. <h3 class="left_item_title">In the news...</h3>
  25. <center>
  26. <div class="news_item">
  27. <h2 class="news_item_title">
  28. <a href="gitjs-intro.html">How I create browser applications inside browsers</a>
  29. </h2>
  30. <p class="news_item_date">
  31. 2021-01-28 00:00
  32. </p>
  33. <div class="news_item_contents">
  34. <p><img src="../../images/2021_gitjs-intro_снимок.jpg" alt="GitJS" /></p>
  35. <p>In this article Michael shares his experience of creating durable applications.</p>
  36. <p>In 2013 Canonical <a href="https://techcrunch.com/2013/08/22/edge-crowdfunding-fail">tried to crowdfund Ubuntu Edge smartphone</a>.
  37. Its main feature could be the ability to use the smartphone as a full-fledged
  38. PС. Unfortunatly, the crowdfunding campaign did not accumulate enough money,
  39. so a dream of having a universal device remained to be the dream.</p>
  40. <p>I've been searching for universality, too, on the software side,
  41. not the hardware one. Today I can confidently say I found the necessary
  42. combination: Git and JavaScript.</p>
  43. <p>As you know, I have already described the benefits of browser applications
  44. (<a href="http://opengamestudio.org/en/news/on-the-way-to-durable-applications.html">nCKOB</a> static site generator) and the benefits of using Git
  45. instead of yet another back-end with API (<a href="http://opengamestudio.org/en/news/git-budget.html">GitBudget</a> to track
  46. personal spendings). Once GitBudget was out, I spent the remaining 2020
  47. to build a system allowing one to create browser applications right inside
  48. browsers. GitJS is the name of that system.</p>
  49. <p><cut/></p>
  50. <h1 id="gitjs">GitJS</h1>
  51. <p>The system uses Git for:</p>
  52. <ul>
  53. <li>long-term data storage <strong>outside</strong> of device;</li>
  54. <li>talking to the outside world;</li>
  55. <li>delivering the application to a device over HTTP.</li>
  56. </ul>
  57. <p>Thus, Git is not used for version control, Git is merely a
  58. widespread technology to keep data with read (HTTP) and write permissions. This
  59. might be somewhat counterintuitive. However, this allows everyone to decide
  60. where and how to keep data: paid/free, locally/remotely.</p>
  61. <p>You might argue that FTP/rsync could be used instead of Git if we only
  62. need to keep data. However, there are no widespread services like
  63. SourceForge/GitHub/BitBucket/GitLab for FTP/rsync. Also, there are no
  64. implementations of FTP/rsync that work inside browsers, and Git has
  65. <a href="https://isomorphic-git.org">Isomorphic-Git</a>.</p>
  66. <p>JS (alongside HTML/CSS) is used for:</p>
  67. <ul>
  68. <li>user interface;</li>
  69. <li>logic;</li>
  70. <li>long-term data storage <strong>on</strong> device.</li>
  71. </ul>
  72. <p>GitJS consists of the following three mandatory parts (in the order of execution):</p>
  73. <ol>
  74. <li><a href="https://gitlab.com/gitjs/gitjs.gitlab.io/-/blob/master/index.html">HTML page</a><ul>
  75. <li>introduces GitJS rules</li>
  76. <li>has a tiny size to work for slow connections</li>
  77. <li>is requested/delivered each time the page is completely refreshed</li>
  78. <li>may be hosted locally to work without the Internet</li></ul></li>
  79. <li><a href="https://bitbucket.org/gitjs/0000/src/master/0000.js">GitJS rules</a><ul>
  80. <li>are essentially a chunk of JS code</li>
  81. <li>introduce the concept of modules and their loading, saving, execution</li>
  82. <li>introduce the concept of sequences: a way to structure source code in a reactive-event-based manner</li>
  83. <li>are requested/delivered by HTML page only if they are absent or need an update</li>
  84. <li>are saved by HTML page into LocalStorage to start faster next time</li></ul></li>
  85. <li><a href="https://git.opengamestudio.org/kornerr/nPOBEPuTb-JSZip">Startup module</a><ul>
  86. <li>is located in the address string after <code>?</code> symbol</li>
  87. <li>is executed after the loading of GitJS rules</li>
  88. <li>does whatever is necessary, e.g., introduces dependent modules to be loaded before the main application should start</li>
  89. <li>the linked example depicts JSZip library test</li></ul></li>
  90. </ol>
  91. <p>Startup module may introduce absolutely any additional rules to GitJS ones or
  92. even replace them, so your fantasy here is only limited by what browsers
  93. permit: e.g., you can't erase all hard drive files of a user.</p>
  94. <p>I'd like to stress that having an HTML page and Git web service locally
  95. lets you use GitJS without the Internet.</p>
  96. <h1 id="gitjsapplication1editorofgitjsmodules">GitJS application №1: editor of GitJS modules</h1>
  97. <p>Currently, the editor has very basic functionality:</p>
  98. <p><strong>1.1. Editing of module's text files</strong></p>
  99. <p><img src="../../images/2021_gitjs-intro_правка-текстовых-файлов.png" alt="" /></p>
  100. <p><strong>1.2. Publishing changes to Git</strong></p>
  101. <p><img src="../../images/2021_gitjs-intro_публикация-изменений.png" alt="" /></p>
  102. <p><strong>Note</strong>: browsers keep passwords.</p>
  103. <p><strong>1.3. Editing the structure of a module</strong></p>
  104. <p><img src="../../images/2021_gitjs-intro_правка-структуры.png" alt="" /></p>
  105. <p><strong>1.4. Opening previously loaded modules from LocalStorage/IndexedDB</strong></p>
  106. <p><img src="../../images/2021_gitjs-intro_открытие-модуля.png" alt="" /></p>
  107. <p><strong>1.5. Saving changes locally into LocalStorage/IndexedDB</strong></p>
  108. <p>Here's the editor's last version: <a href="http://gitjs.org/📦">http://gitjs.org/📦</a>.
  109. The first run takes some time, be patient.</p>
  110. <h1 id="gitjsapplication2mahjongsolitaire">GitJS application №2: Mahjong solitaire</h1>
  111. <p>Currently, the game has the following functionality:</p>
  112. <p><strong>2.1. Selection and removal of tiles off the field according to Mahjong solitaire rules</strong></p>
  113. <p><img src="../../images/2021_gitjs-intro_механика.png" alt="" /></p>
  114. <p><strong>2.2. Tile theme selection</strong></p>
  115. <p><img src="../../images/2021_gitjs-intro_темы.png" alt="" /></p>
  116. <p><strong>2.3. Field layout selection</strong></p>
  117. <p><img src="../../images/2021_gitjs-intro_раскладки.png" alt="" /></p>
  118. <p><strong>2.4. Victory/loss detection</strong></p>
  119. <p>Here's the game's last version: <a href="http://gitjs.org/🀄/1.0.14">http://gitjs.org/🀄/1.0.14</a>.</p>
  120. <p>In the end, this game will match the original <a href="http://opengamestudio.org/en/game/ogs-mahjong-1.html">Mahjong</a> (released several
  121. years ago) in terms of features.</p>
  122. <h1 id="limitations">Limitations</h1>
  123. <p>GitJS limitations stem from browser ones.</p>
  124. <p><strong>1. CORS</strong></p>
  125. <p>To be able to publish changes to Git, we have to meet CORS restrictions.
  126. Currently, major services <a href="https://github.com/isomorphic-git/isomorphic-git#cors-support">do not allow to publish Git changes easily</a>,
  127. so one would have to use either a proxy, or a personal Git service.</p>
  128. <p><strong>2. Full-screen surfing on mobile</strong></p>
  129. <p>Nowadays, browsers collapse navigation and other controls when you scroll a
  130. page that doesn't fit into available space. This leaves the space at the top
  131. and the bottom of the screen free of controls but still unusable for touches
  132. because these touches bring those controls back. Such behaviour is very
  133. inconvenient for games.</p>
  134. <p>Mahjong solitaire works around that problem by supporting portrait mode: you
  135. can shift the field left/right. However, such a solution has its own drawbacks:
  136. one cannot see the field at a single glance, which makes the game harder to play.</p>
  137. <h1 id="plans">Plans</h1>
  138. <p><a href="http://opengamestudio.org/en/news/on-the-way-to-durable-applications.html">nCKOB</a> mentioned earlier will be rewritten as GitJS application. This
  139. would allow anyone to create statically generated sites without leaving a
  140. browser. We'll see how this goes.</p>
  141. <p>PS: The first image is "Bayan" picture created by Viktor Vasnetsov in 1910.</p>
  142. </div>
  143. </div>
  144. <div id="disqus_thread"></div>
  145. <script>
  146. var disqus_config = function () {
  147. this.page.url = "https://opengamestudio.org/en/news/gitjs-intro.html";
  148. this.page.identifier = "gitjs-intro.html";
  149. };
  150. (function() { // DON'T EDIT BELOW THIS LINE
  151. var d = document, s = d.createElement('script');
  152. s.src = 'https://opengamestudio.disqus.com/embed.js';
  153. s.setAttribute('data-timestamp', +new Date());
  154. (d.head || d.body).appendChild(s);
  155. })();
  156. </script>
  157. <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
  158. <div id="footer">
  159. The site has been generated by <a href="http://opengamestudio.org/pskov">PSKOV</a>
  160. from <a href="http://github.com/ogstudio/site-opengamestudio">this source code</a>.
  161. </div>
  162. </center>
  163. </body>
  164. </html>