Skip to content

Commit

Permalink
Feature/v5 (#7)
Browse files Browse the repository at this point in the history
* Adding version
* improving logging
* Change design add config dir opening
  • Loading branch information
kakakaya authored Apr 14, 2023
1 parent e913849 commit bc376d6
Show file tree
Hide file tree
Showing 12 changed files with 284 additions and 111 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

投稿力の変わらないただ一つのBlueskyクライアント。そう、まぜそば大陸ならね。

Out of respect for [ラーメン大陸](www16.atpages.jp/nigore/soft/).
Out of respect for [ラーメン大陸](https://www16.atpages.jp/nigore/soft/).

## About

### ラーメン大陸リスペクト機能
チェックが付いた機能は実装済み(つまりまだなにもできていない)

- [x] 投稿
Expand All @@ -25,15 +26,16 @@ Out of respect for [ラーメン大陸](www16.atpages.jp/nigore/soft/).
- [ ] F6キーでポスト画面に入力されている文字列の英日翻訳(実装予定なし)
- [ ] F7キーでポスト画面に入力されている文字列の日英日翻訳(実装予定なし)
- [ ] F8キーで新規付箋(実装予定なし)
- [ ] F9キーで「地震だ!」機能。どこの田舎よりも素早い速報を!
- [x] F9キーで「地震だ!」機能。どこの田舎よりも素早い速報を!
- [ ] F10キーでCDトレイの開閉。(実装予定なし)
- [ ] F11キーでポストにフッターのオンオフ。(空文字無効)
- [ ] F12キーでポストにハッシュタグのオンオフ。(空文字無効)
- [ ] Escキーで終了or隠れる。
- マウス
- [ ] 残り文字数の部分をダブルクリックでTL画面呼び出し。
- [ ] 残り文字数の部分を右クリックでメニュー呼び出し。
- [ ] 残り文字数の部分を掴んだら移動。
- [x] 残り文字数の部分を掴んだら移動。
- まぜそば大陸はどこでも掴んだら移動可能。
- アレ
- [x] ちくわ
- [ ] ハイパーステルスアレ
Expand Down
36 changes: 24 additions & 12 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

// cliutil "github.com/bluesky-social/indigo/cmd/gosky/util"
"github.com/adrg/xdg"
"github.com/bluesky-social/indigo/xrpc"
)

Expand All @@ -19,6 +20,7 @@ type App struct {
config Config
ctx context.Context
xrpcc *xrpc.Client
logger *log.Logger
}

// NewApp creates a new App application struct
Expand All @@ -30,15 +32,14 @@ func NewApp() *App {
// so we can call the runtime methods
func (a *App) startup(ctx context.Context) {
a.ctx = ctx

// Build xrpc.Client
var auth *xrpc.AuthInfo

cred := a.config.Credential
auth, err := createSession(cred.Host, cred.Identifier, cred.Password)

if err != nil {
log.Fatal("Failed creating session, bad identifier or password?: %v", err)
a.logger.Fatalf("Failed creating session, bad identifier or password?: %v", err)
}

xrpcc := &xrpc.Client{
Expand Down Expand Up @@ -104,21 +105,32 @@ func (a *App) Greet(name string) string {
return fmt.Sprintf("Hello %s, It's show time and current time is %s!", name, time.Now().Format(time.RFC3339))
}


func (a *App) Post(text string) string {
res, err := PostFeed(a.xrpcc, text)
res, err := BskyFeedPost(a.xrpcc, text)
if err != nil {
return fmt.Sprintf(err.Error())
errs := fmt.Sprintf("Posting error: %s", err.Error())
a.logger.Println(errs)
return errs

}
return res
}

func (a *App) Chikuwa() string {
text := fmt.Sprintf("ちくわ。 %s", time.Now().Format(time.RFC3339))
res, err := PostFeed(a.xrpcc, text)
func (a *App) Chikuwa(text string) string {
return a.Post(fmt.Sprintf("%s %s", text, time.Now().Format(time.RFC3339)))
}

if err != nil {
log.Println(err)
return fmt.Sprintf(err.Error())
}
return res
func (a *App) OpenConfigDirectory() error {
f, _ := xdg.ConfigFile("mazesoba-continent")
return openDirectory(f)
}

func (a *App) OpenLogDirectory() error {
f, _ := xdg.CacheFile("mazesoba-continent")
return openDirectory(f)
}

func (a *App) GetVersion() string {
return Version
}
11 changes: 4 additions & 7 deletions bluesky.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"context"
"fmt"
"log"
"time"

comatproto "github.com/bluesky-social/indigo/api/atproto"
Expand All @@ -13,14 +12,13 @@ import (
"github.com/gen2brain/beeep"
)

func PostFeed(xrpcc *xrpc.Client, text string) (string, error) {
// xrpcc, err := cliutil.GetXrpcClient(ctx, true)
err := beeep.Notify("まぜそば大陸", fmt.Sprintf("PostFeed: posting %s", text), "")
func BskyFeedPost(xrpcc *xrpc.Client, text string) (string, error) {
err := beeep.Notify("まぜそば大陸", fmt.Sprintf("BskyFeedPost: %s", text), "")
if err != nil {
log.Fatalln(err)
return "", err
}

return "<MOCK URI>", nil // TEMP
// return "<MOCK URI>", nil // TEMP

resp, err := comatproto.RepoCreateRecord(context.TODO(), xrpcc, &comatproto.RepoCreateRecord_Input{
Collection: "app.bsky.feed.post",
Expand All @@ -33,6 +31,5 @@ func PostFeed(xrpcc *xrpc.Client, text string) (string, error) {
if err != nil {
return "", fmt.Errorf("failed to create post: %w", err)
}
log.Println(resp.Cid, resp.Uri)
return resp.Uri, nil
}
2 changes: 2 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/adrg/xdg"
)

const configPath = "mazesoba-continent/config.toml"

type Config struct {
General generalConfig
Window windowConfig
Expand Down
10 changes: 10 additions & 0 deletions continent.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package main

// getSpecialCommand ...
func getSpecialCommand(text string) string {
switch text {
case "@バージョン":
return "未実装"
}
return text
}
108 changes: 34 additions & 74 deletions frontend/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@
import logo from './assets/images/logo-universal.png'
import {
Chikuwa,
Post
Post,
OpenConfigDirectory,
OpenLogDirectory,
GetVersion
} from '../wailsjs/go/main/App.js'
import {
WindowCenter,
WindowHide,
WindowShow
WindowShow,
Quit
} from '../wailsjs/runtime/runtime.js'
let text
let placeholder
let charCounter = 0
let placeholder = Math.random() > 0.5 ? "最近どう?" : "どう最近?"
function countGrapheme(string) {
const segmenter = new Intl.Segmenter("ja", {
Expand All @@ -27,102 +33,56 @@
})
}
function earthquake() {
text = "地震だ!"
// post();
function earthquake() {
text = "地震だ!"
}
function version() {
GetVersion().then(version => text = "まぜそば大陸バージョン" + version + "が浮上中")
}
function chikuwa() {
Chikuwa().then(result => {
if (text == "") {
text = "ちくわ。"
}
Chikuwa(text).then(result => {
placeholder = result
text = ""
})
}
function windowHide() {
WindowHide()
}
function windowShow() {
WindowShow()
}
function handleKeyDown(event) {
if ((event.ctrlKey || event.metaKey) && event.key == 'a') {
event.preventDefault();
text = "全部選択"
} else if ((event.ctrlKey || event.metaKey) && event.key == 'Enter') {
event.preventDefault();
post();
} else if (event.key == 'F2') {
event.preventDefault();
// open config
if ((event.ctrlKey || event.metaKey) && event.key == 'Enter') {
event.preventDefault()
post()
} else if ((event.ctrlKey || event.metaKey) && event.key == ',') {
event.preventDefault()
OpenConfigDirectory()
} else if (event.key == 'F9') {
event.preventDefault();
earthquake();
} else if (event.key == 'Escape') {
Quit();
}
charCounter = text.length;
}
window.addEventListener("keydown", handleKeyDown);
</script>

<main style="--wails-draggable:drag">
<div class="input-box" id="input">
<textarea autocomplete="off" bind:value={text} placeholder={placeholder} id="name" />
<textarea autocomplete="off" bind:value={text} placeholder={placeholder} id="inputbox" />
<p id="char-counter" class="char-count">{charCounter}</p>
</div>
<hr/>
<hr />
<div class="buttons">
<p>
ボタン群(仮)
</p>
<button class="btn" on:click={post}>Post(Ctrl+Enter)</button>
<button class="btn" on:click={chikuwa}>ちくわ。</button>
<button class="btn" on:click={WindowCenter}>画面中央</button>
<button class="btn" on:click={windowHide}>画面hide</button>
<button class="btn" on:click={windowShow}>画面show</button>
<button class="btn" on:click={earthquake}>地震だ!(F9)</button>
<button class="btn" on:click={version}>バージョン</button>
<button class="btn" on:click={OpenConfigDirectory}>設定の場所を開く(Ctrl+,)</button>
<button class="btn" on:click={OpenLogDirectory}>ログの場所を開く</button>
</div>
<p id="input-length"></p>
</main>

<style>
body {
font-family: "Avenir-Roman", "Arial", "游ゴシック体", YuGothic, "游ゴシック Medium", "Yu Gothic Medium", "游ゴシック", "Yu Gothic", sans-serif, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif, Helvetica Neue, Arial, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;
}
.result {
height: 1em;
line-height: 2em;
margin: 1.5rem auto;
}
.input-box .input {
border: none;
border-radius: 3px;
outline: none;
height: 30px;
line-height: 30px;
padding: 0 10px;
background-color: rgba(240, 240, 240, 0);
-webkit-font-smoothing: antialiased;
}
.input-box .input:hover {
border: none;
background-color: rgba(255, 255, 255, 0.2);
}
.input-box .input:focus {
border: none;
background-color: rgba(255, 255, 255, 0.2);
}
textarea {
color: white;
font-family: "Avenir-Roman", "Arial", "游ゴシック体", YuGothic, "游ゴシック Medium", "Yu Gothic Medium", "游ゴシック", "Yu Gothic", sans-serif, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif, Helvetica Neue, Arial, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji;
background: transparent;
resize: none;
border: 0 none;
width: 100%;
}
</style>
Loading

0 comments on commit bc376d6

Please sign in to comment.