Skip to content

Commit

Permalink
v3.4.21
Browse files Browse the repository at this point in the history
  • Loading branch information
gruppler committed Sep 12, 2024
2 parents 1ee66d5 + 729a5fb commit 0200b48
Show file tree
Hide file tree
Showing 9 changed files with 184 additions and 45 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ptn-ninja",
"version": "3.4.20",
"version": "3.4.21",
"description": "An editor and viewer for Portable Tak Notation",
"productName": "PTN Ninja",
"author": "Craig Laparo <gruppler+github@gmail.com>",
Expand Down
95 changes: 95 additions & 0 deletions public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# AI-Related Bots
User-agent: anthropic-ai
Disallow: /

User-agent: ChatGPT-User
Disallow: /

User-agent: Claude-Web
Disallow: /

User-agent: ClaudeBot
Disallow: /

User-agent: cohere-ai
Disallow: /

User-agent: GPTBot
Disallow: /

User-agent: PerplexityBot
Disallow: /

User-agent: Seekr
Disallow: /

User-agent: YouBot
Disallow: /

# General Crawlers and Indexing Bots
User-agent: Amazonbot
Disallow: /

User-agent: Applebot
Disallow: /

User-agent: Applebot-Extended
Disallow: /

User-agent: Bytespider
Disallow: /

User-agent: CCBot
Disallow: /

User-agent: DataForSeoBot
Disallow: /

User-agent: Diffbot
Disallow: /

User-agent: FacebookBot
Disallow: /

User-agent: Google-Extended
Disallow: /

User-agent: ImagesiftBot
Disallow: /

User-agent: Meltwater
Disallow: /

User-agent: Omgili
Disallow: /

User-agent: Omgilibot
Disallow: /

User-agent: PaperLiBot
Disallow: /

User-agent: Scrapy
Disallow: /

User-agent: SemrushBot
Disallow: /

User-agent: Swiftbot
Disallow: /

User-agent: TurnitinBot
Disallow: /

User-agent: weborama
Disallow: /

User-agent: garlik
Disallow: /

User-agent: hypefactors
Disallow: /

User-agent: seekport
Disallow: /

