create-lupine 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) hide show
  1. package/README.md +13 -7
  2. package/index.js +232 -108
  3. package/package.json +1 -1
  4. package/templates/common/.agents/skills/lupine-framework/SKILL.md +3 -3
  5. package/templates/common/.agents/skills/lupine-framework/references/backend-api.md +16 -1
  6. package/templates/common/.agents/skills/lupine-framework/references/icon-handling.md +1 -1
  7. package/templates/common/.agents/skills/lupine-framework/references/mobile-interactions.md +17 -88
  8. package/templates/common/.agents/skills/lupine-framework/references/native-apps.md +47 -24
  9. package/templates/common/.agents/skills/lupine-framework/references/navigation-and-routing.md +1 -0
  10. package/templates/common/.agents/skills/lupine-framework/references/reactivity-and-state.md +2 -2
  11. package/templates/common/.agents/skills/lupine-framework/references/styling-and-themes.md +3 -1
  12. package/templates/common/.env.mobile +4 -3
  13. package/templates/common/_env +8 -4
  14. package/templates/common/apps/server/README.md +10 -0
  15. package/templates/common/dev/cp-folder.js +9 -4
  16. package/templates/lupine-template-cv-starter/README.md +33 -1
  17. package/templates/lupine-template-cv-starter/app/package.json +20 -0
  18. package/templates/lupine-template-cv-starter/app/src/app.tsx +6 -0
  19. package/templates/lupine-template-cv-starter/app/src/index.native.tsx +4 -0
  20. package/templates/lupine-template-cv-starter/app/src/index.test.tsx +71 -0
  21. package/templates/lupine-template-cv-starter/app/src/index.web.tsx +28 -0
  22. package/templates/lupine-template-cv-starter/app/tsconfig.json +17 -0
  23. package/templates/lupine-template-cv-starter/lupine.json +8 -7
  24. package/templates/lupine-template-cv-starter/web/src/index.html +9 -2
  25. package/templates/lupine-template-cv-starter/web/src/index.tsx +9 -14
  26. package/templates/lupine-template-cv-starter/web/src/lupine-template-cv-starter/index.html +9 -2
  27. package/templates/lupine-template-cv-starter/web/src/lupine-template-cv-starter/index.tsx +4 -20
  28. package/templates/lupine-template-doc-starter/README.md +33 -1
  29. package/templates/lupine-template-doc-starter/app/package.json +20 -0
  30. package/templates/lupine-template-doc-starter/app/src/app.tsx +6 -0
  31. package/templates/lupine-template-doc-starter/app/src/index.native.tsx +4 -0
  32. package/templates/lupine-template-doc-starter/app/src/index.test.tsx +78 -0
  33. package/templates/lupine-template-doc-starter/app/src/index.web.tsx +28 -0
  34. package/templates/lupine-template-doc-starter/app/tsconfig.json +17 -0
  35. package/templates/lupine-template-doc-starter/lupine.json +8 -7
  36. package/templates/lupine-template-doc-starter/web/src/index.html +9 -2
  37. package/templates/lupine-template-doc-starter/web/src/index.tsx +9 -14
  38. package/templates/lupine-template-doc-starter/web/src/lupine-template-doc-starter/index.html +9 -2
  39. package/templates/lupine-template-doc-starter/web/src/lupine-template-doc-starter/index.tsx +4 -20
  40. package/templates/lupine-template-fullstack-note/README.md +83 -0
  41. package/templates/{lupine-template-cv-starter → lupine-template-fullstack-note}/api/package.json +2 -2
  42. package/templates/lupine-template-fullstack-note/api/resources/install.mysql.sql +32 -0
  43. package/templates/lupine-template-fullstack-note/api/resources/install.sqlite.sql +27 -0
  44. package/templates/lupine-template-fullstack-note/api/src/service/answer.ts +39 -0
  45. package/templates/lupine-template-fullstack-note/api/src/service/api.ts +52 -0
  46. package/templates/lupine-template-fullstack-note/api/src/service/db.ts +78 -0
  47. package/templates/lupine-template-fullstack-note/api/src/service/notes-api.ts +86 -0
  48. package/templates/lupine-template-fullstack-note/api/src/service/root-api.ts +19 -0
  49. package/templates/lupine-template-fullstack-note/api/src/service/user-api.ts +182 -0
  50. package/templates/lupine-template-fullstack-note/app/package.json +19 -0
  51. package/templates/lupine-template-fullstack-note/app/src/app.tsx +75 -0
  52. package/templates/lupine-template-fullstack-note/app/src/index.native.tsx +4 -0
  53. package/templates/lupine-template-fullstack-note/app/src/index.test.tsx +373 -0
  54. package/templates/lupine-template-fullstack-note/app/src/index.web.tsx +20 -0
  55. package/templates/lupine-template-fullstack-note/app/src/pages/components.tsx +65 -0
  56. package/templates/lupine-template-fullstack-note/app/src/pages/details.tsx +38 -0
  57. package/templates/lupine-template-fullstack-note/app/src/pages/discover.tsx +25 -0
  58. package/templates/lupine-template-fullstack-note/app/src/pages/home.tsx +76 -0
  59. package/templates/lupine-template-fullstack-note/app/src/pages/inbox.tsx +49 -0
  60. package/templates/lupine-template-fullstack-note/app/src/pages/login.tsx +54 -0
  61. package/templates/lupine-template-fullstack-note/app/src/pages/me.tsx +32 -0
  62. package/templates/lupine-template-fullstack-note/app/src/pages/notes.tsx +128 -0
  63. package/templates/lupine-template-fullstack-note/app/src/pages/settings.tsx +45 -0
  64. package/templates/lupine-template-fullstack-note/app/src/shell/AppMenu.tsx +44 -0
  65. package/templates/lupine-template-fullstack-note/app/src/shell/api.ts +159 -0
  66. package/templates/lupine-template-fullstack-note/app/src/shell/data.ts +20 -0
  67. package/templates/lupine-template-fullstack-note/app/src/shell/locales/ja.ts +80 -0
  68. package/templates/lupine-template-fullstack-note/app/src/shell/locales/zh-CN.ts +80 -0
  69. package/templates/lupine-template-fullstack-note/app/src/shell/texts.ts +14 -0
  70. package/templates/lupine-template-fullstack-note/app/tsconfig.json +17 -0
  71. package/templates/lupine-template-fullstack-note/lupine.json +25 -0
  72. package/templates/lupine-template-fullstack-note/web/assets/favicon.ico +0 -0
  73. package/templates/{lupine-template-doc-starter/api → lupine-template-fullstack-note/web}/package.json +2 -2
  74. package/templates/lupine-template-fullstack-note/web/src/index.html +23 -0
  75. package/templates/lupine-template-fullstack-note/web/src/index.tsx +15 -0
  76. package/templates/lupine-template-fullstack-starter/README.md +63 -14
  77. package/templates/lupine-template-fullstack-starter/api/src/service/user-api.ts +11 -6
  78. package/templates/lupine-template-fullstack-starter/app/package.json +20 -0
  79. package/templates/lupine-template-fullstack-starter/app/src/app.tsx +76 -0
  80. package/templates/lupine-template-fullstack-starter/app/src/index.native.tsx +4 -0
  81. package/templates/lupine-template-fullstack-starter/app/src/index.test.tsx +276 -0
  82. package/templates/lupine-template-fullstack-starter/app/src/index.web.tsx +28 -0
  83. package/templates/lupine-template-fullstack-starter/app/src/pages/about.tsx +27 -0
  84. package/templates/lupine-template-fullstack-starter/app/src/pages/contact.tsx +41 -0
  85. package/templates/lupine-template-fullstack-starter/app/src/pages/favorite.tsx +27 -0
  86. package/templates/lupine-template-fullstack-starter/app/src/pages/home.tsx +63 -0
  87. package/templates/lupine-template-fullstack-starter/app/src/pages/login.tsx +63 -0
  88. package/templates/lupine-template-fullstack-starter/app/src/pages/mine.tsx +44 -0
  89. package/templates/lupine-template-fullstack-starter/app/src/pages/profile.tsx +58 -0
  90. package/templates/lupine-template-fullstack-starter/app/src/pages/register.tsx +48 -0
  91. package/templates/lupine-template-fullstack-starter/app/src/pages/reset-password.tsx +41 -0
  92. package/templates/lupine-template-fullstack-starter/app/src/pages/settings.tsx +33 -0
  93. package/templates/lupine-template-fullstack-starter/app/src/pages/story.tsx +46 -0
  94. package/templates/lupine-template-fullstack-starter/app/src/shell/api.ts +127 -0
  95. package/templates/lupine-template-fullstack-starter/app/src/shell/parts.tsx +100 -0
  96. package/templates/lupine-template-fullstack-starter/app/src/shell/stories.ts +65 -0
  97. package/templates/lupine-template-fullstack-starter/app/src/shell/texts.ts +79 -0
  98. package/templates/lupine-template-fullstack-starter/app/tsconfig.json +17 -0
  99. package/templates/lupine-template-fullstack-starter/lupine.json +6 -7
  100. package/templates/lupine-template-fullstack-starter/web/src/admin/admin-patch.tsx +34 -0
  101. package/templates/lupine-template-fullstack-starter/web/src/{components → admin/components}/home-search-component.tsx +18 -25
  102. package/templates/lupine-template-fullstack-starter/web/src/{components → admin/components}/story-card.tsx +17 -8
  103. package/templates/lupine-template-fullstack-starter/web/src/{components → admin/components}/story-list.tsx +1 -2
  104. package/templates/lupine-template-fullstack-starter/web/src/{admin_dev → admin}/index.html +1 -0
  105. package/templates/lupine-template-fullstack-starter/web/src/{admin_dev → admin}/index.tsx +13 -28
  106. package/templates/lupine-template-fullstack-starter/web/src/{pages → admin/pages}/admin-cfg.tsx +23 -19
  107. package/templates/lupine-template-fullstack-starter/web/src/{pages → admin/pages}/admin-item-edit.tsx +3 -4
  108. package/templates/lupine-template-fullstack-starter/web/src/{pages → admin/pages}/admin-item-list.tsx +2 -3
  109. package/templates/lupine-template-fullstack-starter/web/src/{pages → admin/pages}/admin-user.tsx +15 -20
  110. package/templates/lupine-template-fullstack-starter/web/src/index.html +8 -2
  111. package/templates/lupine-template-fullstack-starter/web/src/index.tsx +11 -150
  112. package/templates/lupine-template-fullstack-starter/web/src/services/fetch-data.ts +7 -25
  113. package/templates/lupine-template-fullstack-starter/web/src/styles/base-css.ts +0 -3
  114. package/templates/lupine-template-fullstack-starter/web/src/styles/theme.ts +1 -2
  115. package/templates/lupine-template-responsive-starter/README.md +46 -2
  116. package/templates/lupine-template-responsive-starter/app/package.json +19 -0
  117. package/templates/lupine-template-responsive-starter/app/src/app.tsx +80 -0
  118. package/templates/lupine-template-responsive-starter/app/src/index.native.tsx +4 -0
  119. package/templates/lupine-template-responsive-starter/app/src/index.test.tsx +283 -0
  120. package/templates/lupine-template-responsive-starter/app/src/index.web.tsx +31 -0
  121. package/templates/lupine-template-responsive-starter/app/src/pages/about.tsx +23 -0
  122. package/templates/lupine-template-responsive-starter/app/src/pages/finance.tsx +48 -0
  123. package/templates/lupine-template-responsive-starter/app/src/pages/mine.tsx +60 -0
  124. package/templates/lupine-template-responsive-starter/app/src/pages/not-found.tsx +9 -0
  125. package/templates/lupine-template-responsive-starter/app/src/pages/note-detail.tsx +43 -0
  126. package/templates/lupine-template-responsive-starter/app/src/pages/note-edit.tsx +45 -0
  127. package/templates/lupine-template-responsive-starter/app/src/pages/note-search.tsx +62 -0
  128. package/templates/lupine-template-responsive-starter/app/src/pages/notes.tsx +71 -0
  129. package/templates/lupine-template-responsive-starter/app/src/pages/settings.tsx +55 -0
  130. package/templates/lupine-template-responsive-starter/app/src/pages/tools.tsx +112 -0
  131. package/templates/lupine-template-responsive-starter/app/src/shell/icons.ts +7 -0
  132. package/templates/lupine-template-responsive-starter/app/src/shell/layout.ts +18 -0
  133. package/templates/lupine-template-responsive-starter/app/src/shell/locales/zh-CN.ts +89 -0
  134. package/templates/lupine-template-responsive-starter/app/src/shell/menu.tsx +81 -0
  135. package/templates/lupine-template-responsive-starter/app/src/shell/nav.ts +12 -0
  136. package/templates/lupine-template-responsive-starter/app/src/shell/store.ts +72 -0
  137. package/templates/lupine-template-responsive-starter/app/src/shell/texts.ts +11 -0
  138. package/templates/lupine-template-responsive-starter/app/tsconfig.json +17 -0
  139. package/templates/lupine-template-responsive-starter/lupine.json +7 -6
  140. package/templates/lupine-template-responsive-starter/web/src/index.html +9 -2
  141. package/templates/lupine-template-responsive-starter/web/src/index.tsx +9 -25
  142. package/templates/lupine-template-responsive-starter/web/src/lupine-template-responsive-starter/index.html +12 -6
  143. package/templates/lupine-template-responsive-starter/web/src/lupine-template-responsive-starter/index.tsx +12 -22
  144. package/templates/common/apps/server/src/app-loader.ts +0 -4
  145. package/templates/lupine-template-cv-starter/api/resources/config_default.json +0 -6
  146. package/templates/lupine-template-cv-starter/api/resources/install.sqlite.sql +0 -4
  147. package/templates/lupine-template-cv-starter/api/src/index.ts +0 -15
  148. package/templates/lupine-template-cv-starter/web/src/client-env-keys.ts +0 -5
  149. package/templates/lupine-template-cv-starter/web/src/styles/base-css.ts +0 -15
  150. package/templates/lupine-template-doc-starter/api/resources/config_default.json +0 -6
  151. package/templates/lupine-template-doc-starter/api/resources/install.sqlite.sql +0 -4
  152. package/templates/lupine-template-doc-starter/api/src/index.ts +0 -15
  153. package/templates/lupine-template-doc-starter/api/src/resources/config_default.json +0 -6
  154. package/templates/lupine-template-doc-starter/api/src/resources/install.sqlite.sql +0 -4
  155. package/templates/lupine-template-doc-starter/web/src/client-env-keys.ts +0 -5
  156. package/templates/lupine-template-doc-starter/web/src/styles/base-css.ts +0 -15
  157. package/templates/lupine-template-fullstack-starter/web/src/admin_dev/admin-about.tsx +0 -16
  158. package/templates/lupine-template-fullstack-starter/web/src/admin_dev/admin-patch.ts +0 -22
  159. package/templates/lupine-template-fullstack-starter/web/src/components/footer-menu.tsx +0 -52
  160. package/templates/lupine-template-fullstack-starter/web/src/components/footer.tsx +0 -15
  161. package/templates/lupine-template-fullstack-starter/web/src/components/header.tsx +0 -75
  162. package/templates/lupine-template-fullstack-starter/web/src/components/login-code-zh.tsx +0 -162
  163. package/templates/lupine-template-fullstack-starter/web/src/components/login-code.tsx +0 -165
  164. package/templates/lupine-template-fullstack-starter/web/src/components/login-zh.tsx +0 -118
  165. package/templates/lupine-template-fullstack-starter/web/src/components/login.tsx +0 -122
  166. package/templates/lupine-template-fullstack-starter/web/src/components/not-found-page.tsx +0 -12
  167. package/templates/lupine-template-fullstack-starter/web/src/components/register-zh.tsx +0 -161
  168. package/templates/lupine-template-fullstack-starter/web/src/components/register.tsx +0 -163
  169. package/templates/lupine-template-fullstack-starter/web/src/components/reset-password-zh.tsx +0 -166
  170. package/templates/lupine-template-fullstack-starter/web/src/components/reset-password.tsx +0 -177
  171. package/templates/lupine-template-fullstack-starter/web/src/components/user-info.tsx +0 -84
  172. package/templates/lupine-template-fullstack-starter/web/src/frames/admin-page-frame.tsx +0 -48
  173. package/templates/lupine-template-fullstack-starter/web/src/frames/frame1-page-frame.tsx +0 -61
  174. package/templates/lupine-template-fullstack-starter/web/src/frames/frame2-page-frame.tsx +0 -61
  175. package/templates/lupine-template-fullstack-starter/web/src/frames/top-frame.tsx +0 -23
  176. package/templates/lupine-template-fullstack-starter/web/src/frames/user-page-frame.tsx +0 -90
  177. package/templates/lupine-template-fullstack-starter/web/src/models/index.ts +0 -15
  178. package/templates/lupine-template-fullstack-starter/web/src/pages/contact.tsx +0 -105
  179. package/templates/lupine-template-fullstack-starter/web/src/pages/page1-page.tsx +0 -38
  180. package/templates/lupine-template-fullstack-starter/web/src/pages/page2-page.tsx +0 -38
  181. package/templates/lupine-template-fullstack-starter/web/src/pages/user-favorite-page.tsx +0 -58
  182. package/templates/lupine-template-fullstack-starter/web/src/pages/user-home-page.tsx +0 -27
  183. package/templates/lupine-template-fullstack-starter/web/src/pages/user-mine-page.tsx +0 -54
  184. package/templates/lupine-template-fullstack-starter/web/src/pages/user-profile-page-zh.tsx +0 -112
  185. package/templates/lupine-template-fullstack-starter/web/src/pages/user-profile-page.tsx +0 -112
  186. package/templates/lupine-template-fullstack-starter/web/src/pages/user1-page.tsx +0 -57
  187. package/templates/lupine-template-fullstack-starter/web/src/services/shared-data.ts +0 -19
  188. package/templates/lupine-template-fullstack-starter/web/src/styles/app.css +0 -0
  189. package/templates/lupine-template-responsive-starter/api/package.json +0 -6
  190. package/templates/lupine-template-responsive-starter/api/resources/config_default.json +0 -6
  191. package/templates/lupine-template-responsive-starter/api/resources/install.sqlite.sql +0 -4
  192. package/templates/lupine-template-responsive-starter/api/src/service/root-api.ts +0 -18
  193. package/templates/lupine-template-responsive-starter/web/src/app-icons.ts +0 -76
  194. package/templates/lupine-template-responsive-starter/web/src/components/input-history-component.tsx +0 -93
  195. package/templates/lupine-template-responsive-starter/web/src/components/mine-about-page.tsx +0 -87
  196. package/templates/lupine-template-responsive-starter/web/src/components/mine-premium-page.tsx +0 -81
  197. package/templates/lupine-template-responsive-starter/web/src/components/mine-settings-page.tsx +0 -211
  198. package/templates/lupine-template-responsive-starter/web/src/components/mobile-top-search-menu.tsx +0 -107
  199. package/templates/lupine-template-responsive-starter/web/src/components/note-detail.tsx +0 -110
  200. package/templates/lupine-template-responsive-starter/web/src/components/note-edit.tsx +0 -144
  201. package/templates/lupine-template-responsive-starter/web/src/components/note-search-page.tsx +0 -188
  202. package/templates/lupine-template-responsive-starter/web/src/components/search-input.tsx +0 -95
  203. package/templates/lupine-template-responsive-starter/web/src/components/side-menu-content.tsx +0 -169
  204. package/templates/lupine-template-responsive-starter/web/src/frames/app-responsive-frame.tsx +0 -53
  205. package/templates/lupine-template-responsive-starter/web/src/pages/about-page.tsx +0 -32
  206. package/templates/lupine-template-responsive-starter/web/src/pages/finance-page.tsx +0 -35
  207. package/templates/lupine-template-responsive-starter/web/src/pages/home-page.tsx +0 -444
  208. package/templates/lupine-template-responsive-starter/web/src/pages/mine-page.tsx +0 -318
  209. package/templates/lupine-template-responsive-starter/web/src/pages/tools-page.tsx +0 -35
  210. package/templates/lupine-template-responsive-starter/web/src/services/local-notes-service.ts +0 -87
  211. package/templates/lupine-template-responsive-starter/web/src/services/mine-service.ts +0 -45
  212. package/templates/lupine-template-responsive-starter/web/src/styles/app.css +0 -0
  213. package/templates/lupine-template-responsive-starter/web/src/styles/base-css.ts +0 -65
  214. package/templates/lupine-template-responsive-starter/web/src/styles/global.css +0 -2130
  215. package/templates/lupine-template-responsive-starter/web/src/styles/theme.ts +0 -17
  216. /package/templates/lupine-template-cv-starter/{web → app}/markdown/en/01-experience/index.md +0 -0
  217. /package/templates/lupine-template-cv-starter/{web → app}/markdown/en/02-projects/index.md +0 -0
  218. /package/templates/lupine-template-cv-starter/{web → app}/markdown/en/03-skills/index.md +0 -0
  219. /package/templates/lupine-template-cv-starter/{web → app}/markdown/en/04-education/index.md +0 -0
  220. /package/templates/lupine-template-cv-starter/{web → app}/markdown/en/index.md +0 -0
  221. /package/templates/lupine-template-cv-starter/{web → app}/markdown/index.md +0 -0
  222. /package/templates/lupine-template-cv-starter/{web → app}/markdown/zh/01-experience/index.md +0 -0
  223. /package/templates/lupine-template-cv-starter/{web → app}/markdown/zh/02-projects/index.md +0 -0
  224. /package/templates/lupine-template-cv-starter/{web → app}/markdown/zh/03-skills/index.md +0 -0
  225. /package/templates/lupine-template-cv-starter/{web → app}/markdown/zh/04-education/index.md +0 -0
  226. /package/templates/lupine-template-cv-starter/{web → app}/markdown/zh/index.md +0 -0
  227. /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/en/01-experience/index.html +0 -0
  228. /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/en/02-projects/index.html +0 -0
  229. /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/en/03-skills/index.html +0 -0
  230. /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/en/04-education/index.html +0 -0
  231. /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/en/index.html +0 -0
  232. /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/index.html +0 -0
  233. /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/markdown-config.ts +0 -0
  234. /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/zh/01-experience/index.html +0 -0
  235. /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/zh/02-projects/index.html +0 -0
  236. /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/zh/03-skills/index.html +0 -0
  237. /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/zh/04-education/index.html +0 -0
  238. /package/templates/lupine-template-cv-starter/{web → app}/src/markdown-built/zh/index.html +0 -0
  239. /package/templates/lupine-template-doc-starter/{web → app}/markdown/en/essentials/index.md +0 -0
  240. /package/templates/lupine-template-doc-starter/{web → app}/markdown/en/essentials/list.md +0 -0
  241. /package/templates/lupine-template-doc-starter/{web → app}/markdown/en/guide/install.md +0 -0
  242. /package/templates/lupine-template-doc-starter/{web → app}/markdown/en/guide/started.md +0 -0
  243. /package/templates/lupine-template-doc-starter/{web → app}/markdown/en/index.md +0 -0
  244. /package/templates/lupine-template-doc-starter/{web → app}/markdown/index.md +0 -0
  245. /package/templates/lupine-template-doc-starter/{web → app}/markdown/zh/essentials/index.md +0 -0
  246. /package/templates/lupine-template-doc-starter/{web → app}/markdown/zh/essentials/list.md +0 -0
  247. /package/templates/lupine-template-doc-starter/{web → app}/markdown/zh/guide/install.md +0 -0
  248. /package/templates/lupine-template-doc-starter/{web → app}/markdown/zh/guide/started.md +0 -0
  249. /package/templates/lupine-template-doc-starter/{web → app}/markdown/zh/index.md +0 -0
  250. /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/en/essentials/index.html +0 -0
  251. /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/en/essentials/list.html +0 -0
  252. /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/en/guide/install.html +0 -0
  253. /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/en/guide/started.html +0 -0
  254. /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/en/index.html +0 -0
  255. /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/index.html +0 -0
  256. /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/markdown-config.ts +0 -0
  257. /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/zh/essentials/index.html +0 -0
  258. /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/zh/essentials/list.html +0 -0
  259. /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/zh/guide/install.html +0 -0
  260. /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/zh/guide/started.html +0 -0
  261. /package/templates/lupine-template-doc-starter/{web → app}/src/markdown-built/zh/index.html +0 -0
  262. /package/templates/{lupine-template-responsive-starter → lupine-template-fullstack-note}/api/src/index.ts +0 -0
  263. /package/templates/lupine-template-fullstack-starter/{web/assets/images → app/assets}/sample.png +0 -0
  264. /package/templates/lupine-template-fullstack-starter/web/src/{components → admin/components}/story-props.ts +0 -0
