This repository has been archived by the owner on Oct 15, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add GitBook status IA
- Loading branch information
qqq3
committed
Jun 10, 2016
1 parent
0171288
commit d7330c4
Showing
5 changed files
with
168 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package DDG::Spice::GitBookStatus; | ||
# ABSTRACT: Search for the current status of GitBook | ||
|
||
use DDG::Spice; | ||
|
||
spice is_cached => 1; | ||
spice proxy_cache_valid => "200 5m"; | ||
|
||
spice wrap_jsonp_callback => 1; | ||
|
||
spice to => 'http://status.gitbook.com/index.json'; | ||
|
||
triggers any => 'gitbook'; | ||
|
||
handle remainder => sub { | ||
return $_ if m/^(is\s*)?(system)?\s*(status|up|down)\s*(of\s*)?$/i; #return if query contains (system) status; status of; etc | ||
return; | ||
}; | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<h3 class="gbstatus--header text--primary"> | ||
{{! Check if the status is either good, minor or major }} | ||
{{#GitbookStatus_indicator status "none"}} | ||
The status of GitBook is <span class="gbstatus--good">good</span>. | ||
{{else}} | ||
{{#GitbookStatus_indicator status "minor"}} | ||
GitBook status is <span class="gbstatus--minor">{{status}}</span>. | ||
{{else}} | ||
GitBook status is <span class="gbstatus--major">{{status}}</span>. | ||
{{/GitbookStatus_indicator}} | ||
{{/GitbookStatus_indicator}} | ||
|
||
{{#GitbookStatus_ifNotEmpty description}} | ||
<h6 class="gbstatus--message text--secondary">{{description}}</h6> | ||
{{/GitbookStatus_ifNotEmpty}} | ||
</h3> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
.zci--git_book_status .gbstatus--header { | ||
font-size: 1.5em; | ||
margin-bottom: 0; | ||
padding-bottom: 0; | ||
} | ||
|
||
.zci--git_book_status .gbstatus--good { | ||
color: #4b9e4d; | ||
} | ||
|
||
.zci--git_book_status .gbstatus--minor { | ||
color: #f1a031; | ||
} | ||
|
||
.zci--git_book_status .gbstatus--major { | ||
color: #de5833; | ||
} | ||
|
||
.zci--git_book_status .gbstatus--message { | ||
font-size: 1em; | ||
margin-top: 0; | ||
margin-bottom: 0; | ||
padding-top: 0; | ||
padding-bottom: 0.75em; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
(function (env) { | ||
"use strict"; | ||
env.ddg_spice_git_book_status = function(api_result) { | ||
|
||
if (!api_result) { | ||
return Spice.failed('git_book_status'); | ||
} | ||
var dataDetails = { | ||
status: api_result.status.indicator, | ||
description: api_result.status.description | ||
} | ||
|
||
Spice.add({ | ||
id: "git_book_status", | ||
name: "Answer", | ||
data: dataDetails, | ||
meta: { | ||
sourceName: api_result.page.name, | ||
sourceUrl: api_result.page.url | ||
}, | ||
templates: { | ||
group: 'base', | ||
options: { | ||
content: Spice.git_book_status.content, | ||
moreAt: true | ||
} | ||
} | ||
}); | ||
} | ||
|
||
Spice.registerHelper("GitbookStatus_indicator", function(string1, string2, options) { | ||
return ((string1 == string2) ? options.fn(this) : options.inverse(this)); | ||
}); | ||
|
||
Spice.registerHelper("GitbookStatus_ifNotEmpty", function(string, options) { | ||
return ((typeof(string) !== "undefined" && string !== '') ? options.fn(this) : options.inverse(this)); | ||
}); | ||
}(this)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/usr/bin/env perl | ||
|
||
use strict; | ||
use warnings; | ||
use Test::More; | ||
use DDG::Test::Spice; | ||
|
||
spice is_cached => 1; | ||
|
||
ddg_spice_test( | ||
[qw( DDG::Spice::GitBookStatus)], | ||
|
||
'gitbook status' => test_spice( | ||
'/js/spice/git_book_status/status', | ||
call_type => 'include', | ||
caller => 'DDG::Spice::GitBookStatus' | ||
), | ||
'gitbook down' => test_spice( | ||
'/js/spice/git_book_status/down', | ||
call_type => 'include', | ||
caller => 'DDG::Spice::GitBookStatus' | ||
), | ||
'gitbook up' => test_spice( | ||
'/js/spice/git_book_status/up', | ||
call_type => 'include', | ||
caller => 'DDG::Spice::GitBookStatus' | ||
), | ||
'gitbook system status' => test_spice( | ||
'/js/spice/git_book_status/system%20status', | ||
call_type => 'include', | ||
caller => 'DDG::Spice::GitBookStatus' | ||
), | ||
'gitbook system up' => test_spice( | ||
'/js/spice/git_book_status/system%20up', | ||
call_type => 'include', | ||
caller => 'DDG::Spice::GitBookStatus' | ||
), | ||
'gitbook system down' => test_spice( | ||
'/js/spice/git_book_status/system%20down', | ||
call_type => 'include', | ||
caller => 'DDG::Spice::GitBookStatus' | ||
), | ||
'status of gitbook' => test_spice( | ||
'/js/spice/git_book_status/status%20of', | ||
call_type => 'include', | ||
caller => 'DDG::Spice::GitBookStatus' | ||
), | ||
'is gitbook down' => test_spice( | ||
'/js/spice/git_book_status/is%20down', | ||
call_type => 'include', | ||
caller => 'DDG::Spice::GitBookStatus' | ||
), | ||
'is gitbook system up' => test_spice( | ||
'/js/spice/git_book_status/is%20system%20up', | ||
call_type => 'include', | ||
caller => 'DDG::Spice::GitBookStatus' | ||
), | ||
'is gitbook system down' => test_spice( | ||
'/js/spice/git_book_status/is%20system%20down', | ||
call_type => 'include', | ||
caller => 'DDG::Spice::GitBookStatus' | ||
), | ||
|
||
'about gitbook' => undef, | ||
'what is gitbook' => undef, | ||
'gitbook' => undef | ||
); | ||
|
||
done_testing; |