Skip to content

Commit fe13043

Browse files
committed
add files
1 parent 6b6370e commit fe13043

32 files changed

+25985
-0
lines changed

front-editor.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/*
3+
* Plugin Name: AApps - Front Editor
4+
* Description: Front editor for WP
5+
* Author: uptimizt
6+
* Version: 0.1
7+
*/
8+
9+
require_once __DIR__ . '/includes/Meta.php';
10+
require_once __DIR__ . '/includes/FieldUrl.php';
11+
12+
add_shortcode('fetest', function () {
13+
14+
ob_start(); ?>
15+
16+
<div class="feapp">loading...</div>
17+
18+
<?php return ob_get_clean();
19+
});
20+
21+
22+
add_action('wp_enqueue_scripts', function () {
23+
24+
25+
if (!is_singular()) {
26+
return;
27+
}
28+
29+
$post = get_post();
30+
31+
if (!has_shortcode($post->post_content, 'fetest')) {
32+
return;
33+
}
34+
35+
$css_files = [
36+
'bundle' => '/frontend/public/build/bundle.css',
37+
// 'shared' => '/frontend/public/build/shared.css'
38+
];
39+
foreach ($css_files as $key => $file_path) {
40+
$ver = filemtime(__DIR__ . $file_path);
41+
wp_enqueue_style('fedev-' . $key, $src = plugins_url($file_path, __FILE__), $deps = [], $ver);
42+
43+
}
44+
45+
$app_js_path = '/frontend/public/build/bundle.js';
46+
wp_enqueue_script('editorFeMd', plugins_url($app_js_path, __FILE__), [], filemtime(__DIR__ . $app_js_path), true);
47+
$config_app = [
48+
'root' => esc_url_raw( rest_url() ),
49+
'nonce' => wp_create_nonce( 'wp_rest' ),
50+
'pageUrl' => get_permalink($post),
51+
'toolbarEnable' => false,
52+
'fileCoverEnable' => false,
53+
];
54+
55+
$config_app = apply_filters( 'editor_fe_md_config', $config_app);
56+
57+
wp_localize_script( 'editorFeMd', 'editorFeMdConfig', $config_app);
58+
});
59+

frontend/.env-example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
APP_DEV_USERNAME=user
2+
APP_DEV_PASS=secret
3+

frontend/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/node_modules/
2+
!/public/build/
3+
4+
.DS_Store
5+
6+
.env

frontend/README.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
*Psst — looking for a more complete solution? Check out [SvelteKit](https://kit.svelte.dev), the official framework for building web applications of all sizes, with a beautiful development experience and flexible filesystem-based routing.*
2+
3+
*Looking for a shareable component template instead? You can [use SvelteKit for that as well](https://kit.svelte.dev/docs#packaging) or the older [sveltejs/component-template](https://github.com/sveltejs/component-template)*
4+
5+
---
6+
7+
# svelte app
8+
9+
This is a project template for [Svelte](https://svelte.dev) apps. It lives at https://github.com/sveltejs/template.
10+
11+
To create a new project based on this template using [degit](https://github.com/Rich-Harris/degit):
12+
13+
```bash
14+
npx degit sveltejs/template svelte-app
15+
cd svelte-app
16+
```
17+
18+
*Note that you will need to have [Node.js](https://nodejs.org) installed.*
19+
20+
21+
## Get started
22+
23+
Install the dependencies...
24+
25+
```bash
26+
cd svelte-app
27+
npm install
28+
```
29+
30+
...then start [Rollup](https://rollupjs.org):
31+
32+
```bash
33+
npm run dev
34+
```
35+
36+
Navigate to [localhost:8080](http://localhost:8080). You should see your app running. Edit a component file in `src`, save it, and reload the page to see your changes.
37+
38+
By default, the server will only respond to requests from localhost. To allow connections from other computers, edit the `sirv` commands in package.json to include the option `--host 0.0.0.0`.
39+
40+
If you're using [Visual Studio Code](https://code.visualstudio.com/) we recommend installing the official extension [Svelte for VS Code](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode). If you are using other editors you may need to install a plugin in order to get syntax highlighting and intellisense.
41+
42+
## Building and running in production mode
43+
44+
To create an optimised version of the app:
45+
46+
```bash
47+
npm run build
48+
```
49+
50+
You can run the newly built app with `npm run start`. This uses [sirv](https://github.com/lukeed/sirv), which is included in your package.json's `dependencies` so that the app will work when you deploy to platforms like [Heroku](https://heroku.com).
51+
52+
53+
## Single-page app mode
54+
55+
By default, sirv will only respond to requests that match files in `public`. This is to maximise compatibility with static fileservers, allowing you to deploy your app anywhere.
56+
57+
If you're building a single-page app (SPA) with multiple routes, sirv needs to be able to respond to requests for *any* path. You can make it so by editing the `"start"` command in package.json:
58+
59+
```js
60+
"start": "sirv public --single"
61+
```
62+
63+
## Using TypeScript
64+
65+
This template comes with a script to set up a TypeScript development environment, you can run it immediately after cloning the template with:
66+
67+
```bash
68+
node scripts/setupTypeScript.js
69+
```
70+
71+
Or remove the script via:
72+
73+
```bash
74+
rm scripts/setupTypeScript.js
75+
```
76+
77+
If you want to use `baseUrl` or `path` aliases within your `tsconfig`, you need to set up `@rollup/plugin-alias` to tell Rollup to resolve the aliases. For more info, see [this StackOverflow question](https://stackoverflow.com/questions/63427935/setup-tsconfig-path-in-svelte).
78+
79+
## Deploying to the web
80+
81+
### With [Vercel](https://vercel.com)
82+
83+
Install `vercel` if you haven't already:
84+
85+
```bash
86+
npm install -g vercel
87+
```
88+
89+
Then, from within your project folder:
90+
91+
```bash
92+
cd public
93+
vercel deploy --name my-project
94+
```
95+
96+
### With [surge](https://surge.sh/)
97+
98+
Install `surge` if you haven't already:
99+
100+
```bash
101+
npm install -g surge
102+
```
103+
104+
Then, from within your project folder:
105+
106+
```bash
107+
npm run build
108+
surge public my-project.surge.sh
109+
```

0 commit comments

Comments
 (0)