docs.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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. {% assign other_version_string = other_version %}
  143. {% capture version_entry_string %}
  144. {{ other_version }}
  145. {% if other_version == site.latest_docs_version %}
  146. ({{ page.latest_text }})
  147. {% endif %}
  148. {% endcapture %}
  149. {% comment %}
  150. Replace only the version part of the URI, thereby redirecting to
  151. the same page in the other version.
  152. NOTE:
  153. This page might not exist in the target version because page
  154. layouts change from version to version
  155. {% endcomment %}
  156. {% capture other_version_root %}/docs/{{ page.language }}/{{ other_version_string }}/{% endcapture %}
  157. {% assign other_version_url = page.url | replace:VERSION_ROOT,other_version_root %}
  158. {% unless ALL_PAGES contains other_version_url %}
  159. {% assign other_version_url = other_version_root %}
  160. {% endunless %}
  161. <a href="{{ site.baseurl }}{{ other_version_url }}" class="{% unless ALL_PAGES contains other_version_url %}missing-page{% endunless %}">
  162. {% if page.version == other_version %}
  163. <span class="selected">
  164. {{ version_entry_string }}
  165. </span>
  166. {% else %}
  167. {{ version_entry_string }}
  168. {% endif %}
  169. </a>
  170. </li>
  171. {% endfor %}
  172. </ul>
  173. </div>
  174. </div>
  175. {% comment %}
  176. Get URL for this page in the latest version
  177. {% endcomment %}
  178. {% capture latest_root %}/docs/{{ page.language }}/latest/{% endcapture %}
  179. {% assign latest_url = page.url | replace:VERSION_ROOT,latest_root %}
  180. {% comment %}
  181. If this page doesn't exist, just use root
  182. {% endcomment %}
  183. {% unless ALL_PAGES contains latest_url %}
  184. {% assign latest_url = latest_root %}
  185. {% endunless %}
  186. <!-- Show warnings for special versions -->
  187. <!-- dev warning -->
  188. {% if page.version == 'dev' %}
  189. <div class="alert docs-alert alert-info" role="alert">
  190. <button type="button" class="close" data-dismiss="alert" aria-label="Close">
  191. <span aria-hidden="true">&times;</span>
  192. </button>
  193. {{ page.in_development_text }}
  194. <a href="{{ site.baseurl }}{{ latest_url }}">
  195. {{ page.click_here_text }}
  196. </a>
  197. </div>
  198. {% endif %}
  199. <!-- outdated warning -->
  200. {% if page.version != 'dev' and page.version != site.latest_docs_version %}
  201. <div class="alert docs-alert alert-danger" role="alert">
  202. <button type="button" class="close" data-dismiss="alert" aria-label="Close">
  203. <span aria-hidden="true">&times;</span>
  204. </button>
  205. {{ page.outdated_text }}
  206. <a href="{{ site.baseurl }}{{ latest_url }}">
  207. {{ page.click_here_text }}
  208. </a>
  209. </div>
  210. {% endif %}
  211. <!-- plugin version warning -->
  212. {% if page.plugin_name and page.plugin_version %}
  213. <div class="alert alert-warning docs-alert" role="alert">
  214. <button type="button" class="close" data-dismiss="alert" aria-label="Close">
  215. <span aria-hidden="true">&times;</span>
  216. </button>
  217. {{ page.plugin_version_text }} {{ page.plugin_version }}.
  218. <a href="https://github.com/apache/{{ page.plugin_name }}/releases">
  219. {{ page.visit_github_text }}
  220. </a>
  221. </div>
  222. {% endif %}
  223. <div id="page-toc-source">
  224. {{ content }}
  225. </div>
  226. </div>
  227. <div class="row">
  228. {% include footer_docs.html %}
  229. </div>
  230. </div>
  231. </div>
  232. <script defer type="text/javascript" src="{{ site.baseurl }}/static/js/lib/toc.min.js"></script>
  233. <script defer type="text/javascript" src="{{ site.baseurl }}/static/js/docs.js"></script>