選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

158 行
9.2KB

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