Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I mentioned to it by mistake. #115

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e36dbee
feat(emulater): firestore,functionsエミュレータを設定
komura-c Sep 2, 2020
6babc20
fix(emulater): app.module設定の分岐を統一
komura-c Sep 2, 2020
49c0fba
fix(#112): stringToLinkをPipeにする
komura-c Sep 2, 2020
3ce2e85
fix(#100): タブ切り替えで上に戻らないようにスクロール修正
komura-c Sep 3, 2020
c94588c
feat(mypage): mypageのsp表示を修正
komura-c Sep 3, 2020
fb88c53
feat(footer): footerのsp表示を修正
komura-c Sep 3, 2020
4cba850
fix(#111): プロフィールのアイコン少し小さくする(SP)
komura-c Sep 3, 2020
7d65cd2
fix(#99): 検索バー以外をクリックで検索バーを閉じるよう修正
komura-c Sep 3, 2020
705c9e1
feat(color): アクセントカラーをindigoにし、formに適用
komura-c Sep 4, 2020
15530c6
fix(#97): 設定画面の余白調整とカラー調整
komura-c Sep 4, 2020
1cd4990
fix(#102): 自分だったらフォローボタン出さない実装
komura-c Sep 4, 2020
c8a6f29
fix(mypage): 読み込んだ後に指定位置に戻す修正
komura-c Sep 4, 2020
9e44f03
feat(article): マイページ、記事一覧の最初の取得を20記事に制限
komura-c Sep 4, 2020
1ce8ddb
Apply Prettier Change
komura-c Sep 4, 2020
9f4eb0d
fix(develop): 開発環境のHostingでエミュレータに向いてしまっていたのを修正
komura-c Sep 4, 2020
808691c
Apply Prettier Change
komura-c Sep 4, 2020
ac95ed7
feat(footer): 一応自分のツイッターリンクを設定
komura-c Sep 4, 2020
d32b184
fix(firestore): rulesを一旦修正
komura-c Sep 4, 2020
e509af5
fix(mypage): スクロールアニメーション廃止、mypageスクロール修正
komura-c Sep 4, 2020
b8bd5c6
Apply Prettier Change
komura-c Sep 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"hosting": {
"public": "dist/musil",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "/**/n/**",
Expand All @@ -21,7 +25,8 @@
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
]
],
"source": "functions"
},
"storage": {
"rules": "storage.rules"
Expand Down
18 changes: 10 additions & 8 deletions firestore.rules
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@ rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /articles/{articleId} {
allow read: if true;
allow create: if request.auth.uid != null;
allow update: if request.auth.uid == resource.data.uid && resource.data.uid == request.resource.data.uid;
allow read: if resource.data.isPublic == true || request.auth.uid == resource.data.uid;
allow create: if request.auth.uid == request.resource.data.uid;
allow update: if request.auth.uid == resource.data.uid && request.resource.data.uid == resource.data.uid;
allow delete: if request.auth.uid == resource.data.uid;
}
match /users/{userId} {
allow read: if true;
allow write: if request.auth.uid == userId;
}
match /users/{userId}/likedArticles/{articleId} {
allow read: if true;
allow write: if request.auth.uid == userId;
allow create: if request.auth.uid == request.resource.data.uid;
allow update: if request.auth.uid == resource.data.uid && request.resource.data.uid == resource.data.uid;
allow delete: if request.auth.uid == resource.data.uid;
match /likedArticles/{articleId} {
allow read: if true;
allow write: if request.auth.uid == userId;
}
}
}
}
5 changes: 5 additions & 0 deletions functions/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ typings/

node_modules/
lib/
.runtimeconfig.json

firebase-debug.log
firestore-debug.log
ui-debug.log
19 changes: 17 additions & 2 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,16 @@ import {
import { FooterComponent } from './footer/footer.component';
import { AngularFireModule } from '@angular/fire';
import { AngularFireAnalyticsModule } from '@angular/fire/analytics';
import { AngularFirestoreModule } from '@angular/fire/firestore';
import {
AngularFirestoreModule,
SETTINGS as FIRESTORE_SETTINGS,
} from '@angular/fire/firestore';
import { AngularFireStorageModule } from '@angular/fire/storage';
import { AngularFireFunctionsModule, REGION } from '@angular/fire/functions';
import {
AngularFireFunctionsModule,
REGION,
ORIGIN,
} from '@angular/fire/functions';
import { AngularFireAuthModule } from '@angular/fire/auth';
import { environment } from '../environments/environment';
import { FroalaEditorModule, FroalaViewModule } from 'angular-froala-wysiwyg';
Expand Down Expand Up @@ -75,6 +82,14 @@ import { MatPaginatorIntlJaModule } from './mat-paginator-intl-ja/mat-paginator-
{ provide: REGION, useValue: 'asia-northeast1' },
{ provide: MAT_SNACK_BAR_DEFAULT_OPTIONS, useValue: { duration: 4000 } },
{ provide: MatPaginatorIntl, useClass: MatPaginatorIntlJaModule },
// {
// provide: ORIGIN,
// useValue: environment.production ? undefined : 'http://localhost:5001',
// },
// {
// provide: FIRESTORE_SETTINGS,
// useValue: environment.production ? {} : { host: 'localhost:8080', ssl: false },
// },
],
bootstrap: [AppComponent],
})
Expand Down
5 changes: 4 additions & 1 deletion src/app/footer/footer.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@
>お問い合わせ(TwitterDM)<mat-icon>open_in_new</mat-icon></a
>
</div>
<p class="copyright">&copy; 2020 MusiL by komura</p>
<p class="copyright">
&copy; 2020 MusiL by
<a href="https://twitter.com/komura_c">komura</a>
</p>
</footer>
8 changes: 8 additions & 0 deletions src/app/footer/footer.component.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import 'mixins';

.footer {
background-color: inherit;
padding: 16px 0 32px;
Expand All @@ -8,6 +10,9 @@
a {
margin: 0 8px 8px;
text-align: center;
@include sp {
font-size: 14px;
}
}
}
}
Expand All @@ -17,4 +22,7 @@ mat-icon {
.copyright {
text-align: center;
margin: 8px 0px;
@include sp {
font-size: 14px;
}
}
2 changes: 1 addition & 1 deletion src/app/mypage/liked-articles/liked-articles.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class LikedArticlesComponent implements OnInit {
articles$: Observable<
ArticleWithAuthor[]
> = this.articleService
.getMyLikedArticles(this.userService.mypageUser.uid)
.getMyLikedArticles(this.userService.mypageUser?.uid)
.pipe(
take(1),
tap(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/mypage/my-articles/my-articles.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class MyArticlesComponent implements OnInit {
articles$: Observable<
ArticleWithAuthor[]
> = this.articleService
.getMyArticlesPublic(this.userService.mypageUser.uid)
.getMyArticlesPublic(this.userService.mypageUser?.uid)
.pipe(
take(1),
tap(() => {
Expand Down
2 changes: 2 additions & 0 deletions src/app/mypage/mypage.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ import { ClipboardModule } from '@angular/cdk/clipboard';
import { MyArticlesComponent } from './my-articles/my-articles.component';
import { LikedArticlesComponent } from './liked-articles/liked-articles.component';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { StringToLinkPipe } from '../pipes/string-to-link.pipe';

@NgModule({
declarations: [
MypageComponent,
NoteComponent,
MyArticlesComponent,
LikedArticlesComponent,
StringToLinkPipe,
],
imports: [
CommonModule,
Expand Down
3 changes: 2 additions & 1 deletion src/app/mypage/mypage/mypage.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h2 class="mypage__user-name">{{ user.userName }}</h2>
<p class="mypage__user-screen-name">@{{ user.screenName }}</p>
<p
class="mypage__user-description"
[innerHTML]="stringToLink(user.description)"
[innerHTML]="user.description | stringToLink"
></p>
<a
mat-flat-button
Expand All @@ -33,6 +33,7 @@ <h2 class="mypage__user-name">{{ user.userName }}</h2>
class="mypage__twitter"
target="_blank"
rel="noopener noreferrer"
*ngIf="user.uid !== authService.uid"
>
<mat-icon
><img src="/assets/icons/twitter-logo-white.png" alt="Twitterロゴ"
Expand Down
22 changes: 22 additions & 0 deletions src/app/mypage/mypage/mypage.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,39 @@
height: 120px;
border-radius: 50%;
margin: 16px 0px;
@include sp {
width: 100px;
height: 100px;
}
}
&__user-name {
font-size: 20px;
font-weight: bold;
margin: 0 0 8px;
@include sp {
font-size: 18px;
}
}
&__user-screen-name {
font-size: 16px;
margin: 0 0 8px;
@include sp {
font-size: 14px;
}
}
&__user-description {
font-size: 16px;
margin: 0 0 16px;
@include sp {
font-size: 14px;
}
}
&__twitter {
text-decoration: none;
background-color: $color-twitter;
@include sp {
font-size: 14px;
}
}
&__menu {
max-width: 600px;
Expand All @@ -51,9 +67,15 @@

.edit-profile {
margin-left: auto;
@include sp {
font-size: 14px;
}
}

.mat-tab-link {
font-size: 16px;
text-decoration: none;
@include sp {
font-size: 14px;
}
}
31 changes: 18 additions & 13 deletions src/app/mypage/mypage/mypage.component.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import {
ActivatedRoute,
Router,
NavigationEnd,
NavigationStart,
} from '@angular/router';
import { UserData } from 'functions/src/interfaces/user';
import { Observable } from 'rxjs';
import { map, switchMap, tap, take } from 'rxjs/operators';
import { AuthService } from 'src/app/services/auth.service';
import { LoadingService } from 'src/app/services/loading.service';
import { UserService } from 'src/app/services/user.service';
import { SeoService } from 'src/app/services/seo.service';
import { ScrollService } from 'src/app/services/scroll.service';

@Component({
selector: 'app-mypage',
Expand Down Expand Up @@ -46,24 +52,23 @@ export class MypageComponent implements OnInit {
isLoading = true;

constructor(
private router: Router,
private route: ActivatedRoute,
private userService: UserService,
private loadingService: LoadingService,
private seoService: SeoService,
public authService: AuthService
public authService: AuthService,
private scrollService: ScrollService
) {
this.loadingService.toggleLoading(true);
this.router.events.forEach((event) => {
if (event instanceof NavigationStart) {
this.scrollService.saveScrollPosition('mypage');
}
if (event instanceof NavigationEnd) {
this.scrollService.restoreScrollPosition('mypage');
}
});
}

stringToLink(description: string): string {
const linkReg = new RegExp(
/(http(s)?:\/\/[a-zA-Z0-9-.!'()*;/?:@&=+$,%#]+)/gi
);
const toATag =
"<a href='$1' target='_blank' rel='noopener noreferrer'>$1</a>";
const link = description.replace(linkReg, toATag);
return link;
}

ngOnInit(): void {}
}
3 changes: 2 additions & 1 deletion src/app/mypage/note/note.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ <h1 class="note-header__title">{{ article.title }}</h1>
>
<p
class="note-footer__user-description"
[innerHTML]="stringToLink(article.author.description)"
[innerHTML]="article.author.description | stringToLink"
></p>
<a
mat-flat-button
Expand All @@ -190,6 +190,7 @@ <h1 class="note-header__title">{{ article.title }}</h1>
class="note-footer__twitter"
target="_blank"
rel="noopener noreferrer"
*ngIf="article.author.uid !== authService.uid"
>
<mat-icon
><img
Expand Down
10 changes: 10 additions & 0 deletions src/app/mypage/note/note.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,25 @@
height: 80px;
border-radius: 50%;
max-width: 80px;
@include sp {
width: 60px;
height: 60px;
}
}
&__user-name {
display: block;
font-weight: bold;
font-size: 18px;
margin-bottom: 8px;
@include sp {
font-size: 16px;
}
}
&__user-description {
margin: 0 0 8px 0;
@include sp {
font-size: 14px;
}
}
&__twitter {
.mat-icon {
Expand Down
16 changes: 1 addition & 15 deletions src/app/mypage/note/note.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class NoteComponent implements OnInit, OnDestroy {
const rectTop = document.getElementById(id).getBoundingClientRect().top;
const position = window.pageYOffset;
const top = rectTop + position - this.headerHeight;
window.scrollTo({
window.scroll({
top,
behavior: 'smooth',
});
Expand All @@ -147,20 +147,6 @@ export class NoteComponent implements OnInit, OnDestroy {
}, 100);
}

stringToLink(description: string): string {
const linkReg = new RegExp(
/(http(s)?:\/\/[a-zA-Z0-9-.!'()*;/?:@&=+$,%#]+)/gi
);
if (linkReg.test(description)) {
const toATag =
"<a href='$1' target='_blank' rel='noopener noreferrer'>$1</a>";
const link = description.replace(linkReg, toATag);
return link;
} else {
return description;
}
}

clickedLike(articleId: string) {
if (this.authService.uid && !this.isLiked) {
this.likeService.likeArticle(articleId, this.authService.uid);
Expand Down
7 changes: 5 additions & 2 deletions src/app/notes/create/create.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="editor">
<form class="editor__form" [formGroup]="form">
<div class="editor__header">
<mat-form-field class="editor__title">
<mat-form-field class="editor__title" color="accent">
<input
type="text"
formControlName="title"
Expand Down Expand Up @@ -30,7 +30,10 @@
<app-editor [parentForm]="form"></app-editor>
</div>
<div class="editor__buttons">
<mat-slide-toggle class="public-option" formControlName="isPublic"
<mat-slide-toggle
class="public-option"
formControlName="isPublic"
color="primary"
>公開</mat-slide-toggle
>
<button type="button" class="cancel-button" mat-button (click)="cancel()">
Expand Down
2 changes: 1 addition & 1 deletion src/app/notes/tag-form/tag-form.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div [formGroup]="parentForm">
<mat-form-field class="tag-form">
<mat-form-field class="tag-form" color="accent">
<mat-chip-list #chipList aria-label="タグセレクション">
<mat-chip
*ngFor="let tag of tags"
Expand Down
Loading