2 changes: 1 addition & 1 deletion src/Game/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export default class GameBase {

const handleError = (error) => {
if (this.onError) {
this.onError(error, this.plies.length - 1);
this.onError(error, this.plies.length);
} else {
throw error;
}
Expand Down
62 changes: 38 additions & 24 deletions src/Game/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,45 @@ export default class Game extends Aggregation(
GameMutations,
GameUndo
) {
static validate(ptn, silent = false) {
let result = true;
let game;
try {
// Parse the game
game = new Game({
ptn,
state: { plyIndex: 0 },
onError: (error, plyID) => {
result = error.message || error;
if (!silent) {
console.warn("Encountered an error at plyID:", plyID);
console.warn(error);
static validate(ptn, silent = false, multiple = false) {
const games = multiple ? Game.split(ptn) : [ptn];
let isValid = true;

const _validate = (ptn, i) => {
let game;
try {
// Parse the game
game = new Game({
ptn,
state: { plyIndex: 0 },
onError: (error, plyID) => {
isValid = isValid && (error.message || error);
if (!silent) {
console.warn(
`Encountered an error at ${
games.length > 1 ? "Game " + (i + 1) + ", " : ""
}plyID: ${plyID}`
);
console.warn(error);
}
},
});

// Navigate through each branch
Object.values(game.branches).forEach((ply) => {
if (isValid === true) {
game.board.goToPly(ply.id, true);
game.board.last();
}
},
});
});
} catch (error) {}
};

// Navigate through each branch
Object.values(game.branches).forEach((ply) => {
if (result === true) {
game.board.goToPly(ply.id, true);
game.board.last();
}
});
} catch (error) {}
return result;
if (games) {
games.forEach(_validate);
} else {
_validate(ptn);
}
return isValid;
}
}
6 changes: 5 additions & 1 deletion src/components/controls/PTNEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ export default {
header: "",
rules: [
(moves) => {
const result = Game.validate(this.header + moves);
const result = Game.validate(
this.header + moves,
false,
this.isNewGame
);
if (result === true) {
this.$emit("error", "");
return true;
Expand Down
31 changes: 23 additions & 8 deletions src/dialogs/AddGame.vue
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,31 @@ export default {
}
},
async clipboardCreate(ptn) {
let game;
try {
game = new Game({ ptn });
} catch (error) {
console.error(error);
}
const games = Game.split(ptn);
game.warnings.forEach((warning) => this.notifyWarning(warning));
const _createGame = (ptn, i) => {
try {
const game = new Game({ ptn });
game.warnings.forEach((warning) => {
console.log(i, warning);
this.notifyWarning(warning);
});
if (games.length > 1) {
game.name += " - " + this.$tc("Game x", i + 1);
}
games[i] = game;
} catch (error) {
console.error(error);
}
};
if (games) {
games.forEach(_createGame);
} else {
_createGame(ptn);
}
await this.$store.dispatch("game/ADD_GAME", game);
await this.$store.dispatch("game/ADD_GAMES", { games });
this.close();
},
playTak() {
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/en-us/about.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PTN Ninja

**Version [3.4.20](https://github.com/gruppler/PTN-Ninja/releases)**
**Version [3.4.21](https://github.com/gruppler/PTN-Ninja/releases)**

This is an editor and viewer for [Portable Tak Notation (PTN)](https://ustak.org/portable-tak-notation/). It aims to be...

Expand Down
1 change: 1 addition & 0 deletions src/i18n/en-us/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export default {
"From Center": "From Center",
"Full Link": "Full Link",
Fullscreen: "Fullscreen",
"Game x": "Game {count}",
"Game Info": "Game Info",
"Game Notifications": "Game Notifications",
"Game x closed": 'Closed "{game}"',
Expand Down
28 changes: 19 additions & 9 deletions src/store/game/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const IMPORT_FROM_CLIPBOARD = async function ({ dispatch }) {
} catch (error) {
console.error(error);
}
let game;
let games = [];
if (ptn) {
if (/^\d+$/.test(ptn)) {
// PlayTak game ID
Expand Down Expand Up @@ -151,7 +151,7 @@ export const IMPORT_FROM_CLIPBOARD = async function ({ dispatch }) {
if (!isEmpty(route.params)) {
try {
const params = parseURLparams(route);
game = new Game(params);
games[0] = new Game(params);
await dispatch("ADD_GAME", game);
return true;
} catch (error) {
Expand All @@ -160,9 +160,16 @@ export const IMPORT_FROM_CLIPBOARD = async function ({ dispatch }) {
}
}
}
} else if (Game.validate(ptn, true) === true) {
} else if (Game.validate(ptn, true, true) === true) {
// PTN
game = new Game({ ptn });
games = Game.split(ptn);
games = games.map((ptn, i) => {
const game = new Game({ ptn });
if (games.length > 1) {
game.name += " - " + i18n.tc("Game x", i + 1);
}
return game;
});
} else if (Ply.test(ptn) || Linenum.test(ptn)) {
// Plies
dispatch("INSERT_PLIES", { plies: ptn });
Expand All @@ -172,18 +179,18 @@ export const IMPORT_FROM_CLIPBOARD = async function ({ dispatch }) {
let tps = new TPS(ptn);
if (tps.isValid) {
tps = tps.text;
game = new Game({ tags: { tps } });
games[0] = new Game({ tags: { tps } });
} else {
// JSON
try {
let tags = JSON.parse(ptn);
game = new Game({ tags });
games[0] = new Game({ tags });
} catch (error) {}
}
}
}
if (ptn && game) {
await dispatch("ADD_GAME", game);
if (ptn && games && games.length) {
await dispatch("ADD_GAMES", { games });
return true;
} else {
router.push({ name: "add", params: { tab: "load", type: "ptn" } });
Expand Down Expand Up @@ -494,7 +501,10 @@ export const OPEN_FILES = async function ({ dispatch, state }, files) {
const name = file.name.replace(/(\.ptn|\.txt)+$/, "");
const games = Game.split(event.target.result);
games.forEach((ptn, i) => {
parseGame(ptn, `${name} - Game ${i + 1}`);
parseGame(
ptn,
games.length > 1 ? name + " - " + i18n.t("Game x", i + 1) : name
);
});
};
reader.onerror = notifyError;
Expand Down

0 comments on commit 0200b48

Please sign in to comment.