Skip to content

Commit

Permalink
Merge pull request #1033 from atsu1125/avoidsearchindex
Browse files Browse the repository at this point in the history
Feat: AvoidSearchIndex
  • Loading branch information
fs5m8 authored Dec 15, 2022
2 parents 992a4b9 + 41f664b commit 29b58d5
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 5 deletions.
1 change: 1 addition & 0 deletions locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,7 @@ common/views/components/profile-editor.vue:
careful-bot: "Follower requests from bots require approval"
careful-remote: "Follower requests from remote require approval"
auto-accept-followed: "Automatically approve follows from the people you follow"
avoid-search-index: "Avoid search engine index"
advanced: "Other"
privacy: "Privacy"
save: "Save"
Expand Down
1 change: 1 addition & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,7 @@ common/views/components/profile-editor.vue:
careful-bot: "Bot からのフォローだけ承認制にする"
careful-remote: "リモートからのフォローだけ承認制にする"
auto-accept-followed: "フォローしているユーザーからのフォローを自動承認する"
avoid-search-index: "検索エンジンによるインデックスを避ける"
advanced: "その他"
privacy: "プライバシー"
save: "保存"
Expand Down
14 changes: 14 additions & 0 deletions migration/1671119579013-avoidsearchindex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {MigrationInterface, QueryRunner} from "typeorm";

export class avoidsearchindex1671119579013 implements MigrationInterface {
name = 'avoidsearchindex1671119579013'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "user" ADD "avoidSearchIndex" boolean NOT NULL DEFAULT false`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "avoidSearchIndex"`);
}

}
6 changes: 5 additions & 1 deletion src/client/app/common/views/components/settings/profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
<ui-switch v-model="carefulBot" :disabled="isLocked" @change="save(false)">{{ $t('careful-bot') }}</ui-switch>
<ui-switch v-model="carefulRemote" :disabled="isLocked" @change="save(false)">{{ $t('careful-remote') }}</ui-switch>
<ui-switch v-model="autoAcceptFollowed" :disabled="!isLocked && !carefulBot && !carefulRemote" @change="save(false)">{{ $t('auto-accept-followed') }}</ui-switch>
<ui-switch v-model="avoidSearchIndex" @change="save(false)">{{ $t('avoid-search-index') }}</ui-switch>
</div>
</section>

Expand Down Expand Up @@ -178,6 +179,7 @@ export default Vue.extend({
carefulBot: false,
carefulRemote: false,
autoAcceptFollowed: false,
avoidSearchIndex: false,
saving: false,
avatarUploading: false,
bannerUploading: false,
Expand Down Expand Up @@ -220,6 +222,7 @@ export default Vue.extend({
this.carefulBot = this.$store.state.i.carefulBot;
this.carefulRemote = this.$store.state.i.carefulRemote;
this.autoAcceptFollowed = this.$store.state.i.autoAcceptFollowed;
this.avoidSearchIndex = this.$store.state.i.avoidSearchIndex;
this.fieldName0 = this.$store.state.i.fields[0] ? this.$store.state.i.fields[0].name : null;
this.fieldValue0 = this.$store.state.i.fields[0] ? this.$store.state.i.fields[0].value : null;
Expand Down Expand Up @@ -300,7 +303,8 @@ export default Vue.extend({
isLocked: !!this.isLocked,
carefulBot: !!this.carefulBot,
carefulRemote: !!this.carefulRemote,
autoAcceptFollowed: !!this.autoAcceptFollowed
autoAcceptFollowed: !!this.autoAcceptFollowed,
avoidSearchIndex: !!this.avoidSearchIndex,
}).then(i => {
this.saving = false;
this.$store.state.i.avatarId = i.avatarId;
Expand Down
5 changes: 5 additions & 0 deletions src/models/entities/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ export class User {
@JoinColumn()
public movedToUser: User | null;

@Column('boolean', {
default: false,
})
public avoidSearchIndex: boolean;

constructor(data: Partial<User>) {
if (data == null) return;

Expand Down
1 change: 1 addition & 0 deletions src/models/repositories/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export class UserRepository extends Repository<User> {
isCat: user.isCat || falsy,
isVerified: user.isVerified || falsy,
isPremium: user.isPremium || falsy,
avoidSearchIndex: user.avoidSearchIndex || falsy,

// カスタム絵文字添付
emojis: populateEmojis(user.emojis, user.host),
Expand Down
8 changes: 8 additions & 0 deletions src/server/api/endpoints/i/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ export const meta = {
}
},

avoidSearchIndex: {
validator: $.optional.bool,
desc: {
'ja-JP': '検索エンジンによるインデックスを避けるか'
}
},

isBot: {
validator: $.optional.bool,
desc: {
Expand Down Expand Up @@ -202,6 +209,7 @@ export default define(meta, async (ps, user, app) => {
if (typeof ps.carefulBot == 'boolean') profileUpdates.carefulBot = ps.carefulBot;
if (typeof ps.carefulRemote == 'boolean') profileUpdates.carefulRemote = ps.carefulRemote;
if (typeof ps.autoAcceptFollowed == 'boolean') profileUpdates.autoAcceptFollowed = ps.autoAcceptFollowed;
if (typeof ps.avoidSearchIndex == 'boolean') updates.avoidSearchIndex = ps.avoidSearchIndex;
if (typeof ps.isCat == 'boolean') updates.isCat = ps.isCat;
if (typeof ps.autoWatch == 'boolean') profileUpdates.autoWatch = ps.autoWatch;
if (typeof ps.alwaysMarkNsfw == 'boolean') profileUpdates.alwaysMarkNsfw = ps.alwaysMarkNsfw;
Expand Down
4 changes: 3 additions & 1 deletion src/server/web/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,14 @@ router.get('/streaming', async ctx => {
// Render base html for all requests
router.get('*', async ctx => {
const meta = await fetchMeta();
const noindex = ctx.path.match(/^[/](search|tags[/]|explore|featured)/);
await ctx.render('base', {
img: meta.bannerUrl,
title: meta.name || 'Misskey',
instanceName: meta.name || 'Misskey',
desc: meta.description,
icon: meta.iconUrl
icon: meta.iconUrl,
noindex
});
ctx.set('Cache-Control', 'public, max-age=300');
});
Expand Down
3 changes: 3 additions & 0 deletions src/server/web/views/base.pug
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ html
link(rel='apple-touch-icon' href= icon || '/apple-touch-icon.png')
link(rel='manifest' href='/manifest.json')

if noindex
meta(name='robots' content='noindex')

title
block title
= title || 'Areionskey'
Expand Down
2 changes: 1 addition & 1 deletion src/server/web/views/note.pug
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ block meta
meta(name='twitter:card' content='summary')

// todo
if user.host
if user.host || user.avoidSearchIndex
meta(name='robots' content='noindex')

if user.twitter
Expand Down
2 changes: 1 addition & 1 deletion src/server/web/views/page.pug
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ block meta

meta(name='twitter:card' content='summary')

if user.host
if user.host || user.avoidSearchIndex
meta(name='robots' content='noindex')

// todo
Expand Down
2 changes: 1 addition & 1 deletion src/server/web/views/user.pug
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ block meta

meta(name='twitter:card' content='summary')

if user.host
if user.host || user.avoidSearchIndex
meta(name='robots' content='noindex')

if profile.twitter
Expand Down

0 comments on commit 29b58d5

Please sign in to comment.