docs.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. ---
  2. layout: base
  3. docs_tab: true
  4. analytics_id: UA-64283057-1
  5. ---
  6. {% include header.html %}
  7. {% comment %}
  8. set some constants
  9. {% endcomment %}
  10. {% assign ALL_PAGES = site.data.all-pages %}
  11. {% assign TOCFILE = site.data.toc[page.tocfile] %}
  12. {% capture VERSION_ROOT %}/docs/{{ page.language }}/{{ page.version }}/{% endcapture %}
  13. {% capture LANGUAGE_ROOT %}/docs/{{ page.language }}/{% endcapture %}
  14. {% assign MY_ENTRY = page.url | replace: VERSION_ROOT,"" %}
  15. {% assign my_entry_parts = MY_ENTRY | split: "/" %}
  16. {% comment %}
  17. PATH_TO_ROOT: path from here to version root, replacing all parts except the last one with '../'
  18. NOTE:
  19. the capture is a single line because extraneous whitespace would screw up the URI it produces
  20. {% endcomment %}
  21. {% capture PATH_TO_ROOT %}{% for item in my_entry_parts %}{% if forloop.rindex > 1 %}../{% endif %}{% endfor %}{% endcapture %}
  22. <div class="docs">
  23. <!-- Table of Contents -->
  24. <div class="hidden-xs hidden-sm site-toc-container">
  25. {% include toc_recursive_main.html entries=TOCFILE my_entry=MY_ENTRY path_to_root=PATH_TO_ROOT %}
  26. </div>
  27. <!-- Page content -->
  28. <div class="page-content-container">
  29. <div class="page-content">
  30. <div class="content-header">
  31. <!-- ToC Dropdown (for XS and SM sizes only) -->
  32. <div class="toc-dropdown dropdown visible-xs-block visible-sm-block">
  33. <button class="btn btn-default dropdown-toggle" type="button" id="tocDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
  34. {{ page.toc_text }}
  35. <span class="caret"></span>
  36. </button>
  37. <ul class="dropdown-menu">
  38. {% include toc_recursive_dropdown.html entries=TOCFILE my_entry=MY_ENTRY path_to_root=PATH_TO_ROOT %}
  39. </ul>
  40. </div>
  41. {% comment %}
  42. Show a single edit-link if the page has a specific edit-link.
  43. {% endcomment %}
  44. {% if page.edit_link %}
  45. <a class="edit hidden-xs hidden-sm" href="{{ page.edit_link }}"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> {{ page.edit_text }}</a>
  46. {% comment %}
  47. Otherwise, show editing and translating options.
  48. Edit-links obey the following rules:
  49. if page in /dev/ or /latest/:
  50. show edit link for /dev/ page in source language
  51. if page not in source language:
  52. show translation link for /dev/ page
  53. else:
  54. show edit link for the page in its version and language
  55. {% endcomment %}
  56. {% else %}
  57. {% capture base_edit_link %}https://github.com/apache/cordova-docs/tree/master/www/{{ page.path }}{% endcapture %}
  58. {% capture base_version %}/{{ page.version }}/{% endcapture %}
  59. {% capture base_language %}/{{ page.language }}/{% endcapture %}
  60. {% capture dev_version %}/dev/{% endcapture %}
  61. {% capture src_language %}/{{ site.src_language }}/{% endcapture %}
  62. {% comment %}
  63. Edit-links for current pages in non-source languages
  64. NOTE:
  65. Pages that are under /dev/ or /latest/ (i.e. site.latest_docs_version) have page.current set to "true".
  66. {% endcomment %}
  67. {% if page.language != site.src_language and page.current %}
  68. {% comment %}
  69. Compute crowdin link
  70. {% endcomment %}
  71. {% capture page_path_prefix %}docs/{{ page.language }}/{{ page.version }}{% endcapture %}
  72. {% assign page_path_end = page.path | split:"/" | last %}
  73. {% assign crowdin_path = page.path | replace:page_path_prefix,"docs/en/dev" | replace:page_path_end,"" %}
  74. {% capture crowdin_link %}https://crowdin.com/project/cordova/{{ page.language }}#/cordova-docs/{{ crowdin_path }}{% endcapture %}
  75. {% assign edit_link = base_edit_link | replace:base_language,src_language | replace:base_version,dev_version %}
  76. <a class="edit" href="{{ edit_link }}"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> {{ page.edit_source_text }}</a>
  77. <a class="edit" href="{{ crowdin_link }}"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> {{ page.edit_translation_text }}</a>
  78. {% comment %}
  79. Edit-links for all other pages
  80. {% endcomment %}
  81. {% else %}
  82. {% comment %}
  83. Edit-link for latest version points to dev instead
  84. {% endcomment %}
  85. {% if page.version == site.latest_docs_version %}
  86. {% assign edit_link = base_edit_link | replace:base_version,dev_version %}
  87. {% else %}
  88. {% assign edit_link = base_edit_link %}
  89. {% endif %}
  90. <a class="edit" href="{{ edit_link }}"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> {{ page.edit_source_text }}</a>
  91. {% endif %}
  92. {% endif %}
  93. <!-- Language dropdown -->
  94. <div class="dropdown">
  95. <button class="btn btn-default dropdown-toggle" type="button" id="languageDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
  96. {{ site.data.docs-versions[page.language].name }}
  97. <span class="caret"></span>
  98. </button>
  99. <!-- List all languages -->
  100. <ul class="dropdown-menu" aria-labelledby="languageDropdown">
  101. {% for other_language_entry in site.data.docs-versions %}
  102. {% assign other_language_id = other_language_entry[0] %}
  103. {% assign other_language = other_language_entry[1] %}
  104. {% assign other_language_versions = other_language.versions %}
  105. {% assign other_language_name = other_language.name %}
  106. {% capture other_language_root %}/docs/{{ other_language_id }}/{% endcapture %}
  107. {% comment %}
  108. Replace only the language part of the URI, thereby redirecting to the same page
  109. in the other language. The page will exist because translations are clones of each other.
  110. {% endcomment %}
  111. {% assign other_language_url = page.url | replace:LANGUAGE_ROOT,other_language_root %}
  112. <li>
  113. <a href="{{ site.baseurl }}{{ other_language_url }}" class="{% unless other_language_versions contains page.version %}missing-page{% endunless %}">
  114. {% if page.language == other_language_id %}
  115. <span class="selected">
  116. {{ other_language_name }}
  117. </span>
  118. {% else %}
  119. {{ other_language_name }}
  120. {% endif %}
  121. </a>
  122. </li>
  123. {% endfor %}
  124. </ul>
  125. </div>
  126. <!-- Version dropdown -->
  127. <div class="dropdown">
  128. <button class="btn btn-default dropdown-toggle" type="button" id="versionDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
  129. {{ page.version }}
  130. {% if page.version == site.latest_docs_version %}
  131. ({{ page.latest_text }})
  132. {% endif %}
  133. <span class="caret"></span>
  134. </button>
  135. <ul class="dropdown-menu" aria-labelledby="versionDropdown">
  136. <!-- List versions available in this language -->
  137. {% for other_version in site.data.docs-versions[page.language].versions reversed %}
  138. <li>
  139. {% comment %}
  140. Name the latest version as "latest" to take advantage of redirects for "/latest/".
  141. {% endcomment %}
  142. {% if other_version == site.latest_docs_version %}
  143. {% assign other_version_string = "latest" %}
  144. {% else %}
  145. {% assign other_version_string = other_version %}
  146. {% endif %}
  147. {% capture version_entry_string %}
  148. {{ other_version }}
  149. {% if other_version == site.latest_docs_version %}
  150. ({{ page.latest_text }})
  151. {% endif %}
  152. {% endcapture %}
  153. {% comment %}
  154. Replace only the version part of the URI, thereby redirecting to
  155. the same page in the other version.
  156. NOTE:
  157. This page might not exist in the target version because page
  158. layouts change from version to version
  159. {% endcomment %}
  160. {% capture other_version_root %}/docs/{{ page.language }}/{{ other_version_string }}/{% endcapture %}
  161. {% assign other_version_url = page.url | replace:VERSION_ROOT,other_version_root %}
  162. {% unless ALL_PAGES contains other_version_url %}
  163. {% assign other_version_url = other_version_root %}
  164. {% endunless %}
  165. <a href="{{ site.baseurl }}{{ other_version_url }}" class="{% unless ALL_PAGES contains other_version_url %}missing-page{% endunless %}">
  166. {% if page.version == other_version %}
  167. <span class="selected">
  168. {{ version_entry_string }}
  169. </span>
  170. {% else %}
  171. {{ version_entry_string }}
  172. {% endif %}
  173. </a>
  174. </li>
  175. {% endfor %}
  176. </ul>
  177. </div>
  178. </div>
  179. {% comment %}
  180. Get URL for this page in the latest version
  181. {% endcomment %}
  182. {% capture latest_root %}/docs/{{ page.language }}/latest/{% endcapture %}
  183. {% assign latest_url = page.url | replace:VERSION_ROOT,latest_root %}
  184. {% comment %}
  185. If this page doesn't exist, just use root
  186. {% endcomment %}
  187. {% unless ALL_PAGES contains latest_url %}
  188. {% assign latest_url = latest_root %}
  189. {% endunless %}
  190. <!-- Show warnings for special versions -->
  191. <!-- dev warning -->
  192. {% if page.version == 'dev' %}
  193. <div class="alert docs-alert alert-info" role="alert">
  194. <button type="button" class="close" data-dismiss="alert" aria-label="Close">
  195. <span aria-hidden="true">&times;</span>
  196. </button>
  197. {{ page.in_development_text }}
  198. <a href="{{ site.baseurl }}{{ latest_url }}">
  199. {{ page.click_here_text }}
  200. </a>
  201. </div>
  202. {% endif %}
  203. <!-- outdated warning -->
  204. {% if page.version != 'dev' and page.version != site.latest_docs_version %}
  205. <div class="alert docs-alert alert-danger" role="alert">
  206. <button type="button" class="close" data-dismiss="alert" aria-label="Close">
  207. <span aria-hidden="true">&times;</span>
  208. </button>
  209. {{ page.outdated_text }}
  210. <a href="{{ site.baseurl }}{{ latest_url }}">
  211. {{ page.click_here_text }}
  212. </a>
  213. </div>
  214. {% endif %}
  215. <!-- plugin version warning -->
  216. {% if page.plugin_name and page.plugin_version %}
  217. <div class="alert alert-warning docs-alert" role="alert">
  218. <button type="button" class="close" data-dismiss="alert" aria-label="Close">
  219. <span aria-hidden="true">&times;</span>
  220. </button>
  221. {{ page.plugin_version_text }} {{ page.plugin_version }}.
  222. <a href="https://github.com/apache/{{ page.plugin_name }}/releases">
  223. {{ page.visit_github_text }}
  224. </a>
  225. </div>
  226. {% endif %}
  227. <div id="page-toc-source">
  228. {{ content }}
  229. </div>
  230. </div>
  231. <div class="row">
  232. {% include footer_docs.html %}
  233. </div>
  234. </div>
  235. </div>
  236. <script defer type="text/javascript" src="{{ site.baseurl }}/static/js/lib/toc.min.js"></script>
  237. <script defer type="text/javascript" src="{{ site.baseurl }}/static/js/docs.js"></script>