Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Commit

Permalink
Complete the repository
Browse files Browse the repository at this point in the history
  • Loading branch information
Futrime committed Mar 10, 2022
1 parent 203f365 commit b16c9ed
Show file tree
Hide file tree
Showing 23 changed files with 722 additions and 28 deletions.
27 changes: 1 addition & 26 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -173,29 +173,4 @@
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
END OF TERMS AND CONDITIONS
57 changes: 56 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,57 @@
# Shao-Pastebin
A website for storing and sharing any text online

SHAO Pastebin is a web app for storing and sharing any text online. This kind of websites are mainly used by programmers to share their code snippets, but anyone is welcome to paste any text.

## Features

* Fast
* Simple and lightweight
* Splitted frontend and backend
* Support Markdown
* Free and easy to deploy

## Getting Started

### Our Service

Don't you want to deploy on your own? Just visit [our website](https://pastebin.futrime.com) to use our public service!

### Server

#### Prerequisite
* A [SendGrid](https://sendgrid.com/) account (free account is OK)
* PHP version 7.0 or greater
* MySQL version 5.6 or greater (or any other compatible database)

#### Deployment
1. Register at [SendGrid](https://sendgrid.com/) and get the key for email sending
1. Create a MySQL compatible database
1. Import `/backend/pastebin.sql` to the database created
1. Modify configurations in `/backend/config.php` according to comments in the file
1. Upload all files except `/backend/pastebin.sql` in `/backend/` folder to your server

### Client

#### Prerequisite
* A SHAO-Pastebin server (you can use our server `https://api.paste.shao.fun` or `https://api.pastebin.594144.xyz` to test)
* A server to hold client program (you can run locally) or deployment services like Netlify and GitHub Pages
* For running locally, Node.js >= 12.x and npm >= 6.x is recommended

#### Deployment
You can run it locally by typing `npm test`. Then you can visit [localhost:8080](http://localhost:8080) to have a glance.

Meanwhile, you can set up a traditional web server like nginx and Caddy. And upload all files in root folder except `/backend/`.

We **RECOMMEND** deploying with GitHub Pages, for the best experience and the most reliability:
1. Fork this repository
1. Switch to branch `pages`
1. Modify the backend URL configuration in `/config.json`
1. Stash and commit the changes
1. Set up GitHub Pages:
1. Visit your forked repository on GitHub
1. Go to `Settings`->`Pages`
1. Select source branch `pages` and folder `/ (root)` and save
1. You can also add your custom domain

## License
SHAO Pastebin is released under Apache-2.0 License. See [the LICENSE file](https://github.com/Futrime/SHAO-Pastebin/blob/master/LICENSE) for more details
20 changes: 19 additions & 1 deletion backend/config.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
<?php
define('DB_HOST', 'localhost');

/**
* @license
* Copyright 2022 Futrime & M1saka10010
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

define('DB_HOST', 'Database address');
define('DB_USER', 'Database username');
define('DB_PASS', 'Database password');
define('DB_NAME', 'Database name');
Expand Down
17 changes: 17 additions & 0 deletions backend/functions/db.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
<?php

/**
* @license
* Copyright 2022 Futrime & M1saka10010
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

$db_host = DB_HOST;
$db_user = DB_USER;
$db_pass = DB_PASS;
Expand Down
18 changes: 18 additions & 0 deletions backend/functions/function.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
<?php

/**
* @license
* Copyright 2022 Futrime & M1saka10010
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

function cook_salt()
{
$chars = array_merge(range('A', 'Z'), range('a', 'z'), range('0', '9'));
Expand Down
18 changes: 18 additions & 0 deletions backend/pastebin.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
<?php

/**
* @license
* Copyright 2022 Futrime & M1saka10010
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

include 'config.php';
include 'functions/db.php';
include 'functions/function.php';
Expand Down
17 changes: 17 additions & 0 deletions backend/pastebin.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/**
* @license
* Copyright 2022 Futrime & M1saka10010
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

-- phpMyAdmin SQL Dump
-- version 5.0.4
-- https://www.phpmyadmin.net/
Expand Down
18 changes: 18 additions & 0 deletions backend/user.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
<?php

/**
* @license
* Copyright 2022 Futrime & M1saka10010
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

include 'config.php';
include 'functions/db.php';
include 'functions/function.php';
Expand Down
15 changes: 15 additions & 0 deletions create.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
<!--
Copyright 2022 Futrime & M1saka10010
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE html>
<html lang="zh">

Expand Down
15 changes: 15 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
<!--
Copyright 2022 Futrime & M1saka10010
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE html>
<html lang="zh">

Expand Down
17 changes: 17 additions & 0 deletions js/create.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/**
* @license
* Copyright 2022 Futrime & M1saka10010
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { postData } from './include.mjs'


Expand Down
17 changes: 17 additions & 0 deletions js/include.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/**
* @license
* Copyright 2022 Futrime & M1saka10010
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

const config = await (async () => {
const res = await fetch('config.json');
const obj = await res.json();
Expand Down
17 changes: 17 additions & 0 deletions js/index.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/**
* @license
* Copyright 2022 Futrime & M1saka10010
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { postData } from './include.mjs'


Expand Down
17 changes: 17 additions & 0 deletions js/list.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/**
* @license
* Copyright 2022 Futrime & M1saka10010
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { postData } from './include.mjs'


Expand Down
17 changes: 17 additions & 0 deletions js/sign-up.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/**
* @license
* Copyright 2022 Futrime & M1saka10010
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { isValidEmail, postData } from './include.mjs'


Expand Down
17 changes: 17 additions & 0 deletions js/user.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/**
* @license
* Copyright 2022 Futrime & M1saka10010
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { isValidEmail, postData } from './include.mjs'


Expand Down
Loading

0 comments on commit b16c9ed

Please sign in to comment.