@cocreate/server-side-render 1.0.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.
- package/.github/FUNDING.yml +3 -0
- package/.github/workflows/automated.yml +83 -0
- package/.github/workflows/manual.yml +44 -0
- package/CHANGELOG.md +6 -0
- package/CONTRIBUTING.md +97 -0
- package/CoCreate.config.js +43 -0
- package/LICENSE +21 -0
- package/README.md +84 -0
- package/demo/index.html +28 -0
- package/docs/index.html +126 -0
- package/package.json +69 -0
- package/release.config.js +22 -0
- package/src/index.js +76 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
name: Automated
|
|
2
|
+
"on":
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- master
|
|
6
|
+
jobs:
|
|
7
|
+
about:
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
steps:
|
|
10
|
+
- name: Checkout
|
|
11
|
+
uses: actions/checkout@v2
|
|
12
|
+
- name: Jaid/action-sync-node-meta
|
|
13
|
+
uses: jaid/action-sync-node-meta@v1.4.0
|
|
14
|
+
with:
|
|
15
|
+
direction: overwrite-github
|
|
16
|
+
githubToken: "${{ secrets.GITHUB }}"
|
|
17
|
+
release:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
steps:
|
|
20
|
+
- name: Checkout
|
|
21
|
+
uses: actions/checkout@v2
|
|
22
|
+
- name: Semantic Release
|
|
23
|
+
uses: cycjimmy/semantic-release-action@v2
|
|
24
|
+
id: semantic
|
|
25
|
+
with:
|
|
26
|
+
extra_plugins: |
|
|
27
|
+
@semantic-release/changelog
|
|
28
|
+
@semantic-release/git
|
|
29
|
+
@semantic-release/github
|
|
30
|
+
env:
|
|
31
|
+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
|
32
|
+
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
|
|
33
|
+
outputs:
|
|
34
|
+
new_release_published: "${{ steps.semantic.outputs.new_release_published }}"
|
|
35
|
+
new_release_version: "${{ steps.semantic.outputs.new_release_version }}"
|
|
36
|
+
cdn:
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
needs: release
|
|
39
|
+
if: needs.release.outputs.new_release_published == 'true'
|
|
40
|
+
env:
|
|
41
|
+
VERSION: "${{ needs.release.outputs.new_release_version }}"
|
|
42
|
+
steps:
|
|
43
|
+
- name: Checkout
|
|
44
|
+
uses: actions/checkout@v2
|
|
45
|
+
- name: setup nodejs
|
|
46
|
+
uses: actions/setup-node@v2
|
|
47
|
+
with:
|
|
48
|
+
node-version: 14.15.4
|
|
49
|
+
- name: yarn install
|
|
50
|
+
run: >
|
|
51
|
+
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >
|
|
52
|
+
.npmrc
|
|
53
|
+
|
|
54
|
+
yarn install
|
|
55
|
+
- name: yarn build
|
|
56
|
+
run: yarn build
|
|
57
|
+
- name: upload bundle as version
|
|
58
|
+
uses: CoCreate-app/CoCreate-s3@master
|
|
59
|
+
with:
|
|
60
|
+
aws-key-id: "${{ secrets.AWSACCESSKEYID }}"
|
|
61
|
+
aws-access-key: "${{ secrets.AWSSECERTACCESSKEY }}"
|
|
62
|
+
bucket: testcrudbucket
|
|
63
|
+
source: ./dist
|
|
64
|
+
destination: "/server-side-render/${{env.VERSION}}"
|
|
65
|
+
acl: public-read
|
|
66
|
+
- name: upload bundle as latest
|
|
67
|
+
uses: CoCreate-app/CoCreate-s3@master
|
|
68
|
+
with:
|
|
69
|
+
aws-key-id: "${{ secrets.AWSACCESSKEYID }}"
|
|
70
|
+
aws-access-key: "${{ secrets.AWSSECERTACCESSKEY }}"
|
|
71
|
+
bucket: testcrudbucket
|
|
72
|
+
source: ./dist
|
|
73
|
+
destination: /server-side-render/latest
|
|
74
|
+
acl: public-read
|
|
75
|
+
invalidations: true
|
|
76
|
+
docs:
|
|
77
|
+
runs-on: ubuntu-latest
|
|
78
|
+
steps:
|
|
79
|
+
- name: Checkout
|
|
80
|
+
uses: actions/checkout@v2
|
|
81
|
+
|
|
82
|
+
- name: update documentation
|
|
83
|
+
uses: CoCreate-app/CoCreate-docs@master
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
name: Manual Workflow
|
|
2
|
+
on:
|
|
3
|
+
workflow_dispatch:
|
|
4
|
+
inputs:
|
|
5
|
+
invalidations:
|
|
6
|
+
description: |
|
|
7
|
+
If set to 'true', invalidates previous upload.
|
|
8
|
+
default: "true"
|
|
9
|
+
required: true
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
cdn:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
env:
|
|
15
|
+
DRY_RUN: ${{ github.event.inputs.dry_run }}
|
|
16
|
+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
|
17
|
+
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- name: Checkout
|
|
21
|
+
uses: actions/checkout@v2
|
|
22
|
+
- name: setup nodejs
|
|
23
|
+
uses: actions/setup-node@v2
|
|
24
|
+
with:
|
|
25
|
+
node-version: 14.15.4
|
|
26
|
+
- name: yarn install
|
|
27
|
+
run: >
|
|
28
|
+
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >
|
|
29
|
+
.npmrc
|
|
30
|
+
|
|
31
|
+
yarn install
|
|
32
|
+
- name: yarn build
|
|
33
|
+
run: yarn build
|
|
34
|
+
- name: upload latest bundle
|
|
35
|
+
uses: CoCreate-app/CoCreate-s3@master
|
|
36
|
+
with:
|
|
37
|
+
aws-key-id: "${{ secrets.AWSACCESSKEYID }}"
|
|
38
|
+
aws-access-key: "${{ secrets.AWSSECERTACCESSKEY }}"
|
|
39
|
+
distributionId: "${{ secrets.DISTRIBUTION_ID }}"
|
|
40
|
+
bucket: testcrudbucket
|
|
41
|
+
source: ./dist
|
|
42
|
+
destination: /server-side-render/latest
|
|
43
|
+
acl: public-read
|
|
44
|
+
invalidations: ${{ github.event.inputs.invalidations }}
|
package/CHANGELOG.md
ADDED
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Contributing to CoCreate-server-side-render
|
|
2
|
+
|
|
3
|
+
This project is work of [many contributors](https://github.com/CoCreate-app/CoCreate-server-side-render/graphs/contributors).
|
|
4
|
+
You're encouraged to submit [pull requests](https://github.com/CoCreate-app/CoCreate-server-side-render/pulls),
|
|
5
|
+
[propose features and discuss issues](https://github.com/CoCreate-app/CoCreate-server-side-render/issues).
|
|
6
|
+
|
|
7
|
+
In the examples below, substitute your Github username for `contributor` in URLs.
|
|
8
|
+
|
|
9
|
+
## Fork the Project
|
|
10
|
+
|
|
11
|
+
Fork the [project on Github](https://github.com/CoCreate-app/CoCreate-server-side-render) and check out your copy.
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
git clone https://github.com/contributor/CoCreate-server-side-render.git
|
|
15
|
+
cd CoCreate-server-side-render
|
|
16
|
+
git remote add upstream https://github.com/CoCreate-app/CoCreate-server-side-render.git
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Create a Topic Branch
|
|
20
|
+
|
|
21
|
+
Make sure your fork is up-to-date and create a topic branch for your feature or bug fix on dev branch.
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
git checkout dev
|
|
25
|
+
git pull upstream dev
|
|
26
|
+
git checkout -b my-feature-branch
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Write Tests
|
|
30
|
+
|
|
31
|
+
Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build.
|
|
32
|
+
|
|
33
|
+
We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
|
|
34
|
+
|
|
35
|
+
## Write Code
|
|
36
|
+
|
|
37
|
+
Implement your feature or bug fix.
|
|
38
|
+
|
|
39
|
+
## Write Documentation
|
|
40
|
+
|
|
41
|
+
Document any external behavior in the [README](README.md).
|
|
42
|
+
|
|
43
|
+
## Commit Changes
|
|
44
|
+
|
|
45
|
+
Make sure git knows your name and email address:
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
git config --global user.name "Your Name"
|
|
49
|
+
git config --global user.email "contributor@example.com"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
We use [semantic-release](https://github.com/semantic-release/semantic-release) as process to generate changelog
|
|
53
|
+
and to release. Write meaningful commits according to
|
|
54
|
+
[Commit Message Formats](https://github.com/semantic-release/semantic-release#commit-message-format) is important.
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
git add ...
|
|
58
|
+
git commit -am "commit-type(optional topic): a meaningful message"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Here is an example of the release type that should be done based on a [semantic-release](https://github.com/semantic-release/semantic-release):
|
|
62
|
+
|
|
63
|
+
| Commit message | Release type |
|
|
64
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------- |
|
|
65
|
+
| `fix(pencil): stop graphite breaking when too much pressure applied` | Patch Release |
|
|
66
|
+
| `feat(pencil): add 'graphiteWidth' option` | ~~Minor~~ Feature Release |
|
|
67
|
+
| `perf(pencil): remove graphiteWidth option`<br><br>`BREAKING CHANGE: The graphiteWidth option has been removed.`<br>`The default graphite width of 10mm is always used for performance reasons.` | ~~Major~~ Breaking Release |
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
## Push
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
git push origin my-feature-branch
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Make a Pull Request
|
|
77
|
+
|
|
78
|
+
Go to [https://github.com/CoCreate-app/CoCreate-server-side-render](https://github.com/CoCreate-app/CoCreate-server-side-render) and select your feature branch.
|
|
79
|
+
Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
|
|
80
|
+
|
|
81
|
+
## Rebase
|
|
82
|
+
|
|
83
|
+
If you've been working on a change for a while, rebase with upstream/dev.
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
git fetch upstream
|
|
87
|
+
git rebase upstream/dev
|
|
88
|
+
git push origin my-feature-branch -f
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Be Patient
|
|
92
|
+
|
|
93
|
+
It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang in there!
|
|
94
|
+
|
|
95
|
+
## Thank You
|
|
96
|
+
|
|
97
|
+
Please do know that we really appreciate and value your time and work. We love you, really.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
"config": {
|
|
3
|
+
"apiKey": "2061acef-0451-4545-f754-60cf8160",
|
|
4
|
+
"organization_Id": "5ff747727005da1c272740ab",
|
|
5
|
+
"host": "general.cocreate.app"
|
|
6
|
+
},
|
|
7
|
+
|
|
8
|
+
"sources": [{
|
|
9
|
+
"entry": "./docs/index.html",
|
|
10
|
+
"collection": "files",
|
|
11
|
+
"document_id": "60145dc49f64ba1680b86693",
|
|
12
|
+
"key": "src",
|
|
13
|
+
"data":{
|
|
14
|
+
"name": "index.html",
|
|
15
|
+
"path": "/docs/server-side-render/index.html",
|
|
16
|
+
"domains": [
|
|
17
|
+
"cocreate.app",
|
|
18
|
+
"general.cocreate.app"
|
|
19
|
+
],
|
|
20
|
+
"directory": "/docs/server-side-render",
|
|
21
|
+
"content-type": "text/html",
|
|
22
|
+
"public": "true",
|
|
23
|
+
"website_id": "5ffbceb7f11d2d00103c4535"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
|
|
28
|
+
"extract": {
|
|
29
|
+
"directory": "./src/",
|
|
30
|
+
"extensions": [
|
|
31
|
+
"js",
|
|
32
|
+
"css",
|
|
33
|
+
"html"
|
|
34
|
+
],
|
|
35
|
+
"ignores": [
|
|
36
|
+
"node_modules",
|
|
37
|
+
"vendor",
|
|
38
|
+
"bower_components",
|
|
39
|
+
"archive"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 CoCreate LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# CoCreate-server-side-render
|
|
2
|
+
|
|
3
|
+
A simple server-side-render component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API. Take it for a spin in our [playground!](https://cocreate.app/docs/server-side-render)
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
## [Docs & Demo](https://cocreate.app/docs/server-side-render)
|
|
16
|
+
|
|
17
|
+
For a complete guide and working demo refer to the [doumentation](https://cocreate.app/docs/server-side-render)
|
|
18
|
+
|
|
19
|
+
## CDN
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<script src="https://cdn.cocreate.app/server-side-render/latest/CoCreate-server-side-render.min.js"></script>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```html
|
|
26
|
+
<script src="https://cdn.cocreate.app/server-side-render/latest/CoCreate-server-side-render.min.css"></script>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## NPM
|
|
30
|
+
|
|
31
|
+
```shell
|
|
32
|
+
$ npm i @cocreate/server-side-render
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## yarn
|
|
36
|
+
|
|
37
|
+
```shell
|
|
38
|
+
$ yarn install @cocreate/server-side-render
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
# Table of Contents
|
|
42
|
+
|
|
43
|
+
- [Table of Contents](#table-of-contents)
|
|
44
|
+
- [Announcements](#announcements)
|
|
45
|
+
- [Roadmap](#roadmap)
|
|
46
|
+
- [How to Contribute](#how-to-contribute)
|
|
47
|
+
- [About](#about)
|
|
48
|
+
- [License](#license)
|
|
49
|
+
|
|
50
|
+
<a name="announcements"></a>
|
|
51
|
+
|
|
52
|
+
# Announcements
|
|
53
|
+
|
|
54
|
+
All updates to this library are documented in our [CHANGELOG](https://github.com/CoCreate-app/CoCreate-server-side-render/blob/master/CHANGELOG.md) and [releases](https://github.com/CoCreate-app/CoCreate-server-side-render/releases). You may also subscribe to email for releases and breaking changes.
|
|
55
|
+
|
|
56
|
+
<a name="roadmap"></a>
|
|
57
|
+
|
|
58
|
+
# Roadmap
|
|
59
|
+
|
|
60
|
+
If you are interested in the future direction of this project, please take a look at our open [issues](https://github.com/CoCreate-app/CoCreate-server-side-render/issues) and [pull requests](https://github.com/CoCreate-app/CoCreate-server-side-render/pulls). We would love to hear your feedback.
|
|
61
|
+
|
|
62
|
+
<a name="about"></a>
|
|
63
|
+
|
|
64
|
+
# About
|
|
65
|
+
|
|
66
|
+
CoCreate-server-side-render is guided and supported by the CoCreate Developer Experience Team.
|
|
67
|
+
|
|
68
|
+
Please Email the Developer Experience Team [here](mailto:develop@cocreate.app) in case of any queries.
|
|
69
|
+
|
|
70
|
+
CoCreate-server-side-render is maintained and funded by CoCreate. The names and logos for CoCreate are trademarks of CoCreate, LLC.
|
|
71
|
+
|
|
72
|
+
<a name="contribute"></a>
|
|
73
|
+
|
|
74
|
+
# How to Contribute
|
|
75
|
+
|
|
76
|
+
We encourage contribution to our libraries (you might even score some nifty swag), please see our [CONTRIBUTING](https://github.com/CoCreate-app/CoCreate-server-side-render/blob/master/CONTRIBUTING.md) guide for details.
|
|
77
|
+
|
|
78
|
+
We want this library to be community-driven, and CoCreate led. We need your help to realize this goal. To help make sure we are building the right things in the right order, we ask that you create [issues](https://github.com/CoCreate-app/CoCreate-server-side-render/issues) and [pull requests](https://github.com/CoCreate-app/CoCreate-server-side-render/pulls) or merely upvote or comment on existing issues or pull requests.
|
|
79
|
+
|
|
80
|
+
We appreciate your continued support, thank you!
|
|
81
|
+
|
|
82
|
+
# License
|
|
83
|
+
|
|
84
|
+
[The MIT License (MIT)](https://github.com/CoCreate-app/CoCreate-server-side-render/blob/master/LICENSE)
|
package/demo/index.html
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
8
|
+
<link rel="icon" href="https://cdn.cocreate.app/favicon.ico" type="image/ico" sizes="16x16">
|
|
9
|
+
<title>server-side-render | CoCreateJS</title>
|
|
10
|
+
</head>
|
|
11
|
+
|
|
12
|
+
<body>
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
<script>
|
|
16
|
+
var config = {
|
|
17
|
+
apiKey: '',
|
|
18
|
+
organization_Id: '',
|
|
19
|
+
host: ''
|
|
20
|
+
}
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<!--<script src="https://cdn.cocreate.app/server-side-render/latest/CoCreate-server-side-render.min.js"></script>-->
|
|
24
|
+
<script src="../../../CoCreateJS/dist/CoCreate.js"></script>
|
|
25
|
+
|
|
26
|
+
</body>
|
|
27
|
+
|
|
28
|
+
</html>
|
package/docs/index.html
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
7
|
+
<title>CoCreate-server-side-render Documentation | CoCreateJS </title>
|
|
8
|
+
<link rel="icon" type="image/png" sizes="32x32" href="https://cocreate.app/images/favicon.ico">
|
|
9
|
+
<meta name="description" content="A simple HTML5 and pure javascript component. Easy configuration using data-attributes and highly styleable." />
|
|
10
|
+
<meta name="keywords" content="helper classes, utility classes, css framework, css library, inline style classes" />
|
|
11
|
+
<meta name="robots" content="index,follow" />
|
|
12
|
+
|
|
13
|
+
<!-- CoCreate CSS CDN -->
|
|
14
|
+
<link rel="stylesheet" href="https://cdn.cocreate.app/latest/CoCreate.min.css" type="text/css" />
|
|
15
|
+
|
|
16
|
+
</head>
|
|
17
|
+
|
|
18
|
+
<body>
|
|
19
|
+
<div collection="" document_id="" name="" id="cocreate-server-side-render">
|
|
20
|
+
<div class="display:flex flex-wrap:wrap justify-content:space-between margin:10px">
|
|
21
|
+
<div class="display:flex align-items:center">
|
|
22
|
+
<h2>CoCreate-server-side-render</h2>
|
|
23
|
+
</div>
|
|
24
|
+
<div class="display:flex align-items:center font-size:20px" share-height="600" share-width="500" share-media="https://via.placeholder.com/300/09f/fff.png">
|
|
25
|
+
<a href="https://github.com/CoCreate-app/CoCreate-server-side-render" target="_blank" class="margin-right:15px"><i class="fab fa-github"></i></a>
|
|
26
|
+
<a class="margin-right:15px share" share-network='twitter' title="Share on twitter"><i class="fab fa-twitter"></i></a>
|
|
27
|
+
<a class="margin-right:15px share" share-network='facebook' title="Share on Facebook"><i class="fab fa-facebook"></i></a>
|
|
28
|
+
<a class="margin-right:15px share" share-network='instagram' title="Share on instagram"><i class="fab fa-instagram"></i></a>
|
|
29
|
+
<a class="margin-right:15px share" share-network='share' title="Share on share"><i class="fas fa-share-alt"></i></a>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
<p class="max-width:500px margin:20px_10px">A simple HTML5, CSS and pure javascript component. Easy configuration using data-attributes and highly styleable.</h1>
|
|
33
|
+
<div id="server-side-render-section" class="display:flex flex-wrap:wrap">
|
|
34
|
+
<div class="flex-grow:1 width:300px padding:20px_10px">
|
|
35
|
+
<h2 class="border-bottom:1px_solid_lightgrey padding:5px_0px">Install</h2>
|
|
36
|
+
<pre class="margin-top:15px"><code class="language-javascript">npm install cocreate-server-side-render</code></pre>
|
|
37
|
+
<p class="padding:10px_0px">Or you can use cdn link:</p>
|
|
38
|
+
<pre><code class="language-javascript">https://cdn.cocreate.app/js/CoCreate-server-side-render.min.js</code></pre>
|
|
39
|
+
|
|
40
|
+
<h2 class="border-bottom:1px_solid_lightgrey margin-top:20px padding:5px_0px">Usage</h2>
|
|
41
|
+
<p class="padding:10px_0px">server-side-render usage content</p>
|
|
42
|
+
<pre><code class="language-html"><div></div></code></pre>
|
|
43
|
+
|
|
44
|
+
<h2 class="border-bottom:1px_solid_lightgrey margin-top:20px padding:5px_0px">Reference</h2>
|
|
45
|
+
<p class="padding:10px_0px">This is server-side-render reference content</p>
|
|
46
|
+
<pre><code class="language-javascript"><div></div></code></pre>
|
|
47
|
+
<p class="padding:10px_0px">This is server-side-render reference content</p>
|
|
48
|
+
|
|
49
|
+
<h2 class="border-bottom:1px_solid_lightgrey margin-top:20px padding:5px_0px">Attributes</h2>
|
|
50
|
+
<ul class="list-style-type:none ">
|
|
51
|
+
<li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
52
|
+
<h4><span>server-side-render</span> <span class="cocreate-badge success">string</span> <span class="cocreate-badge warning">optional</span></h4>
|
|
53
|
+
<p>server-side-render-attribute</p>
|
|
54
|
+
</li>
|
|
55
|
+
<li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
56
|
+
<h4><span>server-side-render</span> <span class="cocreate-badge success">string</span> <span class="cocreate-badge warning">optional</span></h4>
|
|
57
|
+
<p>server-side-render-attribute</p>
|
|
58
|
+
</li>
|
|
59
|
+
</ul>
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
<div class="flex-grow:1 width:300px padding:0px_10px margin:20px_0px border-bottom:1px_solid_lightgrey">
|
|
63
|
+
<!-- SandBox -->
|
|
64
|
+
<h2 class="border-bottom:1px_solid_lightgrey padding:5px_0px">Demo</h2>
|
|
65
|
+
<div class="position:sticky top:0 padding:10px_0px height:100vh">
|
|
66
|
+
<div class="container svColumn overflow:hidden card border-radius:2px width:auto height:100%" id="sandbox">
|
|
67
|
+
<div class="font-size:20px position:absolute top:10px right:10px opacity:0.6 z-index:7">
|
|
68
|
+
<a class="margin-right:10px" id="preview" show="preview" hide="code"><i class="far fa-eye"></i></a>
|
|
69
|
+
<a class="margin-right:10px hidden" id="code" show="code" hide="preview"><i class="fas fa-code"></i></a>
|
|
70
|
+
<!--<a class="margin-right:10px"><i class="far fa-window-maximize"></i></a>-->
|
|
71
|
+
<a target="modal" href="module_activity_datatable.html"
|
|
72
|
+
pass-collection="modules"
|
|
73
|
+
pass-document_id=""
|
|
74
|
+
pass-fetch_value=""
|
|
75
|
+
pass-prefix=""
|
|
76
|
+
pass-to="render"
|
|
77
|
+
modal-width="600px"
|
|
78
|
+
modal-height="400px"
|
|
79
|
+
modal-color="#229954"
|
|
80
|
+
modal-header="false"
|
|
81
|
+
class="margin-right:10px">
|
|
82
|
+
<i class="fas fa-external-link-alt"></i>
|
|
83
|
+
</a>
|
|
84
|
+
<a class="fs-toggle margin-right:5px" fullscreen target="#sandbox"><i class="fas fa-expand"></i></a>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<div class="svRow">
|
|
88
|
+
|
|
89
|
+
<div class="svColumn">
|
|
90
|
+
|
|
91
|
+
<div class="svPanel">
|
|
92
|
+
<div realtime="false"
|
|
93
|
+
collection="modules"
|
|
94
|
+
document_id="5eefe30952c6e94c75fb5e3f"
|
|
95
|
+
name="html"
|
|
96
|
+
id="7"
|
|
97
|
+
class="codemirror height:100% min-width:300px">
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
<div class="svSplitter svHorizontal"> </div>
|
|
101
|
+
|
|
102
|
+
<div class="svPanel">
|
|
103
|
+
<iframe get-value="7" frameBorder="0" height="100%" width="100%" class="min-width:300px"></iframe>
|
|
104
|
+
</div>
|
|
105
|
+
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
<!-- End SandBox -->
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
<script>
|
|
116
|
+
var config = {
|
|
117
|
+
apiKey: 'c2b08663-06e3-440c-ef6f-13978b42883a',
|
|
118
|
+
securityKey: 'f26baf68-e3a9-45fc-effe-502e47116265',
|
|
119
|
+
organization_Id: '5de0387b12e200ea63204d6c'
|
|
120
|
+
}
|
|
121
|
+
</script>
|
|
122
|
+
|
|
123
|
+
<!--CoCreateJS-->
|
|
124
|
+
<script src="https://server.cocreate.app/js/CoCreate.min.js"></script>
|
|
125
|
+
</body>
|
|
126
|
+
</html>
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cocreate/server-side-render",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A simple server-side-render component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"server-side-render",
|
|
7
|
+
"cocreate",
|
|
8
|
+
"low-code-framework",
|
|
9
|
+
"no-code-framework",
|
|
10
|
+
"cocreatejs",
|
|
11
|
+
"cocreatejs-component",
|
|
12
|
+
"cocreate-framework",
|
|
13
|
+
"no-code",
|
|
14
|
+
"low-code",
|
|
15
|
+
"collaborative-framework",
|
|
16
|
+
"realtime",
|
|
17
|
+
"realtime-framework",
|
|
18
|
+
"collaboration",
|
|
19
|
+
"shared-editing",
|
|
20
|
+
"html5-framework",
|
|
21
|
+
"javascript-framework"
|
|
22
|
+
],
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"start": "npx webpack --config webpack.config.js",
|
|
28
|
+
"build": "NODE_ENV=production npx webpack --config webpack.config.js",
|
|
29
|
+
"dev": "npx webpack --config webpack.config.js --watch",
|
|
30
|
+
"docs": "node ./node_modules/@cocreate/docs/src/index.js",
|
|
31
|
+
"hosting": "node ./node_modules/@cocreate/hosting/src/index.js"
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/CoCreate-app/CoCreate-server-side-render.git"
|
|
36
|
+
},
|
|
37
|
+
"author": "CoCreate LLC",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/CoCreate-app/CoCreate-server-side-render/issues"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://cocreate.app/docs/server-side-render",
|
|
43
|
+
"funding": {
|
|
44
|
+
"type": "GitHub Sponsors ❤",
|
|
45
|
+
"url": "https://github.com/sponsors/CoCreate-app"
|
|
46
|
+
},
|
|
47
|
+
"main": "./src/index.js",
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@babel/core": "^7.9.6",
|
|
50
|
+
"@babel/preset-env": "^7.9.6",
|
|
51
|
+
"babel-loader": "^8.1.0",
|
|
52
|
+
"clean-webpack-plugin": "^3.0.0",
|
|
53
|
+
"file-loader": "^6.2.0",
|
|
54
|
+
"html-webpack-plugin": "^4.5.0",
|
|
55
|
+
"mini-css-extract-plugin": "^1.5.0",
|
|
56
|
+
"style-loader": "^2.0.0",
|
|
57
|
+
"terser-webpack-plugin": "^5.1.1",
|
|
58
|
+
"uglifyjs-webpack-plugin": "^2.2.0",
|
|
59
|
+
"webpack": "^5.24.4",
|
|
60
|
+
"webpack-cli": "^4.5.0",
|
|
61
|
+
"webpack-log": "^3.0.1"
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"@cocreate/docs": "^1.2.26",
|
|
65
|
+
"@cocreate/hosting": "^1.2.22",
|
|
66
|
+
"mongodb": "^4.4.0",
|
|
67
|
+
"node-html-parser": "^5.2.0"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
dryRun: false,
|
|
3
|
+
branches: ["master"],
|
|
4
|
+
plugins: [
|
|
5
|
+
"@semantic-release/commit-analyzer",
|
|
6
|
+
"@semantic-release/release-notes-generator",
|
|
7
|
+
[
|
|
8
|
+
"@semantic-release/changelog",
|
|
9
|
+
{
|
|
10
|
+
changelogFile: "CHANGELOG.md",
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
"@semantic-release/npm",
|
|
14
|
+
"@semantic-release/github",
|
|
15
|
+
[
|
|
16
|
+
"@semantic-release/git",
|
|
17
|
+
{
|
|
18
|
+
assets: ["CHANGELOG.md", "package.json"],
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
],
|
|
22
|
+
};
|
package/src/index.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const { parse } = require("node-html-parser");
|
|
2
|
+
const { ObjectID } = require('mongodb');
|
|
3
|
+
|
|
4
|
+
const renderedIgnoreEl = { INPUT: true, TEXTAREA: true, SELECT: true, LINK: true, IFRAME: true, "COCREATE-SELECT": true };
|
|
5
|
+
|
|
6
|
+
module.exports = async function renderHtml(orgDB, html) {
|
|
7
|
+
|
|
8
|
+
let dep = [];
|
|
9
|
+
let dbCache = new Map();
|
|
10
|
+
|
|
11
|
+
async function render(html, lastKey) {
|
|
12
|
+
const dom = parse(html);
|
|
13
|
+
for (let el of dom.querySelectorAll(
|
|
14
|
+
"[collection][name][document_id]"
|
|
15
|
+
)) {
|
|
16
|
+
let meta = el.attributes;
|
|
17
|
+
|
|
18
|
+
if (renderedIgnoreEl[el.tagName])
|
|
19
|
+
continue;
|
|
20
|
+
|
|
21
|
+
if (el.tagName == "DIV" && !el.classList.contains('domEditor'))
|
|
22
|
+
continue;
|
|
23
|
+
|
|
24
|
+
if (el.classList.contains('domEditor') && el.closest('.template'))
|
|
25
|
+
continue;
|
|
26
|
+
|
|
27
|
+
if (el.hasAttribute('actions'))
|
|
28
|
+
continue;
|
|
29
|
+
|
|
30
|
+
let id = meta["document_id"],
|
|
31
|
+
coll = meta['collection'],
|
|
32
|
+
name = meta['name'];
|
|
33
|
+
let key = id + coll + name;
|
|
34
|
+
if (!id || !name || !coll) continue;
|
|
35
|
+
if (dep.includes(key))
|
|
36
|
+
throw new Error(
|
|
37
|
+
`infinite loop: ${lastKey} ${id} ${coll} ${name} has been already rendered`
|
|
38
|
+
);
|
|
39
|
+
else
|
|
40
|
+
dep.push(key)
|
|
41
|
+
|
|
42
|
+
let cacheKey = id + coll;
|
|
43
|
+
let record;
|
|
44
|
+
if (dbCache.has(cacheKey))
|
|
45
|
+
record = dbCache.get(cacheKey)
|
|
46
|
+
else {
|
|
47
|
+
let collection = orgDB.collection(coll)
|
|
48
|
+
record = await collection.findOne({"_id": new ObjectID(id)});
|
|
49
|
+
dbCache.set(cacheKey, record)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (!record || !record[name]) {
|
|
53
|
+
dep.pop();
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
let chunk = record[name];
|
|
57
|
+
if (!chunk) {
|
|
58
|
+
|
|
59
|
+
dep.pop();
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
let dom = await render(chunk);
|
|
63
|
+
|
|
64
|
+
el.setAttribute('rendered', '')
|
|
65
|
+
el.innerHTML = "";
|
|
66
|
+
el.appendChild(dom);
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
dep.pop();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return dom;
|
|
73
|
+
}
|
|
74
|
+
let result = (await render(html, 'root')).toString();
|
|
75
|
+
return result;
|
|
76
|
+
}
|