Skip to content

Commit fd11e54

Browse files
committed
add fallback search to Brave, Google or Bing when no results
1 parent e4864f9 commit fd11e54

8 files changed

+92
-13
lines changed

frontend/angular.json

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,5 @@
157157
}
158158
}
159159
},
160-
"defaultProject": "bookmarks",
161-
"schematics": {
162-
"@schematics/angular:component": {
163-
"prefix": "app",
164-
"styleext": "scss"
165-
},
166-
"@schematics/angular:directive": {
167-
"prefix": "app"
168-
}
169-
}
160+
"defaultProject": "bookmarks"
170161
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<div class="find-elsewhere-options">
2+
<span><i class="fa fa-search"></i> Find elsewhere</span>
3+
<a
4+
href="https://search.brave.com/search?q={{searchText}}"
5+
class="btn btn-outline-secondary btn-sm mr-3 mt-2 tag-list-header shadow-sm"
6+
title="Find with Brave"
7+
target="_blank"
8+
>
9+
Brave
10+
</a>
11+
<a
12+
href="https://www.google.com/search?q={{searchText}}"
13+
class="btn btn-outline-secondary btn-sm mr-3 mt-2 tag-list-header shadow-sm"
14+
title="Find with Google"
15+
target="_blank"
16+
>
17+
Google
18+
</a>
19+
<a
20+
href="https://www.bing.com/search?q={{searchText}}"
21+
class="btn btn-outline-secondary btn-sm mr-3 mt-2 tag-list-header shadow-sm"
22+
title="Find with Bing"
23+
target="_blank"
24+
>
25+
Bing
26+
</a>
27+
</div>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.find-elsewhere-options {
2+
font-size: 1.05rem;
3+
margin-top: 1rem;
4+
padding-left: 2rem;
5+
span {
6+
margin-right: 1rem;
7+
}
8+
a {
9+
display: inline;
10+
vertical-align: middle;
11+
font-size: 1.02rem;
12+
}
13+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { FindElsewhereComponent } from './find-elsewhere.component';
4+
5+
describe('FindElsewhereComponent', () => {
6+
let component: FindElsewhereComponent;
7+
let fixture: ComponentFixture<FindElsewhereComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
declarations: [ FindElsewhereComponent ]
12+
})
13+
.compileComponents();
14+
});
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(FindElsewhereComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Component, Input, OnInit } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-find-elsewhere',
5+
templateUrl: './find-elsewhere.component.html',
6+
styleUrls: ['./find-elsewhere.component.scss']
7+
})
8+
export class FindElsewhereComponent implements OnInit {
9+
10+
@Input()
11+
searchText: any;
12+
13+
constructor() {
14+
}
15+
16+
ngOnInit(): void {
17+
}
18+
19+
}

frontend/src/app/search-results/search-results.component.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
</button>
118118
</span>
119119
<br/>
120-
You can also try looking in other categories 👆👆
120+
{{searchInOtherCategoriesTip}}
121121
</div>
122122
<ng-template #showPubliBookmarksResults>
123123
<app-async-bookmark-list
@@ -170,3 +170,6 @@
170170
</mat-tab>
171171

172172
</mat-tab-group>
173+
174+
<app-find-elsewhere *ngIf="(searchResults$ | async)?.length === 0 && currentPage === 1" [searchText]="searchText">
175+
</app-find-elsewhere>

frontend/src/app/search-results/search-results.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class SearchResultsComponent implements OnInit, OnDestroy {
4646

4747
searchTriggeredSubscription: any;
4848

49-
searchInOtherCategoriesTip = 'You can also try looking in other categories 👆👆';
49+
searchInOtherCategoriesTip = 'You can also try looking in other sections 👆👆 OR ';
5050

5151
constructor(private route: ActivatedRoute,
5252
private router: Router,

frontend/src/app/search-results/search-results.module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { MySnippetsModule } from '../my-snippets/my-snippets.module';
55
import { SharedModule } from '../shared/shared.module';
66
import { RouterModule, Routes } from '@angular/router';
77
import { MatTabsModule } from '@angular/material/tabs';
8+
import { FindElsewhereComponent } from './find-elsewhere/find-elsewhere.component';
89

910
const searchResultsRoutes: Routes = [
1011
{
@@ -14,7 +15,7 @@ const searchResultsRoutes: Routes = [
1415
];
1516

1617
@NgModule({
17-
declarations: [SearchResultsComponent],
18+
declarations: [SearchResultsComponent, FindElsewhereComponent],
1819
imports: [
1920
RouterModule.forChild(searchResultsRoutes),
2021
CommonModule,

0 commit comments

Comments
 (0)