@@ -0,0 +1,48 @@
1
+ import { createSignal, View } from 'lupine.native.core';
2
+ import { Button, createForm, Field, PasswordField, RadioGroup, router, rules, Screen, T, t, TextField, tr } from 'lupine.native.components';
3
+ import * as icons from 'lupine.core/icons';
4
+ import { api } from '../shell/api';
5
+ import { back, report } from '../shell/parts';
6
+
7
+ /** A new account. The e-mail address is the user name; the first sign-in is with a code of the e-mail, which activates it. */
8
+ export const Register = () => {
9
+ const [busy, setBusy] = createSignal(false);
10
+ let password = () => '';
11
+ const form = createForm(
12
+ { email: '', password: '', password2: '', name: '', sex: '' },
13
+ {
14
+ email: [rules.required(), rules.email(t('auth.emailInvalid', 'Enter a valid e-mail address'))],
15
+ password: [rules.required(), rules.min(6)],
16
+ password2: (v) => v !== password() && t('auth.mismatch', 'The two passwords differ'),
17
+ name: rules.required(),
18
+ sex: rules.required(t('auth.chooseOne', 'Choose one')),
19
+ }
20
+ );
21
+ password = () => form.value('password');
22
+ const submit = async () => {
23
+ if (busy() || !form.validate()) return;
24
+ setBusy(true);
25
+ const v = form.values();
26
+ const answer = await api.register({ u: v.email.trim(), p: v.password, preferredName: v.name.trim(), sex: v.sex });
27
+ setBusy(false);
28
+ if (report(answer)) router.replace('/login', { email: v.email.trim() });
29
+ };
30
+ return (
31
+ <Screen title={tr('auth.register', 'Create an account')} onBack={back} testID='page-register'>
32
+ <View style={{ padding: 20, gap: 14, width: '100%', maxWidth: 420, alignSelf: 'center' }}>
33
+ <TextField label={tr('auth.email', 'E-mail')} icon={icons.mail} keyboardType='email' hint={tr('auth.emailHint', 'Codes for signing in and new passwords are sent to it')} {...form.text('email')} testID='register-email' />
34
+ <PasswordField label={tr('auth.password', 'Password')} hint={tr('auth.passwordHint', '6 characters or more')} {...form.text('password')} testID='register-password' />
35
+ <PasswordField label={tr('auth.password2', 'The password again')} {...form.text('password2')} testID='register-password2' />
36
+ <TextField label={tr('auth.name', 'Name to show')} icon={icons.user} {...form.text('name')} testID='register-name' />
37
+ <Field label={tr('auth.gender', 'Gender')} error={() => form.error('sex')} testID='register-sex'>
38
+ <RadioGroup
39
+ horizontal options={[{ label: tr('auth.male', 'Male'), value: 'male' }, { label: tr('auth.female', 'Female'), value: 'female' }]}
40
+ value={() => form.value('sex') || null} onChange={(v) => form.set('sex', v)} testID='register-sex'
41
+ />
42
+ </Field>
43
+ <Button title={tr('auth.register', 'Create an account')} kind='primary' block loading={busy} onPress={submit} testID='register-submit' />
44
+ <T kind='caption' style={{ textAlign: 'center' }}>{tr('auth.registerHint', 'Then sign in with a code of the e-mail: it activates the account.')}</T>
45
+ </View>
46
+ </Screen>
47
+ );
48
+ };
@@ -0,0 +1,41 @@
1
+ import { createSignal, View } from 'lupine.native.core';
2
+ import { Button, createForm, PasswordField, router, rules, Screen, t, TextField, tr } from 'lupine.native.components';
3
+ import * as icons from 'lupine.core/icons';
4
+ import { api } from '../shell/api';
5
+ import { back, CodeButton, report } from '../shell/parts';
6
+
7
+ /** A new password with a code of the e-mail. */
8
+ export const ResetPassword = (p: { email?: string }) => {
9
+ const [busy, setBusy] = createSignal(false);
10
+ let password = () => '';
11
+ const form = createForm(
12
+ { email: p.email || '', code: '', password: '', password2: '' },
13
+ {
14
+ email: rules.required(),
15
+ code: rules.required(),
16
+ password: [rules.required(), rules.min(6)],
17
+ password2: (v) => v !== password() && t('auth.mismatch', 'The two passwords differ'),
18
+ }
19
+ );
20
+ password = () => form.value('password');
21
+ const submit = async () => {
22
+ if (busy() || !form.validate()) return;
23
+ setBusy(true);
24
+ const v = form.values();
25
+ const answer = await api.resetPassword(v.email.trim(), v.password, v.code.trim());
26
+ setBusy(false);
27
+ if (report(answer)) router.replace('/login', { email: v.email.trim() });
28
+ };
29
+ return (
30
+ <Screen title={tr('auth.reset', 'A new password')} onBack={back} testID='page-reset'>
31
+ <View style={{ padding: 20, gap: 14, width: '100%', maxWidth: 420, alignSelf: 'center' }}>
32
+ <TextField label={tr('auth.user', 'E-mail or user name')} icon={icons.user} keyboardType='email' {...form.text('email')} testID='reset-email' />
33
+ <CodeButton email={() => form.value('email').trim()} ready={() => !!form.value('email').trim()} onInvalid={() => form.set('email', form.value('email'))} testID='reset-send-code' />
34
+ <TextField label={tr('auth.code', 'Code of the e-mail')} keyboardType='number' {...form.text('code')} testID='reset-code' />
35
+ <PasswordField label={tr('auth.newPassword', 'New password')} hint={tr('auth.passwordHint', '6 characters or more')} {...form.text('password')} testID='reset-password' />
36
+ <PasswordField label={tr('auth.password2', 'The password again')} {...form.text('password2')} onSubmit={submit} testID='reset-password2' />
37
+ <Button title={tr('auth.setPassword', 'Set the password')} kind='primary' block loading={busy} onPress={submit} testID='reset-submit' />
38
+ </View>
39
+ </Screen>
40
+ );
41
+ };
@@ -0,0 +1,33 @@
1
+ import { Platform } from 'lupine.native.core';
2
+ import { ActionSheet, lang, languages, router, Row, Screen, Section, setLang, setThemePref, t, themePref, themes, tr } from 'lupine.native.components';
3
+ import * as icons from 'lupine.core/icons';
4
+ import { serverAddress } from '../shell/api';
5
+ import { back } from '../shell/parts';
6
+
7
+ /** Theme and language: kept on the device (on the web in cookies, so that the server renders the page with them). */
8
+ export const Settings = () => {
9
+ const label = (n: string) =>
10
+ n === 'system' ? t('settings.system', 'As the system') : n === 'light' ? t('settings.light', 'Light') : n === 'dark' ? t('settings.dark', 'Dark') : n === 'ocean' ? t('settings.ocean', 'Ocean') : n === 'sand' ? t('settings.sand', 'Sand') : n;
11
+ const pickTheme = async () => {
12
+ const v = await ActionSheet.select({ title: t('settings.theme', 'Theme'), selected: themePref(), options: ['system', ...Object.keys(themes)].map((n) => ({ label: label(n), value: n })) });
13
+ if (v) setThemePref(v);
14
+ };
15
+ const pickLang = async () => {
16
+ const v = await ActionSheet.select({ title: t('settings.language', 'Language'), selected: lang(), options: languages.map((l) => ({ label: l.name, value: l.code })) });
17
+ if (v) setLang(v);
18
+ };
19
+ return (
20
+ <Screen title={tr('nav.settings', 'Settings')} onBack={back} grouped testID='page-settings'>
21
+ <Section title={tr('settings.appearance', 'Appearance')}>
22
+ <Row label={tr('settings.theme', 'Theme')} icon={icons.palette} iconColor='#5e5ce6' value={() => label(themePref())} onPress={pickTheme} testID='settings-theme' />
23
+ <Row label={tr('settings.language', 'Language')} icon={icons.language} iconColor='#34c759' value={() => languages.find((l) => l.code === lang())?.name || lang()} onPress={pickLang} testID='settings-language' />
24
+ </Section>
25
+ <Section title={tr('settings.app', 'App')}>
26
+ {/* WEB.API_BASE_URL of the env file of the build; the web version uses its own site */}
27
+ {Platform.OS !== 'web' && <Row label={tr('settings.server', 'Server')} value={serverAddress()} testID='settings-server' />}
28
+ <Row label={tr('settings.version', 'Version')} value={APP_VERSION} />
29
+ <Row label={tr('nav.about', 'About')} icon={icons.info} iconColor='#30b0c7' onPress={() => router.push('/about')} testID='settings-about' />
30
+ </Section>
31
+ </Screen>
32
+ );
33
+ };
@@ -0,0 +1,46 @@
1
+ import { Image, Text, View } from 'lupine.native.core';
2
+ import { Button, col, Icon, MessageBox, router, Screen, T, t, Toast, tr } from 'lupine.native.components';
3
+ import * as icons from 'lupine.core/icons';
4
+ import { api } from '../shell/api';
5
+ import { back, categoryName } from '../shell/parts';
6
+ import { favorites, findStory } from '../shell/stories';
7
+ import { NotFound } from './about';
8
+
9
+ /** /story/3: a route of its own, so links, the back button of the browser and the server's page work. */
10
+ export const StoryPage = (p: { id: string }) => {
11
+ const story = findStory(Number(p.id));
12
+ if (!story) return <NotFound />;
13
+ const on = () => favorites.has(story.id);
14
+ const toggle = async () => {
15
+ if (!api.user()) {
16
+ if (await MessageBox.confirm({ message: t('story.signInFirst', 'Sign in to keep your favorites'), okText: t('auth.signIn', 'Sign in') })) router.push('/login');
17
+ return;
18
+ }
19
+ favorites.toggle(story.id);
20
+ Toast.success(on() ? t('story.added', 'Added to your favorites') : t('story.removed', 'Removed from your favorites'));
21
+ };
22
+ return (
23
+ <Screen title={story.title} onBack={back} testID='page-story'>
24
+ <Image src={story.cover} resizeMode='cover' style={{ width: '100%', aspectRatio: 800 / 520 }} />
25
+ <View style={{ padding: 16, gap: 10 }}>
26
+ <T kind='title' testID='story-title'>{story.title}</T>
27
+ <View style={{ flexDirection: 'row', alignItems: 'center', gap: 14, flexWrap: 'wrap' }}>
28
+ <T kind='secondary'>{story.author}</T>
29
+ <View style={{ flexDirection: 'row', alignItems: 'center', gap: 4 }}>
30
+ <Icon name={icons.eye} size={16} color={col('textTertiary')} />
31
+ <Text style={{ fontSize: 14, color: col('textTertiary') }}>{String(story.views)}</Text>
32
+ </View>
33
+ <View style={{ flexDirection: 'row', alignItems: 'center', gap: 4 }}>
34
+ <Icon name={icons.tag} size={16} color={col('textTertiary')} />
35
+ <Text style={{ fontSize: 14, color: col('textTertiary') }}>{() => categoryName(story.category)}</Text>
36
+ </View>
37
+ </View>
38
+ <T>{tr('story.text', 'The text of the story goes here. The stories of this template are samples (app/src/shell/stories.ts); a real app gets them from its API.')}</T>
39
+ <Button
40
+ title={() => (on() ? t('story.unfavorite', 'Remove from favorites') : t('story.favorite', 'Add to favorites'))}
41
+ icon={icons.heart} kind='primary' onPress={toggle} testID='story-favorite'
42
+ />
43
+ </View>
44
+ </Screen>
45
+ );
46
+ };
@@ -0,0 +1,127 @@
1
+ import { createSignal, Platform, storage, webEnv } from 'lupine.native.core';
2
+ import { lang, t } from 'lupine.native.components';
3
+
4
+ // The API of this template (api/src/service/api.ts, routes under /api), with fetch on every platform.
5
+ //
6
+ // The server: in the browser the page comes from it, so it is the same address (''), whatever the env file says. A
7
+ // native app needs its address: WEB.API_BASE_URL of the env file (lupine-native --env; .env.mobile for the apps of the
8
+ // stores; the key is public, it goes into the bundle), otherwise `npm run dev` on this computer (from the Android
9
+ // emulator 10.0.2.2).
10
+ //
11
+ // The session: the API answers a sign-in with the cookie _token (httpOnly). The browser keeps it and sends it, and
12
+ // scripts never see it. A native app has no cookie jar: it keeps the token of the answer (`result`) with storage and
13
+ // sends it as the cookie of each request itself, with the language of the messages of the API.
14
+
15
+ export interface User {
16
+ id: number;
17
+ email: string;
18
+ username: string;
19
+ nickname: string;
20
+ usertype: string;
21
+ }
22
+ /** what the API answers: status 'ok' or 'error', a message; offline: the server wasn't reached */
23
+ export interface Answer {
24
+ status: string;
25
+ message?: string;
26
+ offline?: boolean;
27
+ [key: string]: any;
28
+ }
29
+
30
+ const native = Platform.OS !== 'web';
31
+ const port = webEnv('API_PORT', 11080);
32
+ const local = `http://${Platform.OS === 'android' ? '10.0.2.2' : 'lupine-template-fullstack-starter.app.localhost'}:${port}`;
33
+ let base = native ? (webEnv('API_BASE_URL', '') || local).replace(/\/+$/, '') : '';
34
+
35
+ /** 'http://host:port'; '' in the browser (the server of the page) */
36
+ export const serverAddress = () => base;
37
+ /** another server, such as one that isn't there (the tests) */
38
+ export const setServerAddress = (address: string) => {
39
+ base = address.replace(/\/+$/, '');
40
+ };
41
+
42
+ // a native app only: the token of the session, and the user, so that the app knows it at once and offline
43
+ const TOKEN = 'session';
44
+ const USER = 'user';
45
+ const cached = (): User | null => {
46
+ if (!native) return null;
47
+ try {
48
+ return JSON.parse(storage.get(USER) || 'null');
49
+ } catch {
50
+ return null;
51
+ }
52
+ };
53
+ // On the web this stays null while the server renders a page (the modules are shared by all requests): the browser asks
54
+ // who is signed in (api.refresh in onMount of the app).
55
+ const [user, setUser] = createSignal<User | null>(cached());
56
+ const keep = (u: User | null) => {
57
+ setUser(u);
58
+ if (native) storage.set(USER, u ? JSON.stringify(u) : null);
59
+ };
60
+ const forget = () => {
61
+ keep(null);
62
+ if (native) storage.set(TOKEN, null);
63
+ };
64
+
65
+ const call = async (path: string, body?: object): Promise<Answer> => {
66
+ const headers: { [name: string]: string } = { Accept: 'application/json' };
67
+ if (body) headers['Content-Type'] = 'application/json';
68
+ if (native) {
69
+ // what a browser sends by itself
70
+ const token = storage.get(TOKEN);
71
+ headers.Cookie = `lang=${encodeURIComponent(lang())}` + (token ? `; _token=${encodeURIComponent(token)}` : '');
72
+ }
73
+ const abort = new AbortController();
74
+ const timer = setTimeout(() => abort.abort(), 20000);
75
+ try {
76
+ const response = await fetch(base + path, { method: body ? 'POST' : 'GET', headers, body: body ? JSON.stringify(body) : undefined, signal: abort.signal });
77
+ const text = await response.text();
78
+ try {
79
+ const json = JSON.parse(text);
80
+ if (json && typeof json === 'object' && typeof json.status === 'string') return json;
81
+ } catch {
82
+ // not JSON: below
83
+ }
84
+ return { status: 'error', message: t('api.badAnswer', 'Unexpected answer of the server ({status})', { status: response.status }) };
85
+ } catch {
86
+ return { status: 'error', offline: true, message: t('api.offline', 'The server cannot be reached') };
87
+ } finally {
88
+ clearTimeout(timer);
89
+ }
90
+ };
91
+
92
+ /** after a sign-in: an app keeps the token; then who it is */
93
+ const signedIn = async (answer: Answer) => {
94
+ if (answer.status !== 'ok') return answer;
95
+ if (native) storage.set(TOKEN, String(answer.result || ''));
96
+ const info = await call('/api/user-info');
97
+ const u = answer.user || {};
98
+ keep(info.status === 'ok' ? info.results : { id: 0, email: '', username: String(u.u || ''), nickname: String(u.nickname || u.u || ''), usertype: String(u.t || 'user') });
99
+ return answer;
100
+ };
101
+
102
+ export const api = {
103
+ user,
104
+ /** who is signed in: the browser by its cookie, an app by its token. Offline an app keeps the user it knows. */
105
+ refresh: async () => {
106
+ if (native && !storage.get(TOKEN)) return forget();
107
+ const answer = await call('/api/user-info');
108
+ if (answer.status === 'ok') keep(answer.results);
109
+ else if (!answer.offline) forget();
110
+ },
111
+ login: async (u: string, p: string) => signedIn(await call('/api/login', { u, p })),
112
+ /** with the code of the e-mail; it also activates a new account */
113
+ loginWithCode: async (u: string, c: string) => signedIn(await call('/api/login', { u, c })),
114
+ /** a code by e-mail, for loginWithCode and resetPassword (one a minute) */
115
+ sendCode: (u: string) => call('/api/reset-code', { u }),
116
+ register: (p: { u: string; p: string; preferredName: string; sex: string }) => call('/api/register', p),
117
+ resetPassword: (u: string, p: string, a: string) => call('/api/reset-pw', { u, p, a }),
118
+ /** password: '' keeps it. A new password ends the session (the token holds a hash of it). */
119
+ updateProfile: (nickname: string, password: string) => call('/api/user-profile', { nickname, password }),
120
+ contact: (p: { name: string; email: string; subject: string; message: string }) => call('/api/add-contact', p),
121
+ logout: async () => {
122
+ await call('/api/logout', {});
123
+ forget();
124
+ },
125
+ /** sign out on this device only */
126
+ forget,
127
+ };
@@ -0,0 +1,100 @@
1
+ import { createSignal, Image, MaybeSignal, onCleanup, Text, View } from 'lupine.native.core';
2
+ import { Button, Card, col, EmptyView, Icon, IconName, router, t, Toast, tr } from 'lupine.native.components';
3
+ import * as icons from 'lupine.core/icons';
4
+ import { Answer, api } from './api';
5
+ import { Story } from './stories';
6
+
7
+ // Pieces that several pages use.
8
+
9
+ export const back = () => void router.back();
10
+
11
+ /** the message of the API as a toast; true if it went well */
12
+ export const report = (answer: Answer, success?: string) => {
13
+ if (answer.status === 'ok') {
14
+ Toast.success(success || answer.message || t('api.done', 'Done'));
15
+ return true;
16
+ }
17
+ Toast.error(answer.message || t('api.failed', 'Something went wrong'));
18
+ return false;
19
+ };
20
+
21
+ export const categoryName = (c: string) =>
22
+ ({
23
+ all: t('cat.all', 'All'),
24
+ chinese: t('cat.chinese', 'Chinese'),
25
+ europe: t('cat.europe', 'Europe'),
26
+ asia: t('cat.asia', 'Asia'),
27
+ dimension: t('cat.dimension', 'Dimension'),
28
+ ancient: t('cat.ancient', 'Ancient'),
29
+ simple: t('cat.simple', 'Simple'),
30
+ })[c] || c;
31
+
32
+ const Count = (p: { icon: IconName; n: number }) => (
33
+ <View style={{ flexDirection: 'row', alignItems: 'center', gap: 4 }}>
34
+ <Icon name={p.icon} size={14} color={col('textTertiary')} />
35
+ <Text style={{ fontSize: 12, color: col('textTertiary') }}>{String(p.n)}</Text>
36
+ </View>
37
+ );
38
+
39
+ /** a story in the grid of the home page */
40
+ export const StoryCard = (p: { story: Story }) => (
41
+ <Card onPress={() => router.push(`/story/${p.story.id}`)} style={{ padding: 0, overflow: 'hidden' }} testID={`story-${p.story.id}`}>
42
+ <Image src={p.story.cover} resizeMode='cover' style={{ width: '100%', aspectRatio: 800 / 520 }} />
43
+ <View style={{ padding: 10, gap: 4 }}>
44
+ <Text numberOfLines={1} style={{ fontSize: 15, fontWeight: '600', color: col('text') }}>{p.story.title}</Text>
45
+ <View style={{ flexDirection: 'row', alignItems: 'center', gap: 10 }}>
46
+ <Text numberOfLines={1} style={{ flex: 1, fontSize: 12, color: col('textSecondary') }}>{p.story.author}</Text>
47
+ <Count icon={icons.eye} n={p.story.views} />
48
+ <Count icon={icons.heart} n={p.story.favorites} />
49
+ </View>
50
+ </View>
51
+ </Card>
52
+ );
53
+
54
+ /** a story in a list: the favorites */
55
+ export const StoryRow = (p: { story: Story; testID?: string }) => (
56
+ <Card onPress={() => router.push(`/story/${p.story.id}`)} style={{ flexDirection: 'row', alignItems: 'center', gap: 12, padding: 8 }} testID={p.testID}>
57
+ <Image src={p.story.cover} resizeMode='cover' style={{ width: 72, height: 47, borderRadius: 6 }} />
58
+ <View style={{ flex: 1, gap: 2 }}>
59
+ <Text numberOfLines={1} style={{ fontSize: 16, color: col('text') }}>{p.story.title}</Text>
60
+ <Text numberOfLines={1} style={{ fontSize: 12, color: col('textSecondary') }}>{p.story.author}</Text>
61
+ </View>
62
+ <Icon name={icons.chevronRight} size={16} color={col('textTertiary')} />
63
+ </Card>
64
+ );
65
+
66
+ /** in place of a page that needs a sign-in */
67
+ export const SignInFirst = (p: { title: MaybeSignal<string>; testID: string }) => (
68
+ <View style={{ alignItems: 'center', gap: 4, paddingBottom: 24 }}>
69
+ <EmptyView icon={icons.lock} title={p.title} />
70
+ <Button title={tr('auth.signIn', 'Sign in')} kind='primary' onPress={() => router.push('/login')} testID={p.testID} />
71
+ </View>
72
+ );
73
+
74
+ /** Sends a code by e-mail (sign-in, a new password), then waits a minute, as the API does. */
75
+ export const CodeButton = (p: { email: () => string; ready: () => boolean; onInvalid: () => void; testID: string }) => {
76
+ const [wait, setWait] = createSignal(0);
77
+ const [busy, setBusy] = createSignal(false);
78
+ let timer: ReturnType<typeof setInterval> | undefined;
79
+ onCleanup(() => clearInterval(timer));
80
+ const send = async () => {
81
+ if (!p.ready()) return p.onInvalid();
82
+ if (busy() || wait() > 0) return;
83
+ setBusy(true);
84
+ const answer = await api.sendCode(p.email());
85
+ setBusy(false);
86
+ if (!report(answer, t('auth.codeSent', 'If the address has an account, a code is on its way'))) return;
87
+ setWait(60);
88
+ clearInterval(timer);
89
+ timer = setInterval(() => {
90
+ setWait(wait() - 1);
91
+ if (wait() <= 0) clearInterval(timer);
92
+ }, 1000);
93
+ };
94
+ return (
95
+ <Button
96
+ title={() => (wait() > 0 ? t('auth.sendAgainIn', 'Send again in {n} s', { n: wait() }) : t('auth.sendCode', 'Send a code'))}
97
+ kind='outline' block loading={busy} disabled={() => wait() > 0} onPress={send} testID={p.testID}
98
+ />
99
+ );
100
+ };
@@ -0,0 +1,65 @@
1
+ import { createMemo, createSignal, storage } from 'lupine.native.core';
2
+ import { api } from './api';
3
+ import cover from '../../assets/sample.png';
4
+
5
+ // Sample stories, the same in the app and in the list of the admin pages (web/src/components/home-search-component.tsx).
6
+ // A real app gets them from its API (a table, a route such as /api/stories?q=...&category=...).
7
+
8
+ export interface Story {
9
+ id: number;
10
+ title: string;
11
+ author: string;
12
+ cover: string;
13
+ category: string;
14
+ views: number;
15
+ favorites: number;
16
+ }
17
+
18
+ export const categories = ['all', 'chinese', 'europe', 'asia', 'dimension', 'ancient', 'simple'];
19
+
20
+ export const stories: Story[] = Array.from({ length: 100 }, (_, i) => ({
21
+ id: i + 1,
22
+ title: `Title ${i + 1}`,
23
+ author: `Author ${i + 1}`,
24
+ cover,
25
+ category: categories[1 + (i % (categories.length - 1))],
26
+ views: 100 + i,
27
+ favorites: 30 + i,
28
+ }));
29
+
30
+ export const findStory = (id: number) => stories.find((s) => s.id === id);
31
+
32
+ /** by words of the title or the author, and a category ('all': any) */
33
+ export const searchStories = (text: string, category: string) => {
34
+ const words = text.toLowerCase().split(/\s+/).filter(Boolean);
35
+ return stories.filter((s) => (category === 'all' || s.category === category) && words.every((w) => `${s.title} ${s.author}`.toLowerCase().includes(w)));
36
+ };
37
+
38
+ // The favorites of the user who is signed in, kept on this device (a real app keeps them with its API). On the web it is
39
+ // localStorage: the page of the server is without them, the browser fills them in.
40
+ const key = () => `favorites:${api.user()?.username || ''}`;
41
+ const [version, setVersion] = createSignal(0);
42
+ const read = (): number[] => {
43
+ try {
44
+ return JSON.parse(storage.get(key()) || '[]');
45
+ } catch {
46
+ return [];
47
+ }
48
+ };
49
+ const ids = createMemo(() => (version(), api.user() ? read() : []));
50
+
51
+ export const favorites = {
52
+ ids,
53
+ has: (id: number) => ids().includes(id),
54
+ stories: createMemo(() => ids().map(findStory).filter((s): s is Story => !!s)),
55
+ toggle: (id: number) => {
56
+ const list = ids();
57
+ storage.set(key(), JSON.stringify(list.includes(id) ? list.filter((x) => x !== id) : [id, ...list]));
58
+ setVersion(version() + 1);
59
+ },
60
+ /** the tests */
61
+ clear: () => {
62
+ storage.set(key(), null);
63
+ setVersion(version() + 1);
64
+ },
65
+ };
@@ -0,0 +1,79 @@
1
+ import { addLnTexts, addTexts, lnZhHans, setLanguages } from 'lupine.native.components';
2
+
3
+ // English is in the code: t('home.more', 'Show more'); here the other languages. (The messages of the API come from the
4
+ // API, in the language of the cookie lang: api/src/lang.)
5
+ addTexts('zh-CN', {
6
+ app: { name: 'Lupine 全栈', notFound: '页面不存在' },
7
+ nav: { home: '故事', favorite: '收藏', mine: '我的', settings: '设置', about: '关于' },
8
+ home: { search: '搜索标题和作者', count: '{n} 个故事', none: '没有找到故事', more: '显示更多' },
9
+ cat: { all: '全部', chinese: '中国', europe: '欧洲', asia: '亚洲', dimension: '次元', ancient: '古风', simple: '简约' },
10
+ story: {
11
+ text: '这里是故事的正文。本模板的故事是示例数据(app/src/shell/stories.ts),真实的应用从它的 API 获取。',
12
+ favorite: '加入收藏',
13
+ unfavorite: '取消收藏',
14
+ added: '已加入收藏',
15
+ removed: '已取消收藏',
16
+ signInFirst: '登录后才能收藏',
17
+ },
18
+ favorite: { signIn: '登录后查看你的收藏', none: '还没有收藏:点故事页上的爱心即可收藏', browse: '浏览故事' },
19
+ mine: { guest: '游客', profile: '个人资料', contact: '联系我们', admin: '管理页面' },
20
+ auth: {
21
+ signIn: '登录',
22
+ signOut: '退出登录',
23
+ signOutAsk: '在这台设备上退出登录?',
24
+ signedOut: '已退出登录',
25
+ welcome: '欢迎,{name}',
26
+ withPassword: '密码',
27
+ withCode: '邮箱验证码',
28
+ user: '邮箱或用户名',
29
+ password: '密码',
30
+ password2: '再输入一次密码',
31
+ newPassword: '新密码',
32
+ passwordHint: '至少 6 个字符',
33
+ code: '邮件中的验证码',
34
+ codeInvalid: '验证码只包含数字',
35
+ sendCode: '发送验证码',
36
+ sendAgainIn: '{n} 秒后可重新发送',
37
+ codeSent: '如果该地址有账号,验证码已发出',
38
+ activate: '请激活账号:发送验证码到你的邮箱,并用它登录',
39
+ forgot: '忘记密码?',
40
+ noAccount: '注册新账号',
41
+ register: '注册新账号',
42
+ registerHint: '然后用邮件中的验证码登录,即可激活账号。',
43
+ email: '邮箱',
44
+ emailHint: '登录验证码和新密码都会发送到这里',
45
+ emailInvalid: '请输入正确的邮箱地址',
46
+ name: '显示的名字',
47
+ gender: '性别',
48
+ male: '男',
49
+ female: '女',
50
+ chooseOne: '请选择一项',
51
+ mismatch: '两次输入的密码不一致',
52
+ reset: '设置新密码',
53
+ setPassword: '设置密码',
54
+ adminHint: '.env 中的管理员(ADMIN_USER)也在这里登录;管理页面在网站上(/admin)。',
55
+ },
56
+ profile: { type: '账号类型', keep: '留空则不修改密码', save: '保存', again: '请用新密码重新登录', signIn: '登录后修改个人资料' },
57
+ contact: { name: '你的名字', subject: '主题', message: '内容', send: '发送', sent: '谢谢,消息已发送', hint: '我们会通过邮件回复。' },
58
+ settings: {
59
+ appearance: '外观',
60
+ theme: '主题',
61
+ language: '语言',
62
+ system: '跟随系统',
63
+ light: '浅色',
64
+ dark: '深色',
65
+ ocean: '海洋',
66
+ sand: '沙滩',
67
+ app: '应用',
68
+ server: '服务器',
69
+ version: '版本',
70
+ },
71
+ about: { tagline: '应用在所有平台上,管理页面在网站上,共用一个 API', text: '使用 lupine.native(应用)、lupine.web(管理页面)和 lupine.api(服务器)构建。' },
72
+ api: { offline: '无法连接服务器', badAnswer: '服务器的回答无法识别({status})', failed: '出错了', done: '完成' },
73
+ });
74
+ // and those of the controls
75
+ addLnTexts({ 'zh-Hans': lnZhHans });
76
+ setLanguages([
77
+ { code: 'en', name: 'English' },
78
+ { code: 'zh-CN', name: '简体中文' },
79
+ ]);
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2020",
4
+ "lib": ["es2020"],
5
+ "types": [],
6
+ "jsx": "react-jsx",
7
+ "jsxImportSource": "lupine.native.core",
8
+ "module": "esnext",
9
+ "moduleResolution": "bundler",
10
+ "strict": true,
11
+ "noEmit": true,
12
+ "skipLibCheck": true
13
+ },
14
+ // the web entry is the only file that may use the DOM, so it isn't checked with these settings
15
+ "include": ["src"],
16
+ "exclude": ["src/index.web.tsx"]
17
+ }
@@ -1,5 +1,7 @@
1
1
  {
2
2
  "name": "lupine-template-fullstack-starter",
3
+ "nativeOut": "dist/native",
4
+ "nativeApp": "app",
3
5
  "webEntryPoints": [
4
6
  {
5
7
  "index": "web/src/index.tsx",
@@ -7,16 +9,13 @@
7
9
  "outdir": "/"
8
10
  },
9
11
  {
10
- "index": "web/src/admin_dev/index.tsx",
11
- "html": "web/src/admin_dev/index.html",
12
- "outdir": "/admin_dev",
12
+ "index": "web/src/admin/index.tsx",
13
+ "html": "web/src/admin/index.html",
14
+ "outdir": "/admin",
13
15
  "env": "web"
14
16
  }
15
17
  ],
16
18
  "apiEntryPoint": "api/src/index.ts",
17
- "watchFiles": [
18
- "web/icons-font.config.js"
19
- ],
20
19
  "copyFiles": [
21
20
  {
22
21
  "env": "all",
@@ -29,4 +28,4 @@
29
28
  "to": "data/resources"
30
29
  }
31
30
  ]
32
- }
31
+ }
@@ -0,0 +1,34 @@
1
+ import { adminFrameHelper } from 'lupine.api/admin';
2
+ import { clearCookie } from 'lupine.web';
3
+ import { AdminCfgPage } from './pages/admin-cfg';
4
+ import { AdminItemListPage } from './pages/admin-item-list';
5
+ import { AdminUserPage } from './pages/admin-user';
6
+
7
+ export const patchAdminFrame = () => {
8
+ // the pages of the site, for the admins of the app and the developer
9
+ adminFrameHelper.insertMenuItem(
10
+ [
11
+ {
12
+ id: 'site',
13
+ text: 'Site',
14
+ url: '',
15
+ items: [
16
+ { id: 'site-items', text: 'Items', icon: 'list', url: '', js: () => adminFrameHelper.addPanel('Items', <AdminItemListPage />) },
17
+ { id: 'site-users', text: 'Users', icon: 'shield', url: '', js: () => adminFrameHelper.addPanel('Users', <AdminUserPage />) },
18
+ { id: 'site-website', text: 'Website', icon: 'globe', url: '', js: () => adminFrameHelper.addPanel('Website', <AdminCfgPage />) },
19
+ ],
20
+ },
21
+ ],
22
+ 'contents'
23
+ );
24
+
25
+ adminFrameHelper.setAppAdminHookCheckLogin(async (authResponse: any) => {
26
+ if (authResponse && authResponse.user && authResponse.user.admin === '1') {
27
+ return true;
28
+ }
29
+ return false;
30
+ });
31
+ adminFrameHelper.setAppAdminHookLogout(async () => {
32
+ clearCookie('_token', '/');
33
+ });
34
+ };