Repository: willfarrell/alfred-caniuse-workflow Branch: master Commit: 9585e63563ea Files: 8 Total size: 145.3 KB Directory structure: gitextract_buzijdyh/ ├── .github/ │ └── FUNDING.yml ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── caniuse.alfredworkflow └── src/ ├── caniuse.php ├── data.json └── workflows.php ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/FUNDING.yml ================================================ # These are supported funding model platforms github: [willfarrell] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] ================================================ FILE: CONTRIBUTING.md ================================================ # How to contribute First off, thanks for you interest in contributing. Everyone who uses this repos really appreciates it. ![alt text][alfred] ## Issues All are welcome. ## Pull Requests Good pull requests - patches, improvements, new features - are a fantastic help. They should remain focused in scope and avoid containing unrelated commits. If your contribution involves a significant amount of work or substantial changes to any part of the project, please open an issue to discuss it first. Make sure to adhere to the coding conventions used throughout a project (indentation, accurate comments, etc.). Please update any documentation that is relevant to the change you're making. ## Pull Request Checklist Before you submit your PR please make sure everything is in order. - [ ] Installed `.alfredworkflow` file from repo before making changes. - [ ] Update the version in the workflow title. Double-click the workflow to edit. - [ ] Increase the version number in `update.json`. Right-click the workflow in Alfred, click `Show in Finder`. The `update.json` file will be in that folder. - [ ] Increase the version number in `current-version.json`. - [ ] If needed include a large icon in the `src/icon-src/` folder that has square dimensions. - [ ] If needed include a cached icon in the `sec/icon-cache/` folder that 256x256 pixels. Alfred creates these when you insert an image into a workflow. You can get this from inside the `.alfredworkflow`. Right-click the workflow in Alfred, click `Show in Finder`. The `--hash-value--.png` file will be in that folder. Copy to `/src/icon-cache` and rename. - [ ] If needed add a screenshot. Use ⌘ (command) + ⇧ (shift) + 4, press ␣ (space), then click on the Alfred window to create a clean screen shot. Place in the `screenshots` folder. - [ ] Update README.md with new version and any additional screenshots. - [ ] Export workflow to repo folder. Right-click the workflow in Alfred, click `Export...`. Don't include the `(v1.0)` in the name. ## Pull Request Process Please follow this process; it's the best way to get your work included in the project: 1. [Fork](http://help.github.com/fork-a-repo/) the project, clone your fork, and configure the remotes: ```bash # Clones your fork of the repo into the current directory in terminal git clone https://github.com//.git # Navigate to the newly cloned directory cd # Assigns the original repo to a remote called "upstream" git remote add upstream https://github.com//.git ``` 2. If you cloned a while ago, get the latest changes from upstream: ```bash git checkout master git pull upstream master ``` 3. Create a new topic branch to contain your feature, change, or fix: ```bash git checkout -b ``` 4. Commit your changes in logical chunks. Please adhere to these [git commit message guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) or your pull request is unlikely be merged into the main project. Use git's [interactive rebase](https://help.github.com/articles/interactive-rebase) feature to tidy up your commits before making them public. 5. Locally merge (or rebase) the upstream development branch into your topic branch: ```bash git pull [--rebase] upstream master ``` 6. Push your topic branch up to your fork: ```bash git push origin ``` 7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests) with a clear title and description. [alfred]: ./screenshots/alfred.png "Alfred Workflow" ================================================ FILE: LICENSE ================================================ The MIT License (MIT) Copyright (c) 2013 will Farrell Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ caniuse ([Download v1.10](https://raw.github.com/willfarrell/alfred-caniuse-workflow/master/caniuse.alfredworkflow)) ===================== Alfred App Workflow for caniuse.com ## Requirements 1. [Alfred App v3](http://www.alfredapp.com/#download) 1. [Alfred Powerpack](https://buy.alfredapp.com/) ## Installing 1. Click the download buttons below 2. Double-click to import into Alfred 3. Review the workflow to add custom Hotkeys ## About Alfred App Workflow for caniuse.com ![alt text][caniuse] Upon making your first search the caniuse db is cached (7 days). ## Commands - `caniuse {query}` ## Contributors - [@willfarrell](https://github.com/willfarrell) - [@sydlawrence](https://github.com/sydlawrence) - [alfred-dev-doctor](https://github.com/sydlawrence/alfred-dev-doctor) - [@Fyrd](https://github.com/Fyrd) - [caniuse](https://github.com/Fyrd/caniuse) - [@mcdado](https://github.com/mcdado) [caniuse]: ./screenshots/caniuse-browser.png "Sample search" ================================================ FILE: src/caniuse.php ================================================ $val) { $key = floatval($key); if ($version < $key && $val == 'y') { $support = $key."+"; break; } elseif ($version < $key && strpos($val, 'y x') !== false) { $version = $key; $support = $key."-px-"; } elseif ($version < $key && strpos($val, 'a') !== false) { $version = $key; $support = $key."!pa."; } elseif ($version < $key && strpos($val, 'p') !== false) { $version = $key; $support = $key."w/pl"; } } return $support ? $support : "n/a"; } // cache if ( filemtime("data.json") <= (time() - 86400 * 7)) { $data = json_decode(getSSLPage("https://raw.githubusercontent.com/Fyrd/caniuse/master/data.json")); $arr = array(); foreach ($data->data as $key => $val) { $title = $val->title; $url = "https://caniuse.com/#feat=" . $key; $description = $val->description; $keywords = $val->keywords; $name = $key; $stats = array(); foreach ($val->stats as $browser => $stat) { $stats[$browser] = browserVersion($val->stats->$browser); } $arr[] = array( "name" => $name, "url" => $url, "keywords" => $keywords, "title" => $title, "description" =>str_replace("—","-",html_entity_decode(trim(str_replace("\n"," ",strip_tags($val->description))))), "stats" => "[IE:{$stats['ie']}, FF:{$stats['firefox']}, GC:{$stats['chrome']}, S:{$stats['safari']}]" ); } if (count($arr)) { file_put_contents("data.json", json_encode($arr)); } } if (!isset($query)) { $query = urlencode( "css" ); } $data = json_decode(file_get_contents("data.json")); function registerResult($result) { global $w; $w->result( $result->title, $result->url, $result->title." ".$result->stats, $result->description, "icon.png" ); return; } $found = array(); $query = urldecode(strtolower(trim($query))); foreach ($data as $key => $result) { $value = strtolower(trim($result->title)); $description = mb_convert_encoding(strip_tags($result->description), 'UTF-8', mb_list_encodings()); $keywords = mb_convert_encoding($result->keywords, 'UTF-8', mb_list_encodings()); $name = $result->name; if (strpos( $value, $query ) === 0) { if (!isset($found[$value])) { $found[$value] = true; registerResult($result); } } else if (strpos($value, $query) > 0) { if (!isset($found[$value])) { $found[$value] = true; registerResult($result); } } else if (strpos($name, $query) === 0) { if (!isset($found[$value])) { $found[$value] = true; registerResult($result); } } else if (strpos($keywords, $query) !== false) { if (!isset($found[$value])) { $found[$value] = true; registerResult($result); } } else if (strpos($description, $query) !== false) { if (!isset($found[$value])) { $found[$value] = true; registerResult($result); } } } echo $w->toxml(); // **************** ?> ================================================ FILE: src/data.json ================================================ [{"name":"png-alpha","url":"http:\/\/caniuse.com\/#feat=png-alpha","keywords":"","title":"PNG alpha transparency","description":"Semi-transparent areas in PNG files","stats":"[IE:7+, FF:2+, GC:4+, S:3.1+]"},{"name":"apng","url":"http:\/\/caniuse.com\/#feat=apng","keywords":"","title":"Animated PNG (APNG)","description":"Like animated GIFs, but allowing 24-bit colors and alpha transparency","stats":"[IE:n\/a, FF:3+, GC:n\/a, S:8+]"},{"name":"video","url":"http:\/\/caniuse.com\/#feat=video","keywords":"