sora 24.02.25 → 24.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +22 -19
- data/CHANGELOG.md +5 -5
- data/CODE_OF_CONDUCT.md +84 -84
- data/LICENSE.txt +21 -21
- data/README.ja.md +69 -0
- data/README.md +48 -4
- data/Rakefile +12 -8
- data/cgi-bin/get.rb +73 -0
- data/cgi-bin/main.rb +100 -8
- data/data/.gitignore +2 -1
- data/docs/get-ipaddr.png +0 -0
- data/docs/screenshot.png +0 -0
- data/exe/sora +2 -2
- data/lib/sora/version.rb +5 -5
- data/lib/sora.rb +4 -2
- data/package.json +18 -0
- data/sig/sora.rbs +4 -4
- data/src/index.ts +364 -0
- data/src/style.css +157 -0
- data/tsconfig.json +11 -0
- data/webpack.config.js +25 -0
- data/www/bundle.js +1346 -0
- data/www/index.html +33 -13
- data/www/main.js +123 -6
- data/www/style.css +89 -20
- data/yarn.lock +1073 -0
- metadata +28 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b5ced9f96a91bad46179bfd6c2cb86390ef87c80a43e986c02981a13327de16
|
4
|
+
data.tar.gz: 0b58886bafd8d8030b0262846a74da0747688bcd7719b48a88070e0c46173174
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25bd597229224b8d3971ca8492d17cec5c24e27e18dede006bde0e5627f17c07a85f222f9d9488e5da46a94811fccbfa05a56eeb2d66507bd0dd4d1359c8a736
|
7
|
+
data.tar.gz: 3e935a72f597d2ca57907625f94059886f2e5390f1c97733ee4041592801886227a8ade6ee1ea3d326cce0321233f8394c6052ccfcf17ea284895139c9f3078a
|
data/.rubocop.yml
CHANGED
@@ -1,19 +1,22 @@
|
|
1
|
-
AllCops:
|
2
|
-
TargetRubyVersion: 2.6
|
3
|
-
|
4
|
-
Style/StringLiterals:
|
5
|
-
Enabled: true
|
6
|
-
EnforcedStyle: double_quotes
|
7
|
-
|
8
|
-
Style/StringLiteralsInInterpolation:
|
9
|
-
Enabled: true
|
10
|
-
EnforcedStyle: double_quotes
|
11
|
-
|
12
|
-
Layout/LineLength:
|
13
|
-
Max: 120
|
14
|
-
|
15
|
-
Layout/EndOfLine:
|
16
|
-
Enabled: False
|
17
|
-
|
18
|
-
Metrics/MethodLength:
|
19
|
-
Enabled: False
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.6
|
3
|
+
|
4
|
+
Style/StringLiterals:
|
5
|
+
Enabled: true
|
6
|
+
EnforcedStyle: double_quotes
|
7
|
+
|
8
|
+
Style/StringLiteralsInInterpolation:
|
9
|
+
Enabled: true
|
10
|
+
EnforcedStyle: double_quotes
|
11
|
+
|
12
|
+
Layout/LineLength:
|
13
|
+
Max: 120
|
14
|
+
|
15
|
+
Layout/EndOfLine:
|
16
|
+
Enabled: False
|
17
|
+
|
18
|
+
Metrics/MethodLength:
|
19
|
+
Enabled: False
|
20
|
+
|
21
|
+
Metrics/AbcSize:
|
22
|
+
Enabled: False
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
## [Unreleased]
|
2
|
-
|
3
|
-
## [0.1.0] - 2024-02-24
|
4
|
-
|
5
|
-
- Initial release
|
1
|
+
## [Unreleased]
|
2
|
+
|
3
|
+
## [0.1.0] - 2024-02-24
|
4
|
+
|
5
|
+
- Initial release
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -1,84 +1,84 @@
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
2
|
-
|
3
|
-
## Our Pledge
|
4
|
-
|
5
|
-
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
-
|
7
|
-
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
-
|
9
|
-
## Our Standards
|
10
|
-
|
11
|
-
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
-
|
13
|
-
* Demonstrating empathy and kindness toward other people
|
14
|
-
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
-
* Giving and gracefully accepting constructive feedback
|
16
|
-
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
-
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
-
|
19
|
-
Examples of unacceptable behavior include:
|
20
|
-
|
21
|
-
* The use of sexualized language or imagery, and sexual attention or
|
22
|
-
advances of any kind
|
23
|
-
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
-
* Public or private harassment
|
25
|
-
* Publishing others' private information, such as a physical or email
|
26
|
-
address, without their explicit permission
|
27
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
-
professional setting
|
29
|
-
|
30
|
-
## Enforcement Responsibilities
|
31
|
-
|
32
|
-
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
-
|
34
|
-
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
-
|
36
|
-
## Scope
|
37
|
-
|
38
|
-
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
-
|
40
|
-
## Enforcement
|
41
|
-
|
42
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at TODO: Write your email address. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
-
|
44
|
-
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
-
|
46
|
-
## Enforcement Guidelines
|
47
|
-
|
48
|
-
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
-
|
50
|
-
### 1. Correction
|
51
|
-
|
52
|
-
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
-
|
54
|
-
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
-
|
56
|
-
### 2. Warning
|
57
|
-
|
58
|
-
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
-
|
60
|
-
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
-
|
62
|
-
### 3. Temporary Ban
|
63
|
-
|
64
|
-
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
-
|
66
|
-
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
-
|
68
|
-
### 4. Permanent Ban
|
69
|
-
|
70
|
-
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
-
|
72
|
-
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
-
|
74
|
-
## Attribution
|
75
|
-
|
76
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
-
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
-
|
79
|
-
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
-
|
81
|
-
[homepage]: https://www.contributor-covenant.org
|
82
|
-
|
83
|
-
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
-
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at TODO: Write your email address. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/LICENSE.txt
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2024 TODO: Write your name
|
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
|
13
|
-
all 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
|
21
|
-
THE SOFTWARE.
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 TODO: Write your name
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.ja.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# sora
|
2
|
+
[![Ruby](https://github.com/Himeyama/sora/actions/workflows/main.yml/badge.svg)](https://github.com/Himeyama/sora/actions/workflows/main.yml)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/sora.svg)](https://badge.fury.io/rb/sora)
|
4
|
+
|
5
|
+
> ![sora](docs/screenshot.png)
|
6
|
+
|
7
|
+
sora は文字列やファイルを送受信できる Ruby 製 http サーバです。
|
8
|
+
|
9
|
+
sora (Server Of Ruby for Access) は、ファイルの送受信や、文字列を送信して情報を伝達することができます。
|
10
|
+
|
11
|
+
- https://rubygems.org/gems/sora
|
12
|
+
|
13
|
+
## インストール
|
14
|
+
この gem は Windows と Linux で動作確認をしています。
|
15
|
+
|
16
|
+
### インストール方法
|
17
|
+
```ps1
|
18
|
+
gem install sora
|
19
|
+
```
|
20
|
+
|
21
|
+
または
|
22
|
+
|
23
|
+
```ps1
|
24
|
+
rake install # リポジトリからインストールする
|
25
|
+
```
|
26
|
+
|
27
|
+
## sora とは
|
28
|
+
sora はインストールされたマシンでサーバーを立ち上げる。
|
29
|
+
そのマシンにLAN 内にあるスマホや他のマシンからアクセスすることで文字列やファイルを共有できます。
|
30
|
+
|
31
|
+
次のコマンドは、sora サーバーを 8001 ポートで立ち上げるコマンドです。
|
32
|
+
|
33
|
+
```ps1
|
34
|
+
sora -p 8080 # または: sora
|
35
|
+
```
|
36
|
+
|
37
|
+
次にブラウザで、sora にアクセスしてみましょう。
|
38
|
+
|
39
|
+
sora をインストールしたマシンでは、以下の url から sora にアクセスできます。
|
40
|
+
|
41
|
+
[http://127.0.0.1:8080/](http://127.0.0.1:8080/)
|
42
|
+
|
43
|
+
他の端末からはインストールしたマシンの IP アドレスを取得してアクセスします。
|
44
|
+
IP アドレスは Windows の「設定」から確認可能で、「IPv4 アドレス」が対象の IP アドレスです。
|
45
|
+
コンソールで `ipconfig` を実行して確認してもよいです。
|
46
|
+
|
47
|
+
![get ipv4](docs/get-ipaddr.png)
|
48
|
+
|
49
|
+
## 開発
|
50
|
+
以下、開発者向けの説明です。
|
51
|
+
|
52
|
+
- Windows
|
53
|
+
- Ruby 3.2.3
|
54
|
+
|
55
|
+
### 依存パッケージのインストール
|
56
|
+
```ps1
|
57
|
+
bundle install
|
58
|
+
```
|
59
|
+
|
60
|
+
### アプリの実行
|
61
|
+
```ps1
|
62
|
+
bundle exec sora
|
63
|
+
```
|
64
|
+
|
65
|
+
### Webpack でスクリプトをコンパイル
|
66
|
+
```ps1
|
67
|
+
rake build:webpack
|
68
|
+
```
|
69
|
+
|
data/README.md
CHANGED
@@ -1,4 +1,48 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
# sora
|
2
|
+
[![Ruby](https://github.com/Himeyama/sora/actions/workflows/main.yml/badge.svg)](https://github.com/Himeyama/sora/actions/workflows/main.yml)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/sora.svg)](https://badge.fury.io/rb/sora)
|
4
|
+
|
5
|
+
> ![sora](docs/screenshot.png)
|
6
|
+
|
7
|
+
[日本語の README](/README.ja.md)
|
8
|
+
|
9
|
+
sora is an http server in Ruby that can send and receive strings and files.
|
10
|
+
|
11
|
+
sora (Server Of Ruby for Access) can send and receive files, and transmit text strings to communicate information.
|
12
|
+
|
13
|
+
- https://rubygems.org/gems/sora
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
This gem is supported on Windows and Linux.
|
17
|
+
|
18
|
+
### How to Install
|
19
|
+
```ps1
|
20
|
+
gem install sora
|
21
|
+
```
|
22
|
+
|
23
|
+
or
|
24
|
+
|
25
|
+
```ps1
|
26
|
+
rake install # Install from repository
|
27
|
+
```
|
28
|
+
|
29
|
+
## About sora
|
30
|
+
Sola sets up a server on the installed machine. Strings and files can be shared by accessing that machine from smartphones or other machines in the LAN.
|
31
|
+
|
32
|
+
The following command will bring up the sora server on port 8080.
|
33
|
+
|
34
|
+
```ps1
|
35
|
+
sora -p 8080 # or: sora
|
36
|
+
```
|
37
|
+
|
38
|
+
Next, let's access sora with a browser.
|
39
|
+
|
40
|
+
On a machine with sora installed, you can access sora from the following url.
|
41
|
+
|
42
|
+
[http://127.0.0.1:8080/](http://127.0.0.1:8080/)
|
43
|
+
|
44
|
+
From other terminals, the IP address of the installed machine is obtained and accessed.
|
45
|
+
The IP address can be checked from the Windows `Settings`, where `IPv4 address` is the target IP address.
|
46
|
+
You can also check it by running `ipconfig` in the console.
|
47
|
+
|
48
|
+
![get ipv4](docs/get-ipaddr.png)
|
data/Rakefile
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "bundler/gem_tasks"
|
4
|
-
require "rubocop/rake_task"
|
5
|
-
|
6
|
-
RuboCop::RakeTask.new
|
7
|
-
|
8
|
-
task default: :rubocop
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rubocop/rake_task"
|
5
|
+
|
6
|
+
RuboCop::RakeTask.new
|
7
|
+
|
8
|
+
task default: :rubocop
|
9
|
+
|
10
|
+
task "build:webpack" do
|
11
|
+
sh "yarn --cwd src run webpack --mode production -o www -w"
|
12
|
+
end
|
data/cgi-bin/get.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "cgi"
|
4
|
+
require "json"
|
5
|
+
require "securerandom"
|
6
|
+
|
7
|
+
def get_content_type(filename)
|
8
|
+
content_types = {
|
9
|
+
".txt" => "text/plain",
|
10
|
+
".json" => "application/json",
|
11
|
+
".js" => "text/javascript",
|
12
|
+
".css" => "text/css",
|
13
|
+
".csv" => "text/csv",
|
14
|
+
".pdf" => "application/pdf",
|
15
|
+
".xls" => "application/vnd.ms-excel",
|
16
|
+
".xlsx" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
17
|
+
".doc" => "application/msword",
|
18
|
+
".docx" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
19
|
+
".ppt" => "application/vnd.ms-powerpoint",
|
20
|
+
".pptx" => "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
21
|
+
".gif" => "image/gif",
|
22
|
+
".bmp" => "image/bmp",
|
23
|
+
".svg" => "image/svg+xml",
|
24
|
+
".zip" => "application/zip",
|
25
|
+
".lzh" => "application/x-lzh",
|
26
|
+
".tar" => "application/x-tar",
|
27
|
+
".mp3" => "audio/mpeg",
|
28
|
+
".mp4" => "video/mp4",
|
29
|
+
".mpeg" => "video/mpeg",
|
30
|
+
".jpg" => "image/jpeg",
|
31
|
+
".jpeg" => "image/jpeg",
|
32
|
+
".png" => "image/png",
|
33
|
+
".html" => "text/html"
|
34
|
+
}
|
35
|
+
|
36
|
+
ext = File.extname(filename)
|
37
|
+
content_types[ext] || "text/html"
|
38
|
+
end
|
39
|
+
|
40
|
+
#
|
41
|
+
# ファイルを取得
|
42
|
+
#
|
43
|
+
# GET: /get?filename=image.png
|
44
|
+
#
|
45
|
+
def file
|
46
|
+
cgi = CGI.new
|
47
|
+
params = cgi.params
|
48
|
+
unless params.key?("filename")
|
49
|
+
print cgi.header("application/json")
|
50
|
+
print(JSON.pretty_generate({ status: "NG" }))
|
51
|
+
return
|
52
|
+
end
|
53
|
+
|
54
|
+
if params["filename"].empty?
|
55
|
+
print cgi.header("application/json")
|
56
|
+
print(JSON.pretty_generate({ status: "NG" }))
|
57
|
+
return
|
58
|
+
end
|
59
|
+
|
60
|
+
file_path = File.join(File.expand_path("../data"), params["filename"][0])
|
61
|
+
File.open(file_path, "rb") do |f|
|
62
|
+
cgi.out(
|
63
|
+
{
|
64
|
+
"type" => get_content_type(file_path),
|
65
|
+
"content-disposition" => "inline; filename=#{File.basename(file_path)}"
|
66
|
+
}
|
67
|
+
) do
|
68
|
+
f.read
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
file
|
data/cgi-bin/main.rb
CHANGED
@@ -7,8 +7,20 @@ require "securerandom"
|
|
7
7
|
cgi = CGI.new
|
8
8
|
print cgi.header("application/json")
|
9
9
|
params = cgi.params
|
10
|
+
|
10
11
|
@json_file_path = "../data/data.json"
|
11
12
|
|
13
|
+
def log(text)
|
14
|
+
open("tmp", "a") do |f|
|
15
|
+
f.puts(text)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
#
|
20
|
+
# JSON ファイルを読み込んで配列として返す関数
|
21
|
+
#
|
22
|
+
# text = read_json("data.tmp")
|
23
|
+
#
|
12
24
|
def read_json(filename)
|
13
25
|
unless File.exist? filename
|
14
26
|
File.open(filename, "w") do |f|
|
@@ -22,24 +34,41 @@ def read_json(filename)
|
|
22
34
|
json
|
23
35
|
end
|
24
36
|
|
37
|
+
#
|
38
|
+
# データを取得
|
39
|
+
#
|
40
|
+
# - データがある場合: データを追加して保存し内容を JSON 形式で表示
|
41
|
+
# - データがない場合: 内容を JSON 形式で表示
|
42
|
+
#
|
43
|
+
# GET: /cgi-bin?data=
|
44
|
+
# GET: /cgi-bin?data=12345
|
45
|
+
#
|
25
46
|
def get_json(params)
|
26
47
|
return unless params.key?("data")
|
27
48
|
|
28
|
-
data = params["data"]
|
49
|
+
data = params["data"]
|
29
50
|
json = read_json(@json_file_path)
|
30
51
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
52
|
+
unless data.nil?
|
53
|
+
content = data[0]
|
54
|
+
if content != ""
|
55
|
+
json.append({
|
56
|
+
content: content,
|
57
|
+
uuid: SecureRandom.uuid
|
58
|
+
})
|
59
|
+
File.open(@json_file_path, "w") do |f|
|
60
|
+
f.write JSON.pretty_generate(json)
|
61
|
+
end
|
38
62
|
end
|
39
63
|
end
|
40
64
|
print(JSON.pretty_generate(json))
|
41
65
|
end
|
42
66
|
|
67
|
+
#
|
68
|
+
# コンテンツを削除する
|
69
|
+
#
|
70
|
+
# GET: /cgi-bin?delete=9cba8adc-2f1f-4feb-86dd-e6daf0d26d41
|
71
|
+
#
|
43
72
|
def delete(params)
|
44
73
|
return unless params.key?("delete")
|
45
74
|
|
@@ -57,5 +86,68 @@ def delete(params)
|
|
57
86
|
print JSON.pretty_generate(response)
|
58
87
|
end
|
59
88
|
|
89
|
+
def save_file(params)
|
90
|
+
return unless params.key?("file")
|
91
|
+
|
92
|
+
file = params["file"][0]
|
93
|
+
response = {
|
94
|
+
filename: file.original_filename
|
95
|
+
}
|
96
|
+
|
97
|
+
return if [".gitignore", "data.json"].include?(response[:filename])
|
98
|
+
|
99
|
+
file_path = File.join(File.expand_path("../data"), response[:filename])
|
100
|
+
|
101
|
+
File.open(file_path, "wb") do |f|
|
102
|
+
f.write file.read
|
103
|
+
end
|
104
|
+
|
105
|
+
print JSON.pretty_generate(response)
|
106
|
+
end
|
107
|
+
|
108
|
+
def remove_file(params)
|
109
|
+
return unless params.key?("removefile")
|
110
|
+
|
111
|
+
removefiles = params["removefile"]
|
112
|
+
if removefiles.empty?
|
113
|
+
print JSON.pretty_generate({ status: "NG" })
|
114
|
+
return
|
115
|
+
end
|
116
|
+
|
117
|
+
removefile = removefiles[0]
|
118
|
+
response = {
|
119
|
+
filename: removefile,
|
120
|
+
status: "NG"
|
121
|
+
}
|
122
|
+
|
123
|
+
if [".gitignore", "data.json", ""].include?(removefile)
|
124
|
+
print JSON.pretty_generate({ status: "NG" })
|
125
|
+
return
|
126
|
+
end
|
127
|
+
|
128
|
+
file_path = File.join(File.expand_path("../data"), removefile)
|
129
|
+
|
130
|
+
response[:status] = "OK" if File.exist?(file_path) && File.delete(file_path)
|
131
|
+
|
132
|
+
print JSON.pretty_generate(response)
|
133
|
+
end
|
134
|
+
|
135
|
+
#
|
136
|
+
# ファイル一覧を取得
|
137
|
+
#
|
138
|
+
# GET: /cgi-bin?files
|
139
|
+
#
|
140
|
+
def get_files(params)
|
141
|
+
return unless params.key?("files")
|
142
|
+
|
143
|
+
response = Dir.glob(File.join(File.expand_path("../data"), "*"))
|
144
|
+
response.map! { |e| File.basename(e) }
|
145
|
+
response.filter! { |e| !["data.json", ".gitignore"].include?(e) }
|
146
|
+
print JSON.pretty_generate(response)
|
147
|
+
end
|
148
|
+
|
60
149
|
get_json(params)
|
61
150
|
delete(params)
|
151
|
+
save_file(params)
|
152
|
+
get_files(params)
|
153
|
+
remove_file(params)
|
data/data/.gitignore
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
!.gitignore
|
2
|
+
*
|
data/docs/get-ipaddr.png
ADDED
Binary file
|
data/docs/screenshot.png
ADDED
Binary file
|
data/exe/sora
CHANGED
@@ -6,9 +6,9 @@ require "optparse"
|
|
6
6
|
|
7
7
|
opt = OptionParser.new
|
8
8
|
|
9
|
-
params = { port: 8080, document_root: File.expand_path("
|
9
|
+
params = { port: 8080, document_root: File.expand_path("../www", __dir__) }
|
10
10
|
|
11
|
-
opt.on("-p [PORT]", "--port [PORT]") { |v| params[:port] = v.to_i }
|
11
|
+
opt.on("-p [PORT]", "--port [PORT]", "Port number, default: 8080") { |v| params[:port] = v.to_i }
|
12
12
|
|
13
13
|
opt.parse!(ARGV)
|
14
14
|
|