Skip to content

Commit

Permalink
add mirror view and subscribe buttons
Browse files Browse the repository at this point in the history
ref #467
  • Loading branch information
collinbarrett committed Sep 10, 2018
1 parent 2df84ff commit 8586e45
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/FilterLists.Web/ClientApp/components/ListDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ function ListInfo(props: any) {
function ListUrls(props: any) {
return <div className="col-3 p-0 btn-group-vertical justify-content-start d-flex align-items-end">
<SubscribeUrl url={props.details.viewUrl} name={props.details.name}/>
<SubscribeUrlMirror url={props.details.viewUrlMirror1} name={props.details.name}/>
<SubscribeUrlMirror url={props.details.viewUrlMirror2} name={props.details.name}/>
<ViewUrl url={props.details.viewUrl} name={props.details.name}/>
<ViewUrlMirror url={props.details.viewUrlMirror1} name={props.details.name}/>
<ViewUrlMirror url={props.details.viewUrlMirror2} name={props.details.name}/>
<HomeUrl url={props.details.homeUrl} name={props.details.name}/>
<PolicyUrl url={props.details.policyUrl} name={props.details.name}/>
<DonateUrl url={props.details.donateUrl} name={props.details.name}/>
Expand Down Expand Up @@ -199,6 +203,30 @@ function SubscribeUrl(props: any) {
}
};

function SubscribeUrlMirror(props: any) {
return props.url
? props.url.indexOf("https://") === -1
? SubscribeUrlNotSecure()
: SubscribeUrlSecondary()
: null;

function SubscribeUrlSecondary() {
return <a href={`abp:subscribe?location=${encodeURIComponent(props.url)}&amp;title=${encodeURIComponent(props.name)}`}
className="btn btn-secondary btn-block fl-btn-details-action"
title={`Mirror - Subscribe to list with browser extension supporting \"abp:\" protocol (e.g. uBlock Origin, AdBlock Plus).`}>
Subscribe
</a>;
}

function SubscribeUrlNotSecure() {
return <a href={`abp:subscribe?location=${encodeURIComponent(props.url)}&amp;title=${encodeURIComponent(props.name)}`}
className="btn btn-danger btn-block fl-btn-details-action"
title={`Mirrow - Not Secure - Subscribe to list with browser extension supporting \"abp:\" protocol (e.g. uBlock Origin, AdBlock Plus).`}>
Subscribe
</a>;
}
};

function ViewUrl(props: any) {
return props.url.indexOf("https://") === -1
? ViewUrlNotSecure()
Expand Down Expand Up @@ -231,6 +259,30 @@ function ViewUrl(props: any) {
}
};

function ViewUrlMirror(props: any) {
return props.url
? props.url.indexOf("https://") === -1
? ViewUrlNotSecure()
: viewUrlSecondary()
: null;

function viewUrlSecondary() {
return <a href={props.url}
className="btn btn-secondary fl-btn-details-action"
title={`Mirror - View ${props.name} in its raw format.`}>
View
</a>;
}

function ViewUrlNotSecure() {
return <a href={props.url}
className="btn btn-danger fl-btn-details-action"
title={`Mirror - Not Secure - View ${props.name} in its raw format.`}>
View
</a>;
}
};

function HomeUrl(props: any) {
return props.url
? <a href={props.url} className="btn btn-primary fl-btn-details-action"
Expand Down Expand Up @@ -390,6 +442,8 @@ interface IFilterListDetailsDto {
tags: IListTagDto[];
updatedDate: string;
viewUrl: string;
viewUrlMirror1: string;
viewUrlMirror2: string;
}

interface IListLicenseDto {
Expand Down

0 comments on commit 8586e45

Please sign in to comment.