ミラーる
This commit is contained in:
376
README-JP.md
376
README-JP.md
@@ -1,188 +1,188 @@
|
||||
# Little Beast
|
||||
シンプル、実践的、アンチ・ブロート
|
||||
|
||||
## Little Beast とは?
|
||||
Little Beast は PHP 8.3 以上向けのフレームワークで、076.moe(ゲーム開発会社)と technicalsuwako.moe(社長のブログ)向けに作られました。\
|
||||
メイン考え方は「必要な物だけ拡張し、不要な物は削除する」です。\
|
||||
各コア機能はライブラリに分割されている為、必要な物だけを選び易い設計になっています。\
|
||||
全てのモジュールはゼロから書かれており、データベースは一切必要ありません。
|
||||
|
||||
Little Beast はテクニカル諏訪子がゲーム開発に完全復帰する前の最後の Web プロジェクトです。
|
||||
|
||||
## Little Beast が「ではない」物
|
||||
* 汎用フレームワーク
|
||||
* 使い憎い
|
||||
* Web 開発者向け
|
||||
* 万人向け
|
||||
* インストールが面倒
|
||||
* 教条的
|
||||
* 民主的に運営される
|
||||
|
||||
## Little Beast が「持っていない」物
|
||||
* データベース(全てファイルベース)
|
||||
* 依存関係
|
||||
* パッケージマネージャー
|
||||
* Docker/Kubernetes/Vagrant/Nix 等のコンテナ
|
||||
* JavaScript
|
||||
* ブロートウェア
|
||||
* ORM
|
||||
* 認証/認可システム
|
||||
* キューやバックグラウンドジョブ
|
||||
* クラウド/サーバーレス統合
|
||||
* スキャフォールディング
|
||||
* コード生成
|
||||
* 抽象化レイヤー
|
||||
* 不要なファイル
|
||||
* DEI、行動規範、その他の差別的慣行
|
||||
|
||||
## 独自機能
|
||||
* データベース不要
|
||||
* Composer や PEAR 不要
|
||||
* サーバーオーバーヘッドゼロ
|
||||
* コンテナ不要
|
||||
* Maron テンプレートエンジン
|
||||
* カスタム Markdown
|
||||
* ActivityPub
|
||||
* 多言語対応
|
||||
* マルチブログ対応
|
||||
* 100% 綺麗で正しい HTML5 と CSS3
|
||||
* 100% 正しい PHP
|
||||
* SEO フレンドリー
|
||||
* モジュラー CSS
|
||||
* Atom フィード
|
||||
* 組み込みテストスイート
|
||||
|
||||
## インストール方法
|
||||
```sh
|
||||
cd /var/www/htdocs
|
||||
git clone https://github.com/TechnicalSuwako/LittleBeast.git .
|
||||
mv config/config.sample.php config/config.php
|
||||
```
|
||||
|
||||
HTTP サーバーを設定して `/public` をルートとして `php-fpm` で実行して下さい。\
|
||||
それだけです!
|
||||
|
||||
### OpenBSD サーバー
|
||||
```sh
|
||||
pkg_add php-8.4.14 php-gmp-8.4.14
|
||||
rcctl enable php84_fpm httpd relayd
|
||||
rcctl start php84_fpm httpd relayd
|
||||
```
|
||||
|
||||
#### httpd
|
||||
```
|
||||
server "technicalsuwako.moe" {
|
||||
listen on * tls port 8443
|
||||
gzip-static
|
||||
tls {
|
||||
certificate "/etc/ssl/technicalsuwako.moe.crt"
|
||||
key "/etc/ssl/private/technicalsuwako.moe.key"
|
||||
}
|
||||
root "/htdocs/technicalsuwako.moe/www/public"
|
||||
directory index "index.php"
|
||||
location "/.well-known/acme-challenge/*" {
|
||||
root "/acme"
|
||||
request strip 2
|
||||
}
|
||||
|
||||
location "/*.php" {
|
||||
fastcgi socket "/run/php-fpm.sock"
|
||||
}
|
||||
|
||||
location "/*.php[/?]*" {
|
||||
fastcgi socket "/run/php-fpm.sock"
|
||||
}
|
||||
|
||||
location "/" {
|
||||
directory index "index.php"
|
||||
}
|
||||
location match "/blog/" {
|
||||
request rewrite "/index.php"
|
||||
}
|
||||
location match "/about" {
|
||||
request rewrite "/index.php"
|
||||
}
|
||||
location match "/monero" {
|
||||
request rewrite "/index.php"
|
||||
}
|
||||
location match "/secret" {
|
||||
request rewrite "/index.php"
|
||||
}
|
||||
location match "/ap/" {
|
||||
request rewrite "/index.php"
|
||||
}
|
||||
location "/.well-known/webfinger" {
|
||||
request rewrite "/index.php"
|
||||
}
|
||||
location "/blog.atom" {
|
||||
request rewrite "/index.php"
|
||||
}
|
||||
}
|
||||
|
||||
server "www.technicalsuwako.moe" {
|
||||
listen on * tls port 8443
|
||||
gzip-static
|
||||
tls {
|
||||
certificate "/etc/ssl/technicalsuwako.moe.crt"
|
||||
key "/etc/ssl/private/technicalsuwako.moe.key"
|
||||
}
|
||||
block return 301 "https://technicalsuwako.moe$REQUEST_URI"
|
||||
}
|
||||
```
|
||||
|
||||
#### relayd
|
||||
```
|
||||
relayd_addr="0.0.0.0"
|
||||
router_addr="192.168.10.106"
|
||||
|
||||
table <httpd> { $router_addr }
|
||||
|
||||
http protocol reverse {
|
||||
tcp { nodelay, sack, socket buffer 65536, backlog 100 }
|
||||
tls ciphers "TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256"
|
||||
tls keypair "technicalsuwako.moe"
|
||||
|
||||
return error
|
||||
|
||||
match request header append "X-Forwarded-For" value "$REMOTE_ADDR"
|
||||
match request header append "X-Forwarded-Port" value "$REMOTE_PORT"
|
||||
|
||||
#match response header set "Referrer-Policy" value "same-origin"
|
||||
match response header set "X-Frame-Options" value "deny"
|
||||
match response header set "X-Content-Type-Options" value "nosniff"
|
||||
match response header set "Referrer-Policy" value "strict-origin-when-cross-origin"
|
||||
match response header set "Strict-Transport-Security" value "max-age=31536000; includeSubDomains; preload"
|
||||
match response header set "Cross-Origin-Opener-Policy" value "same-origin"
|
||||
match response header set "Content-Security-Policy" value "img-src 'self' https://*.076.moe http://*.076.moe https://*.technicalsuwako.moe http://*.technicalsuwako.moe; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline'; object-src 'none';"
|
||||
match response header append "Permissions-Policy" value "accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=()"
|
||||
|
||||
match request header "Accept-Encoding" value "gzip" tag "gzip"
|
||||
match response header "Content-Type" value "text/*" tag "compress"
|
||||
match response header "Content-Type" value "text/html" tag "charset=UTF-8"
|
||||
match response header "Content-Type" value "application/javascript" tag "compress"
|
||||
match response header "Content-Type" value "application/json" tag "compress"
|
||||
|
||||
pass request quick header "Host" value "technicalsuwako.moe" forward to <httpd>
|
||||
|
||||
pass
|
||||
}
|
||||
|
||||
relay www_tls {
|
||||
listen on $relayd_addr port 443 tls
|
||||
protocol reverse
|
||||
|
||||
# Default
|
||||
forward to <httpd> port 8443 check tcp
|
||||
}
|
||||
|
||||
relay www_www {
|
||||
listen on $relayd_addr port 80
|
||||
protocol reverse
|
||||
|
||||
# Default
|
||||
forward to <httpd> port 8080 check tcp
|
||||
}
|
||||
```
|
||||
|
||||
## 必要な PHP モジュール
|
||||
* php_gmp
|
||||
# Little Beast
|
||||
シンプル、実践的、アンチ・ブロート
|
||||
|
||||
## Little Beast とは?
|
||||
Little Beast は PHP 8.3 以上向けのフレームワークで、076.moe(ゲーム開発会社)と technicalsuwako.moe(社長のブログ)向けに作られました。\
|
||||
メイン考え方は「必要な物だけ拡張し、不要な物は削除する」です。\
|
||||
各コア機能はライブラリに分割されている為、必要な物だけを選び易い設計になっています。\
|
||||
全てのモジュールはゼロから書かれており、データベースは一切必要ありません。
|
||||
|
||||
Little Beast はテクニカル諏訪子がゲーム開発に完全復帰する前の最後の Web プロジェクトです。
|
||||
|
||||
## Little Beast が「ではない」物
|
||||
* 汎用フレームワーク
|
||||
* 使い憎い
|
||||
* Web 開発者向け
|
||||
* 万人向け
|
||||
* インストールが面倒
|
||||
* 教条的
|
||||
* 民主的に運営される
|
||||
|
||||
## Little Beast が「持っていない」物
|
||||
* データベース(全てファイルベース)
|
||||
* 依存関係
|
||||
* パッケージマネージャー
|
||||
* Docker/Kubernetes/Vagrant/Nix 等のコンテナ
|
||||
* JavaScript
|
||||
* ブロートウェア
|
||||
* ORM
|
||||
* 認証/認可システム
|
||||
* キューやバックグラウンドジョブ
|
||||
* クラウド/サーバーレス統合
|
||||
* スキャフォールディング
|
||||
* コード生成
|
||||
* 抽象化レイヤー
|
||||
* 不要なファイル
|
||||
* DEI、行動規範、その他の差別的慣行
|
||||
|
||||
## 独自機能
|
||||
* データベース不要
|
||||
* Composer や PEAR 不要
|
||||
* サーバーオーバーヘッドゼロ
|
||||
* コンテナ不要
|
||||
* Maron テンプレートエンジン
|
||||
* カスタム Markdown
|
||||
* ActivityPub
|
||||
* 多言語対応
|
||||
* マルチブログ対応
|
||||
* 100% 綺麗で正しい HTML5 と CSS3
|
||||
* 100% 正しい PHP
|
||||
* SEO フレンドリー
|
||||
* モジュラー CSS
|
||||
* Atom フィード
|
||||
* 組み込みテストスイート
|
||||
|
||||
## インストール方法
|
||||
```sh
|
||||
cd /var/www/htdocs
|
||||
git clone https://github.com/TechnicalSuwako/LittleBeast.git .
|
||||
mv config/config.sample.php config/config.php
|
||||
```
|
||||
|
||||
HTTP サーバーを設定して `/public` をルートとして `php-fpm` で実行して下さい。\
|
||||
それだけです!
|
||||
|
||||
### OpenBSD サーバー
|
||||
```sh
|
||||
pkg_add php-8.4.14 php-gmp-8.4.14
|
||||
rcctl enable php84_fpm httpd relayd
|
||||
rcctl start php84_fpm httpd relayd
|
||||
```
|
||||
|
||||
#### httpd
|
||||
```
|
||||
server "technicalsuwako.moe" {
|
||||
listen on * tls port 8443
|
||||
gzip-static
|
||||
tls {
|
||||
certificate "/etc/ssl/technicalsuwako.moe.crt"
|
||||
key "/etc/ssl/private/technicalsuwako.moe.key"
|
||||
}
|
||||
root "/htdocs/technicalsuwako.moe/www/public"
|
||||
directory index "index.php"
|
||||
location "/.well-known/acme-challenge/*" {
|
||||
root "/acme"
|
||||
request strip 2
|
||||
}
|
||||
|
||||
location "/*.php" {
|
||||
fastcgi socket "/run/php-fpm.sock"
|
||||
}
|
||||
|
||||
location "/*.php[/?]*" {
|
||||
fastcgi socket "/run/php-fpm.sock"
|
||||
}
|
||||
|
||||
location "/" {
|
||||
directory index "index.php"
|
||||
}
|
||||
location match "/blog/" {
|
||||
request rewrite "/index.php"
|
||||
}
|
||||
location match "/about" {
|
||||
request rewrite "/index.php"
|
||||
}
|
||||
location match "/monero" {
|
||||
request rewrite "/index.php"
|
||||
}
|
||||
location match "/secret" {
|
||||
request rewrite "/index.php"
|
||||
}
|
||||
location match "/ap/" {
|
||||
request rewrite "/index.php"
|
||||
}
|
||||
location "/.well-known/webfinger" {
|
||||
request rewrite "/index.php"
|
||||
}
|
||||
location "/blog.atom" {
|
||||
request rewrite "/index.php"
|
||||
}
|
||||
}
|
||||
|
||||
server "www.technicalsuwako.moe" {
|
||||
listen on * tls port 8443
|
||||
gzip-static
|
||||
tls {
|
||||
certificate "/etc/ssl/technicalsuwako.moe.crt"
|
||||
key "/etc/ssl/private/technicalsuwako.moe.key"
|
||||
}
|
||||
block return 301 "https://technicalsuwako.moe$REQUEST_URI"
|
||||
}
|
||||
```
|
||||
|
||||
#### relayd
|
||||
```
|
||||
relayd_addr="0.0.0.0"
|
||||
router_addr="192.168.10.106"
|
||||
|
||||
table <httpd> { $router_addr }
|
||||
|
||||
http protocol reverse {
|
||||
tcp { nodelay, sack, socket buffer 65536, backlog 100 }
|
||||
tls ciphers "TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256"
|
||||
tls keypair "technicalsuwako.moe"
|
||||
|
||||
return error
|
||||
|
||||
match request header append "X-Forwarded-For" value "$REMOTE_ADDR"
|
||||
match request header append "X-Forwarded-Port" value "$REMOTE_PORT"
|
||||
|
||||
#match response header set "Referrer-Policy" value "same-origin"
|
||||
match response header set "X-Frame-Options" value "deny"
|
||||
match response header set "X-Content-Type-Options" value "nosniff"
|
||||
match response header set "Referrer-Policy" value "strict-origin-when-cross-origin"
|
||||
match response header set "Strict-Transport-Security" value "max-age=31536000; includeSubDomains; preload"
|
||||
match response header set "Cross-Origin-Opener-Policy" value "same-origin"
|
||||
match response header set "Content-Security-Policy" value "img-src 'self' https://*.076.moe http://*.076.moe https://*.technicalsuwako.moe http://*.technicalsuwako.moe; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline'; object-src 'none';"
|
||||
match response header append "Permissions-Policy" value "accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=()"
|
||||
|
||||
match request header "Accept-Encoding" value "gzip" tag "gzip"
|
||||
match response header "Content-Type" value "text/*" tag "compress"
|
||||
match response header "Content-Type" value "text/html" tag "charset=UTF-8"
|
||||
match response header "Content-Type" value "application/javascript" tag "compress"
|
||||
match response header "Content-Type" value "application/json" tag "compress"
|
||||
|
||||
pass request quick header "Host" value "technicalsuwako.moe" forward to <httpd>
|
||||
|
||||
pass
|
||||
}
|
||||
|
||||
relay www_tls {
|
||||
listen on $relayd_addr port 443 tls
|
||||
protocol reverse
|
||||
|
||||
# Default
|
||||
forward to <httpd> port 8443 check tcp
|
||||
}
|
||||
|
||||
relay www_www {
|
||||
listen on $relayd_addr port 80
|
||||
protocol reverse
|
||||
|
||||
# Default
|
||||
forward to <httpd> port 8080 check tcp
|
||||
}
|
||||
```
|
||||
|
||||
## 必要な PHP モジュール
|
||||
* php_gmp
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
title: テーブルの例
|
||||
uuid: 684d234e-f0d6-4da0-8f38-71c7105262d5
|
||||
author: Little-san
|
||||
date: 2025-04-11 08:50:57
|
||||
category: test,css
|
||||
css: table
|
||||
----
|
||||
テーブルの例だ。
|
||||
複数CSSファイルを含むには、コンマで分けて下さい。
|
||||
例えば: `css: table,search`
|
||||
|
||||
## プログラミング言語のランキング
|
||||
| プログラミング言語 | ランキング | 理由 |
|
||||
|-------|-----|----|
|
||||
| C | ★★★★★ | どこでも使える |
|
||||
| C++ | ★★★★★ | たーのし~ |
|
||||
| PHP | ★★★★☆ | Little BeastをPHPで作ったから |
|
||||
| Go | ★★★☆☆ | 言語は問題ないけど、会社は親DEI・・・ |
|
||||
| Ruby | ★☆☆☆☆ | 遅過ぎる |
|
||||
| Javascript | ★☆☆☆☆ | 🤡 |
|
||||
| Rust | ★☆☆☆☆ | ゲイ!! |
|
||||
title: テーブルの例
|
||||
uuid: 684d234e-f0d6-4da0-8f38-71c7105262d5
|
||||
author: Little-san
|
||||
date: 2025-04-11 08:50:57
|
||||
category: test,css
|
||||
css: table
|
||||
----
|
||||
テーブルの例だ。
|
||||
複数CSSファイルを含むには、コンマで分けて下さい。
|
||||
例えば: `css: table,search`
|
||||
|
||||
## プログラミング言語のランキング
|
||||
| プログラミング言語 | ランキング | 理由 |
|
||||
|-------|-----|----|
|
||||
| C | ★★★★★ | どこでも使える |
|
||||
| C++ | ★★★★★ | たーのし~ |
|
||||
| PHP | ★★★★☆ | Little BeastをPHPで作ったから |
|
||||
| Go | ★★★☆☆ | 言語は問題ないけど、会社は親DEI・・・ |
|
||||
| Ruby | ★☆☆☆☆ | 遅過ぎる |
|
||||
| Javascript | ★☆☆☆☆ | 🤡 |
|
||||
| Rust | ★☆☆☆☆ | ゲイ!! |
|
||||
| Zig | ★★★☆☆ | 良いけど、未だ開発中 |
|
||||
@@ -1,20 +1,20 @@
|
||||
.fraction {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
margin: 0 0.2em;
|
||||
}
|
||||
|
||||
.fraction .numerator, .fraction .denominator {
|
||||
display: block;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
.fraction .numerator {
|
||||
border-bottom: 1px solid #fcfcfc;
|
||||
}
|
||||
|
||||
.algebraic {
|
||||
font-family: 'Times New Roman', serif;
|
||||
.fraction {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
margin: 0 0.2em;
|
||||
}
|
||||
|
||||
.fraction .numerator, .fraction .denominator {
|
||||
display: block;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
.fraction .numerator {
|
||||
border-bottom: 1px solid #fcfcfc;
|
||||
}
|
||||
|
||||
.algebraic {
|
||||
font-family: 'Times New Roman', serif;
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
.blink {
|
||||
animation: blinker 1s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes blinker {
|
||||
50% {
|
||||
opacity: 0;
|
||||
}
|
||||
.blink {
|
||||
animation: blinker 1s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes blinker {
|
||||
50% {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
blockquote {
|
||||
background: #121012;
|
||||
border: 2px solid #f545f5;
|
||||
border-radius: 2px;
|
||||
border-left: 12px solid #c016c6;
|
||||
margin: 1.5em 10px;
|
||||
padding: 0.5em 10px;
|
||||
blockquote {
|
||||
background: #121012;
|
||||
border: 2px solid #f545f5;
|
||||
border-radius: 2px;
|
||||
border-left: 12px solid #c016c6;
|
||||
margin: 1.5em 10px;
|
||||
padding: 0.5em 10px;
|
||||
}
|
||||
@@ -1,36 +1,36 @@
|
||||
.blog-type > p {
|
||||
font-weight: bolder;
|
||||
}
|
||||
|
||||
a.blog-type-btn {
|
||||
background-color: #550f75;
|
||||
color: #120f12;
|
||||
text-decoration: none;
|
||||
border: 1px solid #fcfcfc;
|
||||
border-radius: 4px;
|
||||
padding: 4px;
|
||||
margin: 4px;
|
||||
transition: background-color 0.9s;
|
||||
}
|
||||
|
||||
a.blog-type-btn.active {
|
||||
background-color: #c016c6;
|
||||
}
|
||||
|
||||
hr.blog-type-line {
|
||||
border: 3px dotted #c016c6;
|
||||
}
|
||||
|
||||
a.blog-type-btn:hover {
|
||||
background-color: #ea79d8;
|
||||
}
|
||||
|
||||
a.blog-type-btn.active:ae6bdb {
|
||||
background-color: #ae6bdb;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 768px) {
|
||||
a.blog-type-btn {
|
||||
display: block;
|
||||
}
|
||||
.blog-type > p {
|
||||
font-weight: bolder;
|
||||
}
|
||||
|
||||
a.blog-type-btn {
|
||||
background-color: #550f75;
|
||||
color: #120f12;
|
||||
text-decoration: none;
|
||||
border: 1px solid #fcfcfc;
|
||||
border-radius: 4px;
|
||||
padding: 4px;
|
||||
margin: 4px;
|
||||
transition: background-color 0.9s;
|
||||
}
|
||||
|
||||
a.blog-type-btn.active {
|
||||
background-color: #c016c6;
|
||||
}
|
||||
|
||||
hr.blog-type-line {
|
||||
border: 3px dotted #c016c6;
|
||||
}
|
||||
|
||||
a.blog-type-btn:hover {
|
||||
background-color: #ea79d8;
|
||||
}
|
||||
|
||||
a.blog-type-btn.active:ae6bdb {
|
||||
background-color: #ae6bdb;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 768px) {
|
||||
a.blog-type-btn {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
@@ -1,40 +1,40 @@
|
||||
.diff-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-family: monospace;
|
||||
color: #fcfcfc;
|
||||
}
|
||||
|
||||
.diff-table td {
|
||||
border: 1px solid #bcb4bc;
|
||||
padding: 5px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.diff-header th {
|
||||
border: 1px solid #bcb4bc;
|
||||
}
|
||||
|
||||
.line-number {
|
||||
width: 50px;
|
||||
text-align: right;
|
||||
color: #c016c6;
|
||||
}
|
||||
|
||||
.removed {
|
||||
background-color: #fa9faa;
|
||||
color: #b61729;
|
||||
}
|
||||
|
||||
.added {
|
||||
background-color: #88ecc1;
|
||||
color: #2c980c;
|
||||
}
|
||||
|
||||
.context {
|
||||
background-color: #232320;
|
||||
}
|
||||
|
||||
.empty {
|
||||
background-color: #746c75;
|
||||
.diff-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-family: monospace;
|
||||
color: #fcfcfc;
|
||||
}
|
||||
|
||||
.diff-table td {
|
||||
border: 1px solid #bcb4bc;
|
||||
padding: 5px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.diff-header th {
|
||||
border: 1px solid #bcb4bc;
|
||||
}
|
||||
|
||||
.line-number {
|
||||
width: 50px;
|
||||
text-align: right;
|
||||
color: #c016c6;
|
||||
}
|
||||
|
||||
.removed {
|
||||
background-color: #fa9faa;
|
||||
color: #b61729;
|
||||
}
|
||||
|
||||
.added {
|
||||
background-color: #88ecc1;
|
||||
color: #2c980c;
|
||||
}
|
||||
|
||||
.context {
|
||||
background-color: #232320;
|
||||
}
|
||||
|
||||
.empty {
|
||||
background-color: #746c75;
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
hr {
|
||||
border: 1px solid #ea79d8;
|
||||
}
|
||||
|
||||
.pager {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
|
||||
.prev {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.next {
|
||||
text-align: right;
|
||||
hr {
|
||||
border: 1px solid #ea79d8;
|
||||
}
|
||||
|
||||
.pager {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
|
||||
.prev {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.next {
|
||||
text-align: right;
|
||||
}
|
||||
@@ -1,94 +1,94 @@
|
||||
<?php
|
||||
namespace Site\Controller;
|
||||
|
||||
use Site\Controller\BlogPost;
|
||||
use Site\Lib\Markdown;
|
||||
|
||||
class Atom extends BlogPost {
|
||||
private string $domain = 'technicalsuwako.moe';
|
||||
|
||||
/**
|
||||
* 最新の5記事のAtomフィードを生成する
|
||||
*
|
||||
* @param array $params パラメータ配列
|
||||
* @return void
|
||||
*/
|
||||
public function feed(array $params): void {
|
||||
try {
|
||||
// 最新の投稿を取得
|
||||
$posts = $this->getPosts('/blog/');
|
||||
// 最新の5件に制限
|
||||
$posts = array_slice($posts, 0, 5);
|
||||
|
||||
// サイトのドメインを取得
|
||||
$domain = $_SERVER['HTTP_HOST'];
|
||||
$baseUrl = 'https://'.$domain;
|
||||
|
||||
// 現在の日時(RFC3339形式)
|
||||
$published = date('c');
|
||||
|
||||
// XMLヘッダーとコンテンツタイプを設定
|
||||
header('Content-Type: application/atom+xml; charset=utf-8');
|
||||
|
||||
// Atomフィードの開始部分
|
||||
echo '<?xml version="1.0" encoding="utf-8"?>'."\n";
|
||||
echo '<feed xmlns="http://www.w3.org/2005/Atom">'."\n";
|
||||
|
||||
// フィードの基本情報
|
||||
echo ' <title>'.SITEINFO['title'].'</title>'."\n";
|
||||
echo ' <link href="'.$baseUrl.'" />'."\n";
|
||||
echo ' <link href="'.$baseUrl.'/blog.atom" rel="self" />'."\n";
|
||||
echo ' <id>'.$baseUrl.'/</id>'."\n";
|
||||
echo ' <published>'.$published.'</published>'."\n";
|
||||
echo ' <updated>'.$published.'</updated>'."\n";
|
||||
echo ' <author>'."\n";
|
||||
echo ' <name>'.SITEINFO['title'].'</name>'."\n";
|
||||
echo ' </author>'."\n";
|
||||
|
||||
// 各エントリー(記事)
|
||||
foreach ($posts as $post) {
|
||||
// 記事の本文を取得(プレーンテキスト)
|
||||
$path = ROOT.'/blog/'.$post['slug'].'.md';
|
||||
$content = '';
|
||||
$postPublished = date('c', strtotime($post['date']));
|
||||
|
||||
if (file_exists($path)) {
|
||||
$fileContent = file_get_contents($path);
|
||||
$parts = explode('----', $fileContent, 2);
|
||||
if (count($parts) > 1) {
|
||||
// 本文をHTMLとして準備
|
||||
$md = new Markdown($post['slug'], '/blog/');
|
||||
$content = $md->parse();
|
||||
// HTMLタグを取り除かないようにCDATAで囲む
|
||||
$content = '<![CDATA['.$content.']]>';
|
||||
}
|
||||
}
|
||||
|
||||
echo ' <entry>'."\n";
|
||||
echo ' <title>'.htmlspecialchars($post['title']).'</title>'."\n";
|
||||
echo ' <link href="'.$baseUrl.'/blog/'.$post['slug'].'" />'."\n";
|
||||
echo ' <id>'.$baseUrl.'/blog/'.$post['slug'].'</id>'."\n";
|
||||
echo ' <published>'.$postPublished.'</published>'."\n";
|
||||
|
||||
// カテゴリ(タグ)
|
||||
if (isset($post['category']) && is_array($post['category'])) {
|
||||
foreach ($post['category'] as $category) {
|
||||
echo ' <category term="'.htmlspecialchars($category).'" />'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
// 本文(要約または全文)
|
||||
echo ' <content type="html">'.$content.'</content>'."\n";
|
||||
echo ' </entry>'."\n";
|
||||
}
|
||||
|
||||
// フィードの終了
|
||||
echo '</feed>';
|
||||
exit;
|
||||
} catch (\Exception $e) {
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
echo 'フィードの作成に失敗: '.$e->getMessage();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
<?php
|
||||
namespace Site\Controller;
|
||||
|
||||
use Site\Controller\BlogPost;
|
||||
use Site\Lib\Markdown;
|
||||
|
||||
class Atom extends BlogPost {
|
||||
private string $domain = 'technicalsuwako.moe';
|
||||
|
||||
/**
|
||||
* 最新の5記事のAtomフィードを生成する
|
||||
*
|
||||
* @param array $params パラメータ配列
|
||||
* @return void
|
||||
*/
|
||||
public function feed(array $params): void {
|
||||
try {
|
||||
// 最新の投稿を取得
|
||||
$posts = $this->getPosts('/blog/');
|
||||
// 最新の5件に制限
|
||||
$posts = array_slice($posts, 0, 5);
|
||||
|
||||
// サイトのドメインを取得
|
||||
$domain = $_SERVER['HTTP_HOST'];
|
||||
$baseUrl = 'https://'.$domain;
|
||||
|
||||
// 現在の日時(RFC3339形式)
|
||||
$published = date('c');
|
||||
|
||||
// XMLヘッダーとコンテンツタイプを設定
|
||||
header('Content-Type: application/atom+xml; charset=utf-8');
|
||||
|
||||
// Atomフィードの開始部分
|
||||
echo '<?xml version="1.0" encoding="utf-8"?>'."\n";
|
||||
echo '<feed xmlns="http://www.w3.org/2005/Atom">'."\n";
|
||||
|
||||
// フィードの基本情報
|
||||
echo ' <title>'.SITEINFO['title'].'</title>'."\n";
|
||||
echo ' <link href="'.$baseUrl.'" />'."\n";
|
||||
echo ' <link href="'.$baseUrl.'/blog.atom" rel="self" />'."\n";
|
||||
echo ' <id>'.$baseUrl.'/</id>'."\n";
|
||||
echo ' <published>'.$published.'</published>'."\n";
|
||||
echo ' <updated>'.$published.'</updated>'."\n";
|
||||
echo ' <author>'."\n";
|
||||
echo ' <name>'.SITEINFO['title'].'</name>'."\n";
|
||||
echo ' </author>'."\n";
|
||||
|
||||
// 各エントリー(記事)
|
||||
foreach ($posts as $post) {
|
||||
// 記事の本文を取得(プレーンテキスト)
|
||||
$path = ROOT.'/blog/'.$post['slug'].'.md';
|
||||
$content = '';
|
||||
$postPublished = date('c', strtotime($post['date']));
|
||||
|
||||
if (file_exists($path)) {
|
||||
$fileContent = file_get_contents($path);
|
||||
$parts = explode('----', $fileContent, 2);
|
||||
if (count($parts) > 1) {
|
||||
// 本文をHTMLとして準備
|
||||
$md = new Markdown($post['slug'], '/blog/');
|
||||
$content = $md->parse();
|
||||
// HTMLタグを取り除かないようにCDATAで囲む
|
||||
$content = '<![CDATA['.$content.']]>';
|
||||
}
|
||||
}
|
||||
|
||||
echo ' <entry>'."\n";
|
||||
echo ' <title>'.htmlspecialchars($post['title']).'</title>'."\n";
|
||||
echo ' <link href="'.$baseUrl.'/blog/'.$post['slug'].'" />'."\n";
|
||||
echo ' <id>'.$baseUrl.'/blog/'.$post['slug'].'</id>'."\n";
|
||||
echo ' <published>'.$postPublished.'</published>'."\n";
|
||||
|
||||
// カテゴリ(タグ)
|
||||
if (isset($post['category']) && is_array($post['category'])) {
|
||||
foreach ($post['category'] as $category) {
|
||||
echo ' <category term="'.htmlspecialchars($category).'" />'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
// 本文(要約または全文)
|
||||
echo ' <content type="html">'.$content.'</content>'."\n";
|
||||
echo ' </entry>'."\n";
|
||||
}
|
||||
|
||||
// フィードの終了
|
||||
echo '</feed>';
|
||||
exit;
|
||||
} catch (\Exception $e) {
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
echo 'フィードの作成に失敗: '.$e->getMessage();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,66 +1,66 @@
|
||||
<?php
|
||||
namespace Site\Controller;
|
||||
|
||||
class BlogPost {
|
||||
/**
|
||||
* ブログ投稿を取得する
|
||||
*
|
||||
* @return array 投稿の配列
|
||||
*/
|
||||
public function getPosts(string $section): array {
|
||||
$path = ROOT.$section;
|
||||
$posts = [];
|
||||
|
||||
if (!is_dir($path)) return $posts;
|
||||
$files = glob($path.'/*.md');
|
||||
|
||||
foreach ($files as $file) {
|
||||
$content = file_get_contents($file);
|
||||
$parts = explode('----', $content, 2);
|
||||
if (count($parts) != 2) continue;
|
||||
|
||||
$metadata = [];
|
||||
$meta = explode("\n", trim($parts[0]));
|
||||
|
||||
foreach ($meta as $line) {
|
||||
$line = trim($line);
|
||||
if (empty($line)) continue;
|
||||
|
||||
$colonPos = strpos($line, ':');
|
||||
if ($colonPos === false) continue;
|
||||
|
||||
$key = trim(substr($line, 0, $colonPos));
|
||||
$value = trim(substr($line, $colonPos + 1));
|
||||
$value = trim($value, '"\'');
|
||||
|
||||
if ($key == 'category') {
|
||||
$metadata[$key] = array_map('trim', explode(',', $value));
|
||||
} else {
|
||||
$metadata[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$articleBody = trim($parts[1]);
|
||||
$preview = mb_substr(strip_tags($articleBody), 0, 50).'...';
|
||||
$slug = basename($file, '.md');
|
||||
|
||||
$posts[] = [
|
||||
'title' => $metadata['title'] ?? '',
|
||||
'date' => $metadata['date'] ?? '',
|
||||
'thumbnail' => $metadata['thumbnail'] ?? '',
|
||||
'thumborient' => $metadata['thumborient'] ?? '',
|
||||
'category' => $metadata['category'] ?? [],
|
||||
'uuid' => $metadata['uuid'] ?? '',
|
||||
'preview' => $preview,
|
||||
'slug' => $slug,
|
||||
];
|
||||
}
|
||||
|
||||
// 日付でソート(新しい順)
|
||||
usort($posts, function($a, $b) {
|
||||
return strtotime($b['date']) - strtotime($a['date']);
|
||||
});
|
||||
|
||||
return $posts;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
namespace Site\Controller;
|
||||
|
||||
class BlogPost {
|
||||
/**
|
||||
* ブログ投稿を取得する
|
||||
*
|
||||
* @return array 投稿の配列
|
||||
*/
|
||||
public function getPosts(string $section): array {
|
||||
$path = ROOT.$section;
|
||||
$posts = [];
|
||||
|
||||
if (!is_dir($path)) return $posts;
|
||||
$files = glob($path.'/*.md');
|
||||
|
||||
foreach ($files as $file) {
|
||||
$content = file_get_contents($file);
|
||||
$parts = explode('----', $content, 2);
|
||||
if (count($parts) != 2) continue;
|
||||
|
||||
$metadata = [];
|
||||
$meta = explode("\n", trim($parts[0]));
|
||||
|
||||
foreach ($meta as $line) {
|
||||
$line = trim($line);
|
||||
if (empty($line)) continue;
|
||||
|
||||
$colonPos = strpos($line, ':');
|
||||
if ($colonPos === false) continue;
|
||||
|
||||
$key = trim(substr($line, 0, $colonPos));
|
||||
$value = trim(substr($line, $colonPos + 1));
|
||||
$value = trim($value, '"\'');
|
||||
|
||||
if ($key == 'category') {
|
||||
$metadata[$key] = array_map('trim', explode(',', $value));
|
||||
} else {
|
||||
$metadata[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$articleBody = trim($parts[1]);
|
||||
$preview = mb_substr(strip_tags($articleBody), 0, 50).'...';
|
||||
$slug = basename($file, '.md');
|
||||
|
||||
$posts[] = [
|
||||
'title' => $metadata['title'] ?? '',
|
||||
'date' => $metadata['date'] ?? '',
|
||||
'thumbnail' => $metadata['thumbnail'] ?? '',
|
||||
'thumborient' => $metadata['thumborient'] ?? '',
|
||||
'category' => $metadata['category'] ?? [],
|
||||
'uuid' => $metadata['uuid'] ?? '',
|
||||
'preview' => $preview,
|
||||
'slug' => $slug,
|
||||
];
|
||||
}
|
||||
|
||||
// 日付でソート(新しい順)
|
||||
usort($posts, function($a, $b) {
|
||||
return strtotime($b['date']) - strtotime($a['date']);
|
||||
});
|
||||
|
||||
return $posts;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,151 +1,151 @@
|
||||
<?php
|
||||
namespace Site\Controller;
|
||||
|
||||
use Site\Controller\BlogPost;
|
||||
use Site\Controller\Mods;
|
||||
use Site\Lib\Activitypub;
|
||||
|
||||
class Fediverse extends BlogPost {
|
||||
use Mods;
|
||||
|
||||
/**
|
||||
* @param array $params パラメータ配列
|
||||
* @return void
|
||||
*/
|
||||
public function apfinger(array $params): void {
|
||||
try {
|
||||
header('Content-Type: application/jrd+json');
|
||||
$ap = new Activitypub();
|
||||
echo $ap->getWebfinger();
|
||||
exit;
|
||||
} catch (\Exception $e) {
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
echo 'フェディバースの作成に失敗: '.$e->getMessage();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params パラメータ配列
|
||||
* @return void
|
||||
*/
|
||||
public function apactor(array $params): void {
|
||||
try {
|
||||
header('Content-Type: application/activity+json');
|
||||
$ap = new Activitypub();
|
||||
echo $ap->getActor();
|
||||
exit;
|
||||
} catch (\Exception $e) {
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
echo 'フェディバースの作成に失敗: '.$e->getMessage();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params パラメータ配列
|
||||
* @return void
|
||||
*/
|
||||
public function apinbox(array $params): void {
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
header('HTTP/1.1 405 Method Not Allowed');
|
||||
header('Allow: POST');
|
||||
exit;
|
||||
}
|
||||
|
||||
$input = file_get_contents('php://input');
|
||||
$activity = json_decode($input, true);
|
||||
if (!$activity || !isset($activity['type'])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
header('Content-Type: application/activity+json');
|
||||
echo json_encode(['error' => '不正なアクティビティ']);
|
||||
exit;
|
||||
}
|
||||
|
||||
logger(\LogType::ActivityPub, "受付に入れた:".json_encode($activity));
|
||||
|
||||
try {
|
||||
header('Content-Type: application/activity+json');
|
||||
$ap = new Activitypub();
|
||||
$ap->postInbox($activity);
|
||||
exit;
|
||||
} catch (\Exception $e) {
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
echo 'フェディバースの作成に失敗: '.$e->getMessage();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params パラメータ配列
|
||||
* @return void
|
||||
*/
|
||||
public function apactivity(array $params): void {
|
||||
$uuid = '';
|
||||
if (isset($params['uuid'])) $uuid = $params['uuid'];
|
||||
|
||||
try {
|
||||
header('Content-Type: application/activity+json');
|
||||
$posts = $this->getPosts('/blog/');
|
||||
$ap = new Activitypub($posts);
|
||||
echo $ap->getActivity($uuid);
|
||||
exit;
|
||||
} catch (\Exception $e) {
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
echo 'フェディバースの作成に失敗: '.$e->getMessage();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params パラメータ配列
|
||||
* @return void
|
||||
*/
|
||||
public function apoutbox(array $params): void {
|
||||
try {
|
||||
header('Content-Type: application/activity+json');
|
||||
$posts = $this->getPosts('/blog/');
|
||||
$ap = new Activitypub($posts);
|
||||
echo $ap->getOutbox();
|
||||
exit;
|
||||
} catch (\Exception $e) {
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
echo 'フェディバースの作成に失敗: '.$e->getMessage();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params パラメータ配列
|
||||
* @return void
|
||||
*/
|
||||
public function apfollowers(array $params): void {
|
||||
try {
|
||||
header('Content-Type: application/activity+json');
|
||||
$ap = new Activitypub();
|
||||
echo $ap->getFollowers();
|
||||
exit;
|
||||
} catch (\Exception $e) {
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
echo 'フェディバースの作成に失敗: '.$e->getMessage();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params パラメータ配列
|
||||
* @return void
|
||||
*/
|
||||
public function apfollowing(array $params): void {
|
||||
try {
|
||||
header('Content-Type: application/activity+json');
|
||||
$ap = new Activitypub();
|
||||
echo $ap->getFollowing();
|
||||
exit;
|
||||
} catch (\Exception $e) {
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
echo 'フェディバースの作成に失敗: '.$e->getMessage();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
<?php
|
||||
namespace Site\Controller;
|
||||
|
||||
use Site\Controller\BlogPost;
|
||||
use Site\Controller\Mods;
|
||||
use Site\Lib\Activitypub;
|
||||
|
||||
class Fediverse extends BlogPost {
|
||||
use Mods;
|
||||
|
||||
/**
|
||||
* @param array $params パラメータ配列
|
||||
* @return void
|
||||
*/
|
||||
public function apfinger(array $params): void {
|
||||
try {
|
||||
header('Content-Type: application/jrd+json');
|
||||
$ap = new Activitypub();
|
||||
echo $ap->getWebfinger();
|
||||
exit;
|
||||
} catch (\Exception $e) {
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
echo 'フェディバースの作成に失敗: '.$e->getMessage();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params パラメータ配列
|
||||
* @return void
|
||||
*/
|
||||
public function apactor(array $params): void {
|
||||
try {
|
||||
header('Content-Type: application/activity+json');
|
||||
$ap = new Activitypub();
|
||||
echo $ap->getActor();
|
||||
exit;
|
||||
} catch (\Exception $e) {
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
echo 'フェディバースの作成に失敗: '.$e->getMessage();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params パラメータ配列
|
||||
* @return void
|
||||
*/
|
||||
public function apinbox(array $params): void {
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
header('HTTP/1.1 405 Method Not Allowed');
|
||||
header('Allow: POST');
|
||||
exit;
|
||||
}
|
||||
|
||||
$input = file_get_contents('php://input');
|
||||
$activity = json_decode($input, true);
|
||||
if (!$activity || !isset($activity['type'])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
header('Content-Type: application/activity+json');
|
||||
echo json_encode(['error' => '不正なアクティビティ']);
|
||||
exit;
|
||||
}
|
||||
|
||||
logger(\LogType::ActivityPub, "受付に入れた:".json_encode($activity));
|
||||
|
||||
try {
|
||||
header('Content-Type: application/activity+json');
|
||||
$ap = new Activitypub();
|
||||
$ap->postInbox($activity);
|
||||
exit;
|
||||
} catch (\Exception $e) {
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
echo 'フェディバースの作成に失敗: '.$e->getMessage();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params パラメータ配列
|
||||
* @return void
|
||||
*/
|
||||
public function apactivity(array $params): void {
|
||||
$uuid = '';
|
||||
if (isset($params['uuid'])) $uuid = $params['uuid'];
|
||||
|
||||
try {
|
||||
header('Content-Type: application/activity+json');
|
||||
$posts = $this->getPosts('/blog/');
|
||||
$ap = new Activitypub($posts);
|
||||
echo $ap->getActivity($uuid);
|
||||
exit;
|
||||
} catch (\Exception $e) {
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
echo 'フェディバースの作成に失敗: '.$e->getMessage();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params パラメータ配列
|
||||
* @return void
|
||||
*/
|
||||
public function apoutbox(array $params): void {
|
||||
try {
|
||||
header('Content-Type: application/activity+json');
|
||||
$posts = $this->getPosts('/blog/');
|
||||
$ap = new Activitypub($posts);
|
||||
echo $ap->getOutbox();
|
||||
exit;
|
||||
} catch (\Exception $e) {
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
echo 'フェディバースの作成に失敗: '.$e->getMessage();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params パラメータ配列
|
||||
* @return void
|
||||
*/
|
||||
public function apfollowers(array $params): void {
|
||||
try {
|
||||
header('Content-Type: application/activity+json');
|
||||
$ap = new Activitypub();
|
||||
echo $ap->getFollowers();
|
||||
exit;
|
||||
} catch (\Exception $e) {
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
echo 'フェディバースの作成に失敗: '.$e->getMessage();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params パラメータ配列
|
||||
* @return void
|
||||
*/
|
||||
public function apfollowing(array $params): void {
|
||||
try {
|
||||
header('Content-Type: application/activity+json');
|
||||
$ap = new Activitypub();
|
||||
echo $ap->getFollowing();
|
||||
exit;
|
||||
} catch (\Exception $e) {
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
echo 'フェディバースの作成に失敗: '.$e->getMessage();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,130 +1,130 @@
|
||||
<?php
|
||||
namespace Site\Lib;
|
||||
|
||||
class DiffViewer {
|
||||
private $diffContent;
|
||||
|
||||
public function __construct(string $filePath) {
|
||||
if (!file_exists($filePath)) {
|
||||
throw new \Exception("Diff file not found: $filePath");
|
||||
}
|
||||
$this->diffContent = file_get_contents($filePath);
|
||||
}
|
||||
|
||||
public function displaySideBySide(): string {
|
||||
$lines = explode("\n", $this->diffContent);
|
||||
$fileDiffs = [];
|
||||
$currentFile = null;
|
||||
$hunk = [];
|
||||
$lineNumbers = ['left' => 0, 'right' => 0];
|
||||
$currentLeftLines = [];
|
||||
$currentRightLines = [];
|
||||
|
||||
foreach ($lines as $line) {
|
||||
// ファイルヘッダーの処理
|
||||
if (preg_match('/^---\s+(.+)/', $line, $matches)) {
|
||||
// ファイルを処理する場合、データを保存する
|
||||
if ($currentFile !== null) {
|
||||
$this->processHunk($hunk, $currentLeftLines, $currentRightLines, $lineNumbers);
|
||||
$fileDiffs[$currentFile] = [
|
||||
'leftLines' => $currentLeftLines,
|
||||
'rightLines' => $currentRightLines
|
||||
];
|
||||
$hunk = [];
|
||||
$currentLeftLines = [];
|
||||
$currentRightLines = [];
|
||||
$lineNumbers = ['left' => 0, 'right' => 0];
|
||||
}
|
||||
$currentFile = $matches[1];
|
||||
continue;
|
||||
}
|
||||
if (preg_match('/^\+\+\+\s+(.+)/', $line)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// ハンクヘッダーの処理 (例:@@ -10,6 +10,7 @@)
|
||||
if (preg_match('/^@@\s+-(\d+),\d+\s+\+(\d+),\d+\s+@@/', $line, $matches)) {
|
||||
$this->processHunk($hunk, $currentLeftLines, $currentRightLines, $lineNumbers);
|
||||
$hunk = [];
|
||||
$lineNumbers['left'] = (int)$matches[1];
|
||||
$lineNumbers['right'] = (int)$matches[2];
|
||||
continue;
|
||||
}
|
||||
|
||||
// ハンクでの行列の集まり
|
||||
if (substr($line, 0, 1) === '-' || substr($line, 0, 1) === '+' || substr($line, 0, 1) === ' ') {
|
||||
$hunk[] = $line;
|
||||
}
|
||||
}
|
||||
|
||||
// 最後のハンク・ファイルの処理
|
||||
if ($currentFile !== null) {
|
||||
$this->processHunk($hunk, $currentLeftLines, $currentRightLines, $lineNumbers);
|
||||
$fileDiffs[$currentFile] = [
|
||||
'leftLines' => $currentLeftLines,
|
||||
'rightLines' => $currentRightLines
|
||||
];
|
||||
}
|
||||
|
||||
// 各ファイルにHTMLの出力の作成
|
||||
$html = '';
|
||||
foreach ($fileDiffs as $fileName => $diff) {
|
||||
$html .= "<h2>ファイル: ".htmlspecialchars($fileName)."</h2>\n";
|
||||
$html .= $this->generateHtml($diff['leftLines'], $diff['rightLines']);
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
private function processHunk(array $hunk, array &$leftLines, array &$rightLines, array &$lineNumbers): void {
|
||||
foreach ($hunk as $line) {
|
||||
$prefix = substr($line, 0, 1);
|
||||
$content = substr($line, 1);
|
||||
|
||||
if ($prefix === '-') {
|
||||
$leftLines[] = ['content' => htmlspecialchars($content), 'type' => 'removed', 'line' => $lineNumbers['left']];
|
||||
$lineNumbers['left']++;
|
||||
} elseif ($prefix === '+') {
|
||||
$rightLines[] = ['content' => htmlspecialchars($content), 'type' => 'added', 'line' => $lineNumbers['right']];
|
||||
$lineNumbers['right']++;
|
||||
} elseif ($prefix === ' ') {
|
||||
// 両側のコンテキストは同じ行列があるかの確認
|
||||
while ($lineNumbers['left'] < $lineNumbers['right']) {
|
||||
$leftLines[] = ['content' => '', 'type' => 'empty', 'line' => $lineNumbers['left']];
|
||||
$lineNumbers['left']++;
|
||||
}
|
||||
while ($lineNumbers['right'] < $lineNumbers['left']) {
|
||||
$rightLines[] = ['content' => '', 'type' => 'empty', 'line' => $lineNumbers['right']];
|
||||
$lineNumbers['right']++;
|
||||
}
|
||||
$leftLines[] = ['content' => htmlspecialchars($content), 'type' => 'context', 'line' => $lineNumbers['left']];
|
||||
$rightLines[] = ['content' => htmlspecialchars($content), 'type' => 'context', 'line' => $lineNumbers['right']];
|
||||
$lineNumbers['left']++;
|
||||
$lineNumbers['right']++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function generateHtml(array $leftLines, array $rightLines): string {
|
||||
$html = '<table class="diff-table">';
|
||||
$html .= '<tr class="diff-header"><th colspan="2">前</th><th colspan="2">新</th></tr>';
|
||||
|
||||
$maxLines = max(count($leftLines), count($rightLines));
|
||||
for ($i = 0; $i < $maxLines; $i++) {
|
||||
$left = isset($leftLines[$i]) ? $leftLines[$i] : ['content' => '', 'type' => 'empty', 'line' => ''];
|
||||
$right = isset($rightLines[$i]) ? $rightLines[$i] : ['content' => '', 'type' => 'empty', 'line' => ''];
|
||||
|
||||
$html .= '<tr>';
|
||||
// 左(変更前)
|
||||
$html .= '<td class="line-number">' . ($left['line'] ?: ' ') . '</td>';
|
||||
$html .= '<td class="' . $left['type'] . '">' . ($left['content'] ?: ' ') . '</td>';
|
||||
// 右(変更後)
|
||||
$html .= '<td class="line-number">' . ($right['line'] ?: ' ') . '</td>';
|
||||
$html .= '<td class="' . $right['type'] . '">' . ($right['content'] ?: ' ') . '</td>';
|
||||
$html .= '</tr>';
|
||||
}
|
||||
|
||||
$html .= '</table>';
|
||||
return $html;
|
||||
}
|
||||
<?php
|
||||
namespace Site\Lib;
|
||||
|
||||
class DiffViewer {
|
||||
private $diffContent;
|
||||
|
||||
public function __construct(string $filePath) {
|
||||
if (!file_exists($filePath)) {
|
||||
throw new \Exception("Diff file not found: $filePath");
|
||||
}
|
||||
$this->diffContent = file_get_contents($filePath);
|
||||
}
|
||||
|
||||
public function displaySideBySide(): string {
|
||||
$lines = explode("\n", $this->diffContent);
|
||||
$fileDiffs = [];
|
||||
$currentFile = null;
|
||||
$hunk = [];
|
||||
$lineNumbers = ['left' => 0, 'right' => 0];
|
||||
$currentLeftLines = [];
|
||||
$currentRightLines = [];
|
||||
|
||||
foreach ($lines as $line) {
|
||||
// ファイルヘッダーの処理
|
||||
if (preg_match('/^---\s+(.+)/', $line, $matches)) {
|
||||
// ファイルを処理する場合、データを保存する
|
||||
if ($currentFile !== null) {
|
||||
$this->processHunk($hunk, $currentLeftLines, $currentRightLines, $lineNumbers);
|
||||
$fileDiffs[$currentFile] = [
|
||||
'leftLines' => $currentLeftLines,
|
||||
'rightLines' => $currentRightLines
|
||||
];
|
||||
$hunk = [];
|
||||
$currentLeftLines = [];
|
||||
$currentRightLines = [];
|
||||
$lineNumbers = ['left' => 0, 'right' => 0];
|
||||
}
|
||||
$currentFile = $matches[1];
|
||||
continue;
|
||||
}
|
||||
if (preg_match('/^\+\+\+\s+(.+)/', $line)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// ハンクヘッダーの処理 (例:@@ -10,6 +10,7 @@)
|
||||
if (preg_match('/^@@\s+-(\d+),\d+\s+\+(\d+),\d+\s+@@/', $line, $matches)) {
|
||||
$this->processHunk($hunk, $currentLeftLines, $currentRightLines, $lineNumbers);
|
||||
$hunk = [];
|
||||
$lineNumbers['left'] = (int)$matches[1];
|
||||
$lineNumbers['right'] = (int)$matches[2];
|
||||
continue;
|
||||
}
|
||||
|
||||
// ハンクでの行列の集まり
|
||||
if (substr($line, 0, 1) === '-' || substr($line, 0, 1) === '+' || substr($line, 0, 1) === ' ') {
|
||||
$hunk[] = $line;
|
||||
}
|
||||
}
|
||||
|
||||
// 最後のハンク・ファイルの処理
|
||||
if ($currentFile !== null) {
|
||||
$this->processHunk($hunk, $currentLeftLines, $currentRightLines, $lineNumbers);
|
||||
$fileDiffs[$currentFile] = [
|
||||
'leftLines' => $currentLeftLines,
|
||||
'rightLines' => $currentRightLines
|
||||
];
|
||||
}
|
||||
|
||||
// 各ファイルにHTMLの出力の作成
|
||||
$html = '';
|
||||
foreach ($fileDiffs as $fileName => $diff) {
|
||||
$html .= "<h2>ファイル: ".htmlspecialchars($fileName)."</h2>\n";
|
||||
$html .= $this->generateHtml($diff['leftLines'], $diff['rightLines']);
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
private function processHunk(array $hunk, array &$leftLines, array &$rightLines, array &$lineNumbers): void {
|
||||
foreach ($hunk as $line) {
|
||||
$prefix = substr($line, 0, 1);
|
||||
$content = substr($line, 1);
|
||||
|
||||
if ($prefix === '-') {
|
||||
$leftLines[] = ['content' => htmlspecialchars($content), 'type' => 'removed', 'line' => $lineNumbers['left']];
|
||||
$lineNumbers['left']++;
|
||||
} elseif ($prefix === '+') {
|
||||
$rightLines[] = ['content' => htmlspecialchars($content), 'type' => 'added', 'line' => $lineNumbers['right']];
|
||||
$lineNumbers['right']++;
|
||||
} elseif ($prefix === ' ') {
|
||||
// 両側のコンテキストは同じ行列があるかの確認
|
||||
while ($lineNumbers['left'] < $lineNumbers['right']) {
|
||||
$leftLines[] = ['content' => '', 'type' => 'empty', 'line' => $lineNumbers['left']];
|
||||
$lineNumbers['left']++;
|
||||
}
|
||||
while ($lineNumbers['right'] < $lineNumbers['left']) {
|
||||
$rightLines[] = ['content' => '', 'type' => 'empty', 'line' => $lineNumbers['right']];
|
||||
$lineNumbers['right']++;
|
||||
}
|
||||
$leftLines[] = ['content' => htmlspecialchars($content), 'type' => 'context', 'line' => $lineNumbers['left']];
|
||||
$rightLines[] = ['content' => htmlspecialchars($content), 'type' => 'context', 'line' => $lineNumbers['right']];
|
||||
$lineNumbers['left']++;
|
||||
$lineNumbers['right']++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function generateHtml(array $leftLines, array $rightLines): string {
|
||||
$html = '<table class="diff-table">';
|
||||
$html .= '<tr class="diff-header"><th colspan="2">前</th><th colspan="2">新</th></tr>';
|
||||
|
||||
$maxLines = max(count($leftLines), count($rightLines));
|
||||
for ($i = 0; $i < $maxLines; $i++) {
|
||||
$left = isset($leftLines[$i]) ? $leftLines[$i] : ['content' => '', 'type' => 'empty', 'line' => ''];
|
||||
$right = isset($rightLines[$i]) ? $rightLines[$i] : ['content' => '', 'type' => 'empty', 'line' => ''];
|
||||
|
||||
$html .= '<tr>';
|
||||
// 左(変更前)
|
||||
$html .= '<td class="line-number">' . ($left['line'] ?: ' ') . '</td>';
|
||||
$html .= '<td class="' . $left['type'] . '">' . ($left['content'] ?: ' ') . '</td>';
|
||||
// 右(変更後)
|
||||
$html .= '<td class="line-number">' . ($right['line'] ?: ' ') . '</td>';
|
||||
$html .= '<td class="' . $right['type'] . '">' . ($right['content'] ?: ' ') . '</td>';
|
||||
$html .= '</tr>';
|
||||
}
|
||||
|
||||
$html .= '</table>';
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,64 +1,64 @@
|
||||
<?php
|
||||
namespace Site\Test;
|
||||
|
||||
require_once __DIR__.'/../../../autoload.php';
|
||||
|
||||
use Site\Lib\Tester;
|
||||
use Site\Lib\Mysql;
|
||||
|
||||
$test = new Tester([
|
||||
'colorOutput' => true,
|
||||
'verboseOutput' => true
|
||||
]);
|
||||
|
||||
$test->describe('パケットのデバッグ', function($test): void {
|
||||
try {
|
||||
$db = new Mysql();
|
||||
|
||||
$db->setDebug(true);
|
||||
$db->connect();
|
||||
|
||||
$result = $db->query('SELECT * FROM user WHERE id = 1');
|
||||
|
||||
foreach ($result['rows'] as $row) {
|
||||
echo "ユーザー名: ".$row['nickname']."\n";
|
||||
}
|
||||
|
||||
$db->savePacketLogToFile('mysql_log.txt');
|
||||
$db->close();
|
||||
} catch (\Exception $e) {
|
||||
echo 'エラー: '.$e->getMessage()."\n";
|
||||
}
|
||||
});
|
||||
|
||||
$test->describe('プリペアドステートメント', function($test): void {
|
||||
try {
|
||||
$db = new Mysql();
|
||||
$db->connect();
|
||||
|
||||
// データの入り
|
||||
$stmt = $db->prepare('INSERT INTO users (name, age) VALUES (?, ?)');
|
||||
$test->assertTrue($stmt);
|
||||
|
||||
$db->execute($stmt, ['山田太郎', 25]);
|
||||
// TODO: assert
|
||||
|
||||
$close = $db->demolish($stmt);
|
||||
$this->assertTrue($close);
|
||||
|
||||
// データの受け取り
|
||||
$stmt = $db->prepare('SELECT * FROM users WHERE age > ?');
|
||||
$test->assertTrue($stmt);
|
||||
|
||||
$res = $db->execute($stmt, [20]);
|
||||
// TODO: assert
|
||||
print_r($res);
|
||||
|
||||
$close = $db->demolish($stmt);
|
||||
$this->assertTrue($close);
|
||||
|
||||
$db->close();
|
||||
} catch (\Exception $e) {
|
||||
echo 'エラー: '.$e->getMessage()."\n";
|
||||
}
|
||||
<?php
|
||||
namespace Site\Test;
|
||||
|
||||
require_once __DIR__.'/../../../autoload.php';
|
||||
|
||||
use Site\Lib\Tester;
|
||||
use Site\Lib\Mysql;
|
||||
|
||||
$test = new Tester([
|
||||
'colorOutput' => true,
|
||||
'verboseOutput' => true
|
||||
]);
|
||||
|
||||
$test->describe('パケットのデバッグ', function($test): void {
|
||||
try {
|
||||
$db = new Mysql();
|
||||
|
||||
$db->setDebug(true);
|
||||
$db->connect();
|
||||
|
||||
$result = $db->query('SELECT * FROM user WHERE id = 1');
|
||||
|
||||
foreach ($result['rows'] as $row) {
|
||||
echo "ユーザー名: ".$row['nickname']."\n";
|
||||
}
|
||||
|
||||
$db->savePacketLogToFile('mysql_log.txt');
|
||||
$db->close();
|
||||
} catch (\Exception $e) {
|
||||
echo 'エラー: '.$e->getMessage()."\n";
|
||||
}
|
||||
});
|
||||
|
||||
$test->describe('プリペアドステートメント', function($test): void {
|
||||
try {
|
||||
$db = new Mysql();
|
||||
$db->connect();
|
||||
|
||||
// データの入り
|
||||
$stmt = $db->prepare('INSERT INTO users (name, age) VALUES (?, ?)');
|
||||
$test->assertTrue($stmt);
|
||||
|
||||
$db->execute($stmt, ['山田太郎', 25]);
|
||||
// TODO: assert
|
||||
|
||||
$close = $db->demolish($stmt);
|
||||
$this->assertTrue($close);
|
||||
|
||||
// データの受け取り
|
||||
$stmt = $db->prepare('SELECT * FROM users WHERE age > ?');
|
||||
$test->assertTrue($stmt);
|
||||
|
||||
$res = $db->execute($stmt, [20]);
|
||||
// TODO: assert
|
||||
print_r($res);
|
||||
|
||||
$close = $db->demolish($stmt);
|
||||
$this->assertTrue($close);
|
||||
|
||||
$db->close();
|
||||
} catch (\Exception $e) {
|
||||
echo 'エラー: '.$e->getMessage()."\n";
|
||||
}
|
||||
});
|
||||
@@ -1,23 +1,23 @@
|
||||
<article class="news-card">
|
||||
{@ if (isset($post['thumbnail']) && $post['thumbnail'] != '') @}
|
||||
<div class="news-image">
|
||||
<a href="/{{ $section }}/{{ $post['slug'] }}">
|
||||
<img src="/static/article/{{ $post['thumbnail'] }}" alt="{{ $post['title'] }}" loading="lazy" />
|
||||
</a>
|
||||
</div>
|
||||
{@ endif @}
|
||||
<div class="news-content">
|
||||
<div class="news-meta">
|
||||
<span class="news-date">{{ $post['date'] }}</span>
|
||||
{# {@ if (isset($post['category']) && is_array($post['category'])) @} #}
|
||||
{@ foreach ($post['category'] as $cat) @}
|
||||
<span class="news-category">{{ $cat }}</span>
|
||||
{@ endforeach @}
|
||||
{# {@ endif @} #}
|
||||
</div>
|
||||
<h2 class="news-title">
|
||||
<a href="/{{ $section }}/{{ $post['slug'] }}{{{ isset($_GET['q']) ? '?q='.urlencode($_GET['q']) : '' }}}">{{{ $post['title'] }}}</a>
|
||||
</h2>
|
||||
<p class="news-preview">{{{ $post['preview'] }}}</p>
|
||||
</div>
|
||||
<article class="news-card">
|
||||
{@ if (isset($post['thumbnail']) && $post['thumbnail'] != '') @}
|
||||
<div class="news-image">
|
||||
<a href="/{{ $section }}/{{ $post['slug'] }}">
|
||||
<img src="/static/article/{{ $post['thumbnail'] }}" alt="{{ $post['title'] }}" loading="lazy" />
|
||||
</a>
|
||||
</div>
|
||||
{@ endif @}
|
||||
<div class="news-content">
|
||||
<div class="news-meta">
|
||||
<span class="news-date">{{ $post['date'] }}</span>
|
||||
{# {@ if (isset($post['category']) && is_array($post['category'])) @} #}
|
||||
{@ foreach ($post['category'] as $cat) @}
|
||||
<span class="news-category">{{ $cat }}</span>
|
||||
{@ endforeach @}
|
||||
{# {@ endif @} #}
|
||||
</div>
|
||||
<h2 class="news-title">
|
||||
<a href="/{{ $section }}/{{ $post['slug'] }}{{{ isset($_GET['q']) ? '?q='.urlencode($_GET['q']) : '' }}}">{{{ $post['title'] }}}</a>
|
||||
</h2>
|
||||
<p class="news-preview">{{{ $post['preview'] }}}</p>
|
||||
</div>
|
||||
</article>
|
||||
@@ -1,71 +1,71 @@
|
||||
{@ if (isset($totalPages) && $totalPages > 1) @}
|
||||
<div class="pagination">
|
||||
{# 検索クエリがある場合はページネーションリンクに含める #}
|
||||
{$ $queryParams = [] $}
|
||||
{@ if (isset($_GET['q']) && !empty($_GET['q'])) @}
|
||||
{$ $queryParams['q'] = $_GET['q'] $}
|
||||
{@ endif @}
|
||||
|
||||
{# 前のページへのリンク #}
|
||||
{@ if (isset($currentPage) && $currentPage > 1) @}
|
||||
{$ $prevParams = $queryParams $}
|
||||
{$ $prevParams['page'] = $currentPage - 1 $}
|
||||
{$ $prevQueryString = http_build_query($prevParams) $}
|
||||
<a href="?{{ $prevQueryString }}" class="page-link">« 前</a>
|
||||
{@ endif @}
|
||||
|
||||
{# 表示するページ番号の範囲を計算(モバイル対応の為) #}
|
||||
{# 最大表示ページ数 #}
|
||||
{$ $rangeSize = 2 $}
|
||||
{$ $startPage = max(1, $currentPage - floor($rangeSize / 2)) $}
|
||||
{$ $endPage = min($totalPages, $startPage + $rangeSize - 1) $}
|
||||
|
||||
{# 範囲の調整 #}
|
||||
{@ if ($endPage - $startPage + 1 < $rangeSize && $startPage > 1) @}
|
||||
{$ $startPage = max(1, $endPage - $rangeSize + 1) $}
|
||||
{@ endif @}
|
||||
|
||||
{# 最初のページへのリンク(多数のページがある場合) #}
|
||||
{@ if ($startPage > 1) @}
|
||||
{$ $firstParams = $queryParams $}
|
||||
{$ $firstParams['page'] = 1 $}
|
||||
{$ $firstQueryString = http_build_query($firstParams) $}
|
||||
|
||||
<a href="?{{ $firstQueryString }}" class="page-link">1</a>
|
||||
{@ if ($startPage > 2) @}
|
||||
<span class="page-ellipsis">...</span>
|
||||
{@ endif @}
|
||||
{@ endif @}
|
||||
|
||||
{@ for ($i = $startPage; $i <= $endPage; $i++) @}
|
||||
{$ $pageParams = $queryParams $}
|
||||
{$ $pageParams['page'] = $i $}
|
||||
{$ $pageQueryString = http_build_query($pageParams) $}
|
||||
|
||||
{@ if ($i == $currentPage) @}
|
||||
<span class="page-current" aria-current="page">{{ $i }}</span>
|
||||
{@ else @}
|
||||
<a href="?{{ $pageQueryString }}" class="page-link">{{ $i }}</a>
|
||||
{@ endif @}
|
||||
{@ endfor @}
|
||||
|
||||
{@ if ($endPage < $totalPages) @}
|
||||
{# 最後のページへのリンク(多数のページがある場合) #}
|
||||
{$ $lastParams = $queryParams $}
|
||||
{$ $lastParams['page'] = $totalPages $}
|
||||
{$ $lastQueryString = http_build_query($lastParams) $}
|
||||
{@ if ($endPage < $totalPages - 1) @}
|
||||
<span class="page-ellipsis">...</span>
|
||||
{@ endif @}
|
||||
<a href="?{{ $lastQueryString }}" class="page-link">{{ $totalPages }}</a>
|
||||
{@ endif @}
|
||||
|
||||
{# 次のページへのリンク #}
|
||||
{@ if (isset($currentPage) && $currentPage < $totalPages) @}
|
||||
{$ $nextParams = $queryParams $}
|
||||
{$ $nextParams['page'] = $currentPage + 1 $}
|
||||
{$ $nextQueryString = http_build_query($nextParams) $}
|
||||
<a href="?{{ $nextQueryString }}" class="page-link">次 »</a>
|
||||
{@ endif @}
|
||||
</div>
|
||||
{@ if (isset($totalPages) && $totalPages > 1) @}
|
||||
<div class="pagination">
|
||||
{# 検索クエリがある場合はページネーションリンクに含める #}
|
||||
{$ $queryParams = [] $}
|
||||
{@ if (isset($_GET['q']) && !empty($_GET['q'])) @}
|
||||
{$ $queryParams['q'] = $_GET['q'] $}
|
||||
{@ endif @}
|
||||
|
||||
{# 前のページへのリンク #}
|
||||
{@ if (isset($currentPage) && $currentPage > 1) @}
|
||||
{$ $prevParams = $queryParams $}
|
||||
{$ $prevParams['page'] = $currentPage - 1 $}
|
||||
{$ $prevQueryString = http_build_query($prevParams) $}
|
||||
<a href="?{{ $prevQueryString }}" class="page-link">« 前</a>
|
||||
{@ endif @}
|
||||
|
||||
{# 表示するページ番号の範囲を計算(モバイル対応の為) #}
|
||||
{# 最大表示ページ数 #}
|
||||
{$ $rangeSize = 2 $}
|
||||
{$ $startPage = max(1, $currentPage - floor($rangeSize / 2)) $}
|
||||
{$ $endPage = min($totalPages, $startPage + $rangeSize - 1) $}
|
||||
|
||||
{# 範囲の調整 #}
|
||||
{@ if ($endPage - $startPage + 1 < $rangeSize && $startPage > 1) @}
|
||||
{$ $startPage = max(1, $endPage - $rangeSize + 1) $}
|
||||
{@ endif @}
|
||||
|
||||
{# 最初のページへのリンク(多数のページがある場合) #}
|
||||
{@ if ($startPage > 1) @}
|
||||
{$ $firstParams = $queryParams $}
|
||||
{$ $firstParams['page'] = 1 $}
|
||||
{$ $firstQueryString = http_build_query($firstParams) $}
|
||||
|
||||
<a href="?{{ $firstQueryString }}" class="page-link">1</a>
|
||||
{@ if ($startPage > 2) @}
|
||||
<span class="page-ellipsis">...</span>
|
||||
{@ endif @}
|
||||
{@ endif @}
|
||||
|
||||
{@ for ($i = $startPage; $i <= $endPage; $i++) @}
|
||||
{$ $pageParams = $queryParams $}
|
||||
{$ $pageParams['page'] = $i $}
|
||||
{$ $pageQueryString = http_build_query($pageParams) $}
|
||||
|
||||
{@ if ($i == $currentPage) @}
|
||||
<span class="page-current" aria-current="page">{{ $i }}</span>
|
||||
{@ else @}
|
||||
<a href="?{{ $pageQueryString }}" class="page-link">{{ $i }}</a>
|
||||
{@ endif @}
|
||||
{@ endfor @}
|
||||
|
||||
{@ if ($endPage < $totalPages) @}
|
||||
{# 最後のページへのリンク(多数のページがある場合) #}
|
||||
{$ $lastParams = $queryParams $}
|
||||
{$ $lastParams['page'] = $totalPages $}
|
||||
{$ $lastQueryString = http_build_query($lastParams) $}
|
||||
{@ if ($endPage < $totalPages - 1) @}
|
||||
<span class="page-ellipsis">...</span>
|
||||
{@ endif @}
|
||||
<a href="?{{ $lastQueryString }}" class="page-link">{{ $totalPages }}</a>
|
||||
{@ endif @}
|
||||
|
||||
{# 次のページへのリンク #}
|
||||
{@ if (isset($currentPage) && $currentPage < $totalPages) @}
|
||||
{$ $nextParams = $queryParams $}
|
||||
{$ $nextParams['page'] = $currentPage + 1 $}
|
||||
{$ $nextQueryString = http_build_query($nextParams) $}
|
||||
<a href="?{{ $nextQueryString }}" class="page-link">次 »</a>
|
||||
{@ endif @}
|
||||
</div>
|
||||
{@ endif @}
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="search-form">
|
||||
<form action="/{{ $curblog != 'gd' ? $section : '' }}" method="GET">
|
||||
<input type="text" name="q" value="{{{ isset($_GET['q']) ? htmlspecialchars($_GET['q']) : '' }}}" placeholder="キーワードを入力して下さい" />
|
||||
<input type="submit" value="検索" />
|
||||
</form>
|
||||
<div class="search-form">
|
||||
<form action="/{{ $curblog != 'gd' ? $section : '' }}" method="GET">
|
||||
<input type="text" name="q" value="{{{ isset($_GET['q']) ? htmlspecialchars($_GET['q']) : '' }}}" placeholder="キーワードを入力して下さい" />
|
||||
<input type="submit" value="検索" />
|
||||
</form>
|
||||
</div>
|
||||
@@ -1,15 +1,15 @@
|
||||
{@ include(common/header) @}
|
||||
<h1 class="paragraph">Moneroで支援♡</h1>
|
||||
<p class="paragraph">
|
||||
欲しければ、モネロ(XMR)でご支援お願い申し上げます。
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<img src="https://ass.technicalsuwako.moe/keroxmr.png" alt="" />
|
||||
<img src="https://ass.technicalsuwako.moe/xmr-qr.png" alt="" />
|
||||
</p>
|
||||
|
||||
<p class="paragraph">
|
||||
<pre><code>88daW9ANXGVg9zHe6tzHSpQjxHN6JPFDz9wvZBecL1BfTFwmkuLYm9xRsLUt1WAVGPQ6h5pZX6nyu9zXFwE5efSz1gtE1oz</code></pre>
|
||||
</p>
|
||||
{@ include(common/footer) @}
|
||||
{@ include(common/header) @}
|
||||
<h1 class="paragraph">Moneroで支援♡</h1>
|
||||
<p class="paragraph">
|
||||
欲しければ、モネロ(XMR)でご支援お願い申し上げます。
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<img src="https://ass.technicalsuwako.moe/keroxmr.png" alt="" />
|
||||
<img src="https://ass.technicalsuwako.moe/xmr-qr.png" alt="" />
|
||||
</p>
|
||||
|
||||
<p class="paragraph">
|
||||
<pre><code>88daW9ANXGVg9zHe6tzHSpQjxHN6JPFDz9wvZBecL1BfTFwmkuLYm9xRsLUt1WAVGPQ6h5pZX6nyu9zXFwE5efSz1gtE1oz</code></pre>
|
||||
</p>
|
||||
{@ include(common/footer) @}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{@ include(common/header) @}
|
||||
<h1 class="paragraph">秘密のページ</h1>
|
||||
<p class="paragraph">
|
||||
内緒だね~
|
||||
</p>
|
||||
{@ include(common/footer) @}
|
||||
{@ include(common/header) @}
|
||||
<h1 class="paragraph">秘密のページ</h1>
|
||||
<p class="paragraph">
|
||||
内緒だね~
|
||||
</p>
|
||||
{@ include(common/footer) @}
|
||||
|
||||
Reference in New Issue
Block a user