From 2aa415842a0acf8695f9f8cbbc9ab0834a304d93 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Jul 10 2018 13:11:40 +0000 Subject: [PATCH 1/6] update icons --- diff --git a/src/assets/img/a.svg b/src/assets/img/a.svg deleted file mode 100755 index b6e618e..0000000 --- a/src/assets/img/a.svg +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/src/assets/img/ask_back.png b/src/assets/img/ask_back.png deleted file mode 100644 index 84d8866..0000000 Binary files a/src/assets/img/ask_back.png and /dev/null differ diff --git a/src/assets/img/ask_logo.svg b/src/assets/img/ask_logo.svg deleted file mode 100644 index d2cc127..0000000 --- a/src/assets/img/ask_logo.svg +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - diff --git a/src/assets/img/back.png b/src/assets/img/back.png deleted file mode 100644 index 76071ae..0000000 Binary files a/src/assets/img/back.png and /dev/null differ diff --git a/src/assets/img/c.svg b/src/assets/img/c.svg deleted file mode 100755 index b286089..0000000 --- a/src/assets/img/c.svg +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/src/assets/img/cal_logo.svg b/src/assets/img/cal_logo.svg deleted file mode 100644 index 22cd8a7..0000000 --- a/src/assets/img/cal_logo.svg +++ /dev/null @@ -1,165 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/assets/img/downvote.svg b/src/assets/img/downvote.svg new file mode 100644 index 0000000..8e590ea --- /dev/null +++ b/src/assets/img/downvote.svg @@ -0,0 +1,20 @@ + + + + ion-android-arrow-dropup - Ionicons Copy + Created with Sketch. + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/assets/img/logo.svg b/src/assets/img/logo.svg deleted file mode 100644 index 2c9e7a5..0000000 --- a/src/assets/img/logo.svg +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - diff --git a/src/assets/img/m.svg b/src/assets/img/m.svg deleted file mode 100755 index 7028006..0000000 --- a/src/assets/img/m.svg +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/src/assets/img/mag_logo.svg b/src/assets/img/mag_logo.svg deleted file mode 100644 index a9fe9ce..0000000 --- a/src/assets/img/mag_logo.svg +++ /dev/null @@ -1,271 +0,0 @@ - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - diff --git a/src/assets/img/mag_title.svg b/src/assets/img/mag_title.svg deleted file mode 100644 index 0613fa8..0000000 --- a/src/assets/img/mag_title.svg +++ /dev/null @@ -1,182 +0,0 @@ - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/assets/img/s.svg b/src/assets/img/s.svg deleted file mode 100755 index b4f4d2d..0000000 --- a/src/assets/img/s.svg +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/src/assets/img/social_back.png b/src/assets/img/social_back.png deleted file mode 100644 index 620f791..0000000 Binary files a/src/assets/img/social_back.png and /dev/null differ diff --git a/src/assets/img/social_icon.svg b/src/assets/img/social_icon.svg deleted file mode 100644 index 6bf9e04..0000000 --- a/src/assets/img/social_icon.svg +++ /dev/null @@ -1,208 +0,0 @@ - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/assets/img/upvote.svg b/src/assets/img/upvote.svg new file mode 100644 index 0000000..c588e78 --- /dev/null +++ b/src/assets/img/upvote.svg @@ -0,0 +1,20 @@ + + + + ion-android-arrow-dropup - Ionicons + Created with Sketch. + + + + + + + + + + + + + + + \ No newline at end of file From aed1c5a0b83c26c72d25ed60ebd3114fb192f783 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Jul 10 2018 13:11:49 +0000 Subject: [PATCH 2/6] add relative time helper --- diff --git a/src/utils.ts b/src/utils.ts index 8ea8f46..ab8342b 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -40,7 +40,52 @@ export function beautifyDate(postDate: any, type: string): string { } /** - * Return the type of package from it names. + * Function to convert EPOCH time to relative time + * @param timestamp actual timestamp of the post + * @returns Relative time in format HH/MM ago + */ + +export function convertToRelativeTime(timestamp: any): string { + //convert EPOCH Time to javascript time + timestamp = parseInt(timestamp) * 1000; + + //get current time + var current: any = new Date(); + + var msPerMinute = 60 * 1000; + var msPerHour = msPerMinute * 60; + var msPerDay = msPerHour * 24; + var msPerMonth = msPerDay * 30; + var msPerYear = msPerDay * 365; + + var elapsed = current - timestamp; + + if (elapsed < msPerMinute) { + return Math.round(elapsed / 1000) + ' seconds ago'; + } + + else if (elapsed < msPerHour) { + return Math.round(elapsed / msPerMinute) + ' minutes ago'; + } + + else if (elapsed < msPerDay) { + return Math.round(elapsed / msPerHour) + ' hours ago'; + } + + else if (elapsed < msPerMonth) { + return Math.round(elapsed / msPerDay) + ' days ago'; + } + + else if (elapsed < msPerYear) { + return Math.round(elapsed / msPerMonth) + ' months ago'; + } + + else { + return Math.round(elapsed / msPerYear) + ' years ago'; + } +} + + /* Return the type of package from it names. * * Matches the name against the Fedora packaging guidelines * Taken from: https://fedoraproject.org/wiki/Packaging:Naming?rd=Packaging:NamingGuidelines From 99cd23c254235fd7f95bd92e672581af490d06c7 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Jul 10 2018 13:12:07 +0000 Subject: [PATCH 3/6] add attribute to askfedora --- diff --git a/src/providers/ask-fedora/ask-fedora.ts b/src/providers/ask-fedora/ask-fedora.ts index 0664361..4e315e0 100644 --- a/src/providers/ask-fedora/ask-fedora.ts +++ b/src/providers/ask-fedora/ask-fedora.ts @@ -6,7 +6,7 @@ import { Observable } from 'rxjs/Observable'; import { fromPromise } from 'rxjs/observable/fromPromise'; import { merge } from 'rxjs/observable/merge'; import { map, tap } from 'rxjs/operators'; -import { defaultValue } from '../../utils'; +import { defaultValue, convertToRelativeTime} from '../../utils'; /** * Ask Fedora API endpoint @@ -53,7 +53,7 @@ export interface Question { /** * Time of posting of this question */ - addedAt: Date, + addedAt: string, /** * Tags associated with this question @@ -98,8 +98,8 @@ export class AskFedoraService { * * @returns Observable which emits an array of questions */ - fetchQuestions(): Observable { - return this.http.get(`${ENDPOINT}/questions/`) + fetchQuestions(type:string): Observable { + return this.http.get(`${ENDPOINT}/questions/`,{ params: { 'sort': type + '-desc' } }) .pipe( map((data: any) => (data.questions as any[]).map(q => ({ id: q.id, @@ -107,8 +107,8 @@ export class AskFedoraService { link: q.url, answerCount: q.answer_count, content: q.summary, - addedAt: new Date(parseInt(q.added_at, 10)), - tags: q.tags, + addedAt: convertToRelativeTime(q.last_activity_at), + tags: q.tags.toString().split(','), viewCount: q.view_count, score: q.score, }))) @@ -122,8 +122,8 @@ export class AskFedoraService { * * @returns Observable which emits an array of questions */ - getQuestions(): Observable { - return merge(this.loadCachedQuestions(), this.fetchQuestions().pipe( + getQuestions(type:string): Observable { + return merge(this.loadCachedQuestions(), this.fetchQuestions(type).pipe( tap(x => this.storage.set(STORAGE_KEY, x))) ); } From 195347ade8b89afc3f05438fdd16b6c1e5c54a92 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Jul 10 2018 13:12:26 +0000 Subject: [PATCH 4/6] add ask page template --- diff --git a/src/pages/ask/ask.html b/src/pages/ask/ask.html index 6440d60..90a1389 100644 --- a/src/pages/ask/ask.html +++ b/src/pages/ask/ask.html @@ -1,59 +1,48 @@ - - - - - - - - - - - - - - - - - - {{ question.title }} - - - - - - - - - - - {{ question.score }} -
- VOTE -
- - {{ question.answerCount }} -
- Ans -
- - {{ question.viewCount }} -
- VIEW -
-
-
-
-
+ + + + Fedora + + + + + + + + + + Latest + + + Most Voted + + + Popular + + + + + + + + + {{question.score}} + + + + + {{question.title}} + + + {{tag}} + + + + + + + + + \ No newline at end of file From f587ccb21dd59d484c71a6628bc6e51ae67d35ed Mon Sep 17 00:00:00 2001 From: Abhishek Date: Jul 10 2018 13:12:37 +0000 Subject: [PATCH 5/6] add ask page styles --- diff --git a/src/pages/ask/ask.scss b/src/pages/ask/ask.scss index 6651340..f9a7336 100644 --- a/src/pages/ask/ask.scss +++ b/src/pages/ask/ask.scss @@ -1,59 +1,48 @@ -.ask { - background-color: #ffffff !important; - background: url('../../ask_back.png'); -} - - -#ask_logo{ - z-index: 1; - display:block; - position:absolute; - left:0; - right:0; - top:40px; - margin:auto; -} - -.search_bar{ - margin-top: 40px; -} - -#ask_list{ - margin-top: 20px; -} - -.searchbar-input{ - background-color: rgba(0, 0, 0, 0.7); - color: white; -} - -#ask_ques{ - background-color: #16160f; - color: #d0e296; -} - -.button{ - background-color: transparent; - box-shadow: 0; -} - -ion-card{ - background-color: #e9e9e1 !important; -} - -#vote{ - background-color: #4a757f; - text-align: center; -} -#ans{ - background-color: #eab243; - text-align: center; -} -#view{ - background-color: #d33f00; - text-align: center; -} -#stats ion-col{ - padding: 10px 0; - color: #ffffff; -} +.questions { + background-color: #EFF0F1 !important; + ion-card { + padding: 16px; + background-color: #FFFFFF !important; + box-shadow: none; + margin: 4px 0 !important; + width: 100%; + [col-11] { + padding: 0 0 0 4px !important; + } + [col-1] { + text-align: center; + padding: 0 !important; + } + img { + height: 5px; + } + span { + font-family: "OpenSans-Bold"; + font-size: 14px; + color: #3C6EB4; + letter-spacing: 0; + text-align: center; + line-height: 20px; + } + ion-card-header { + padding: 0 !important; + } + ion-card-content { + margin-top: 4px; + padding: 0 !important; + font-size: 12px !important; + } + .label { + padding: 4px; + font-family: "OpenSans-Semibold"; + font-size: 8px; + color: #3C6EB4; + display: inline-block; + margin: 8px 8px 0 0; + text-transform: lowercase; + letter-spacing: 0; + background: rgba(#E8EFF8, 0.5); + border-radius: 2px; + } + } +} \ No newline at end of file From c79ad665853e4ef9eab49c74197e3224f11d431e Mon Sep 17 00:00:00 2001 From: Abhishek Date: Jul 10 2018 13:12:44 +0000 Subject: [PATCH 6/6] add ask page logic --- diff --git a/src/pages/ask/ask.ts b/src/pages/ask/ask.ts index f36a30e..f24aa27 100644 --- a/src/pages/ask/ask.ts +++ b/src/pages/ask/ask.ts @@ -1,5 +1,4 @@ import { Component } from '@angular/core'; -import { SocialSharing } from '@ionic-native/social-sharing'; import { Browser } from '../../providers/browser/browser'; import { AskFedoraService, Question } from '../../providers/ask-fedora/ask-fedora'; @@ -14,6 +13,10 @@ import { AskFedoraService, Question } from '../../providers/ask-fedora/ask-fedor providers: [Browser, AskFedoraService], }) export class AskPage { + /** + * Set active segment as latest questions + */ + showQuestionsBy: String = "new"; /** * Stores list of displayed questions @@ -21,25 +24,39 @@ export class AskPage { private questions: Question[]; constructor(private browser: Browser, - private askFedora: AskFedoraService, private socialSharing: SocialSharing) { + private askFedora: AskFedoraService) { this.questions = []; } ngOnInit() { - this.updateQuestions(); + this.updateQuestions('activity'); } /** * Fetch a list of latest questions using Ask Fedora API. */ - updateQuestions(): void { + updateQuestions(type: string): void { this.askFedora - .getQuestions() + .getQuestions(type) .subscribe(questions => { this.questions = questions || []; }); } + onSegmentChange() { + switch (this.showQuestionsBy) { + case "new": + this.updateQuestions('activity'); + break; + case "votes": + this.updateQuestions('votes'); + break; + case "answers": + this.updateQuestions('answers'); + break; + } + } + /** * Open a question in a browser. * @@ -50,21 +67,4 @@ export class AskPage { openQuestion(question: Question): void { this.browser.open(question.link); } - - /** - * Share the question using a third-party app installed in the user's device - * - * Allows to share the question using apps like WhatsApp, Facebook, or any app that - * exposes a share interface to the underlying OS. - * - * @param question question to share - */ - shareQuestion(question: Question): void { - this.socialSharing.share( - question.content, - question.title, - null, - question.link - ); - } }