├── CNAME ├── src ├── less │ ├── util.less │ ├── global.less │ ├── loading.less │ ├── page.less │ └── content.less └── js │ ├── misc-function.js │ └── index.js ├── .gitignore ├── sitemap.xml ├── contribution.md ├── package.json ├── gulpfile.js ├── README.md └── index.html /CNAME: -------------------------------------------------------------------------------- 1 | legacy.awesomelists.top 2 | -------------------------------------------------------------------------------- /src/less/util.less: -------------------------------------------------------------------------------- 1 | .content-hidden { 2 | display: none; 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | data 2 | components 3 | node_modules 4 | .DS_Store 5 | *.log 6 | Gemfile.lock 7 | -------------------------------------------------------------------------------- /src/less/global.less: -------------------------------------------------------------------------------- 1 | body, html { 2 | font-family: "Vollkorn", "Helvetica Neue", Helvetica, Arial; 3 | background-color: #eee; 4 | height: 100%; 5 | width: 100%; 6 | padding-bottom: 150px; 7 | // background-image: url('../img/geometry2.png'); 8 | } 9 | 10 | html, 11 | body, 12 | input, 13 | textarea, 14 | buttons { 15 | -webkit-font-smoothing: antialiased; 16 | -moz-osx-font-smoothing: grayscale; 17 | text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.004); 18 | } 19 | 20 | a { 21 | cursor: pointer; 22 | } 23 | -------------------------------------------------------------------------------- /sitemap.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | https://awesomelists.top/ 11 | 2015-12-18T05:05:07+00:00 12 | always 13 | 14 | -------------------------------------------------------------------------------- /src/less/loading.less: -------------------------------------------------------------------------------- 1 | /* 2 | * Usage: 3 | * 4 |
5 | * 6 | */ 7 | .sk-spinner-pulse { 8 | width: 40px; 9 | height: 40px; 10 | margin: 40px auto; 11 | background-color: skyblue; 12 | border-radius: 100%; 13 | -webkit-animation: sk-pulseScaleOut 1s infinite ease-in-out; 14 | animation: sk-pulseScaleOut 1s infinite ease-in-out; } 15 | 16 | @-webkit-keyframes sk-pulseScaleOut { 17 | 0% { 18 | -webkit-transform: scale(0); 19 | transform: scale(0); } 20 | 100% { 21 | -webkit-transform: scale(1); 22 | transform: scale(1); 23 | opacity: 0; } } 24 | 25 | @keyframes sk-pulseScaleOut { 26 | 0% { 27 | -webkit-transform: scale(0); 28 | transform: scale(0); } 29 | 100% { 30 | -webkit-transform: scale(1); 31 | transform: scale(1); 32 | opacity: 0; } } 33 | -------------------------------------------------------------------------------- /contribution.md: -------------------------------------------------------------------------------- 1 | Contribution 2 | == 3 | - If you are going to PR a awesome list in JSON format, please follow this format 4 | - For example, the JSON file of `sindresorhus/awesome-nodejs` repo should be named as `sindresorhus-awesome-nodejs.json` 5 | - Also, the content should follow the following format. 6 | 7 | ``` 8 | [ 9 | { 10 | "name": "webtorrent", 11 | "url": "https://github.com/feross/webtorrent", 12 | "description": "Streaming torrent client for Node", 13 | 14 | }, 15 | { 16 | "name": "GitTorrent", 17 | "url": "https://github.com/cjb/GitTorrent", 18 | "description": "Peer-to-peer network of Git repositories being shared over BitTorrent", 19 | "cate": "Category" 20 | } 21 | ] 22 | ``` 23 | 24 | You can see the full example [here](https://github.com/lockys/awesome.json/blob/master/repo-json/sindresorhus-awesome-nodejs.json) 25 | - Any patch about UI, UX improvement is welcome, just be aware of the coding style. 26 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "awesome-search", 3 | "version": "0.1.0", 4 | "description": "A website which make you access the awesome list more quickly.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "preinstall": "npx npm-force-resolutions" 9 | }, 10 | "keywords": [ 11 | "awesome", 12 | "search" 13 | ], 14 | "engines": { 15 | "node": ">=12.16.1" 16 | }, 17 | "author": "Calvin Cheng (https://github.com/lockys)", 18 | "license": "MIT", 19 | "devDependencies": { 20 | "del": "^5.1.0", 21 | "gulp": "^3.9.1", 22 | "gulp-concat": "^2.6.1", 23 | "gulp-concat-css": "^3.1.0", 24 | "gulp-jshint": "^2.1.0", 25 | "gulp-less": "^4.0.1", 26 | "gulp-load-plugins": "^2.0.1", 27 | "gulp-notify": "^3.2.0", 28 | "gulp-rename": "^1.4.0", 29 | "gulp-uglify": "^3.0.2", 30 | "gulp-watch": "^5.0.1" 31 | }, 32 | "resolutions": { 33 | "graceful-fs": "^4.2.4" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | var gulpLoadPlugins = require('gulp-load-plugins'); 3 | var path = { 4 | src: './src/', 5 | dist: './build/', 6 | }; 7 | 8 | var plugins = gulpLoadPlugins({ 9 | pattern: ['gulp-*'], 10 | replaceString: /\bgulp[\-.]/, 11 | }); 12 | 13 | gulp.task('js', function () { 14 | gulp.watch(path.src + 'js/*.js', ['js']); 15 | return gulp 16 | .src(path.src + 'js/*.js') 17 | .pipe(plugins.concat('index.js')) 18 | .pipe(plugins.rename({ suffix: '.min' })) 19 | .pipe(plugins.uglify()) 20 | .pipe(gulp.dest(path.dist + 'js/')) 21 | .pipe(plugins.notify({ message: 'Scripts Task Finished!' })); 22 | }); 23 | 24 | gulp.task('less', function () { 25 | gulp.watch(path.src + 'less/*.less', ['less']); 26 | return gulp 27 | .src(path.src + 'less/*.less') 28 | .pipe(plugins.less()) 29 | .pipe(plugins.concatCss('index.css')) // name of concated css. 30 | .pipe(gulp.dest(path.dist + 'css/')) 31 | .pipe(plugins.notify({ message: 'CSS Task Finished!' })); 32 | }); 33 | 34 | gulp.task('default', ['js', 'less']); 35 | -------------------------------------------------------------------------------- /src/js/misc-function.js: -------------------------------------------------------------------------------- 1 | jQuery(function ($) { 2 | var $bodyEl = $('body'); 3 | var $sidedrawerEl = $('#sidedrawer'); 4 | 5 | // ========================================================================== 6 | // Toggle Sidedrawer 7 | // ========================================================================== 8 | function showSidedrawer() { 9 | // show overlay 10 | var options = { 11 | onclose: function () { 12 | $sidedrawerEl 13 | .removeClass('active') 14 | .appendTo(document.body); 15 | }, 16 | }; 17 | 18 | var $overlayEl = $(mui.overlay('on', options)); 19 | 20 | // show element 21 | $sidedrawerEl.appendTo($overlayEl); 22 | setTimeout(function () { 23 | $sidedrawerEl.addClass('active'); 24 | }, 20); 25 | } 26 | 27 | function hideSidedrawer() { 28 | $bodyEl.toggleClass('hide-sidedrawer'); 29 | } 30 | 31 | $('.js-show-sidedrawer').on('click', showSidedrawer); 32 | $('.js-hide-sidedrawer').on('click', hideSidedrawer); 33 | 34 | $('.to-top-arrow').click(function () { 35 | // console.log($('html, body')); 36 | $('html, body').animate({ 37 | scrollTop: 0, 38 | }, 600); 39 | return false; 40 | }); 41 | 42 | }); 43 | -------------------------------------------------------------------------------- /src/less/page.less: -------------------------------------------------------------------------------- 1 | /** 2 | * Layout CSS 3 | */ 4 | 5 | #header { 6 | opacity: 0.8; 7 | position: fixed; 8 | top: 0; 9 | right: 0; 10 | left: 0; 11 | z-index: 2; 12 | transition: left 0.2s; 13 | border-bottom: 1px solid gray; 14 | 15 | .home-button:hover { 16 | text-decoration: none; 17 | } 18 | 19 | & .mui-appbar { 20 | background-color: gray; 21 | } 22 | 23 | &:hover { 24 | opacity: 1; 25 | } 26 | } 27 | 28 | #sidedrawer { 29 | position: fixed; 30 | top: 0; 31 | bottom: 0; 32 | width: 220px; 33 | left: -220px; 34 | overflow: auto; 35 | z-index: 2; 36 | background-color: #fff; 37 | transition: transform 0.2s; 38 | transition: -webkit-transform 0.2s; 39 | } 40 | 41 | /** 42 | screen width bigger than 768px 43 | **/ 44 | 45 | @media (min-width: 768px) { 46 | #header { 47 | left: 220px; 48 | } 49 | 50 | #sidedrawer { 51 | transform: translate(220px); 52 | } 53 | 54 | #content-wrapper { 55 | margin-left: 220px; 56 | } 57 | 58 | #footer { 59 | margin-left: 220px; 60 | } 61 | 62 | body.hide-sidedrawer #header { 63 | left: 0; 64 | } 65 | 66 | body.hide-sidedrawer #sidedrawer { 67 | transform: translate(0px); 68 | } 69 | 70 | body.hide-sidedrawer #content-wrapper { 71 | margin-left: 0; 72 | } 73 | 74 | body.hide-sidedrawer #footer { 75 | margin-left: 0; 76 | } 77 | 78 | .mui-btn { 79 | padding: 0 10px; 80 | font-size: 16px; 81 | } 82 | } 83 | 84 | /** 85 | * Toggle Sidedrawer 86 | */ 87 | #sidedrawer.active { 88 | -moz-transform: translate(220px); 89 | -o-transform: translate(220px); 90 | -webkit-transform: translate(220px); 91 | transform: translate(220px); 92 | } 93 | 94 | /** 95 | * Header CSS 96 | */ 97 | 98 | .sidedrawer-toggle { 99 | color: #fff; 100 | cursor: pointer; 101 | font-size: 20px; 102 | line-height: 20px; 103 | margin-right: 10px; 104 | } 105 | 106 | .sidedrawer-toggle:hover { 107 | color: #fff; 108 | text-decoration: none; 109 | } 110 | 111 | /** 112 | * Sidedrawer CSS 113 | */ 114 | 115 | #sidedrawer-brand { 116 | padding-left: 20px; 117 | } 118 | 119 | #sidedrawer ul { 120 | list-style: none; 121 | } 122 | 123 | #sidedrawer > ul { 124 | padding-left: 0px; 125 | } 126 | 127 | #sidedrawer > ul > li:first-child { 128 | padding-top: 15px; 129 | } 130 | 131 | #sidedrawer strong { 132 | display: block; 133 | padding: 15px 22px; 134 | cursor: pointer; 135 | } 136 | 137 | #sidedrawer strong:hover { 138 | background-color: #e0e0e0; 139 | } 140 | 141 | #sidedrawer strong + ul > li { 142 | padding: 6px 0px; 143 | } 144 | -------------------------------------------------------------------------------- /src/less/content.less: -------------------------------------------------------------------------------- 1 | .mui-btn { 2 | margin: 0 !important; 3 | text-transform: capitalize; 4 | padding: 0 5px; 5 | font-size: 12px; 6 | } 7 | 8 | .cate-anchor-h1 { 9 | font-size: 18px; 10 | } 11 | 12 | .cate-anchor-h2 { 13 | margin-left: 10px; 14 | font-size: 16px; 15 | } 16 | 17 | .cate-anchor-h3 { 18 | margin-left: 20px; 19 | font-size: 14px; 20 | } 21 | 22 | .cate-anchor-h4 { 23 | margin-left: 30px; 24 | font-size: 12px; 25 | } 26 | 27 | .cate-anchor-h5 { 28 | margin-left: 40px; 29 | font-size: 12px; 30 | } 31 | 32 | .cate-anchor-h6 { 33 | margin-left: 50px; 34 | font-size: 12px; 35 | } 36 | 37 | .awesome-cate strong { 38 | padding: 10px 22px !important; 39 | } 40 | 41 | .alert { 42 | display: table; 43 | margin: 20px auto; 44 | } 45 | 46 | .cate-input { 47 | width: 150px; 48 | padding: 5px; 49 | font-size: 12px; 50 | margin: 20px auto; 51 | line-height: normal; 52 | color: #333; 53 | vertical-align: middle; 54 | background-color: #fff; 55 | background-repeat: no-repeat; 56 | background-position: right 8px center; 57 | border: 1px solid #ccc; 58 | outline: none; 59 | border-radius: 3px; 60 | -moz-border-raius: 3px; 61 | -webkit-border-radius: 3px; 62 | -o-border-radius: 3px; 63 | 64 | &:focus { 65 | border: 1px solid black; 66 | outline: 0; 67 | } 68 | } 69 | 70 | .cate-search-result { 71 | position: absolute; 72 | opacity: 0.978; 73 | top: 50px; 74 | padding: 5px; 75 | right: 0px; 76 | width: 184px; 77 | background-color: white; 78 | border: 1px solid lighten(gray, 40%); 79 | border-radius: 3px; 80 | -moz-border-raius: 3px; 81 | -webkit-border-radius: 3px; 82 | -o-border-radius: 3px; 83 | margin: 3px; 84 | font-size: 12px; 85 | line-height: normal; 86 | z-index: 999; 87 | overflow: hidden; 88 | 89 | a { 90 | color: black; 91 | font-size: 13px; 92 | } 93 | } 94 | 95 | .search-repo-link { 96 | cursor: pointer; 97 | 98 | &:hover { 99 | text-decoration: hover; 100 | } 101 | } 102 | 103 | #content-wrapper { 104 | display: block; 105 | // height: 90%; 106 | margin-left: 0px; 107 | transition: margin-left 0.2s; 108 | } 109 | 110 | #readme { 111 | background-color: white; 112 | padding: 10px 20px; 113 | margin-bottom: 30px; 114 | box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.16), 0 0 2px 0 rgba(0, 0, 0, 0.12); 115 | // for main page 116 | overflow: hidden; // or auto; 117 | box-sizing: border-box; 118 | font-size: 1.2em; 119 | 120 | & .home-page-title { 121 | font-variant: small-caps; 122 | } 123 | } 124 | 125 | .origin-repo-btn { 126 | background-color: white; 127 | color: black; 128 | padding: 5px 20px; 129 | margin-right: 5px; 130 | border-bottom: 2px solid lighten(gray, 40%); 131 | transition: all 0.5s ease; 132 | 133 | &:hover { 134 | text-decoration: none; 135 | color: gray; 136 | border-bottom: 2px solid lighten(gray, 10%); 137 | } 138 | } 139 | 140 | .mui-dropdown__menu { 141 | overflow-x: auto; 142 | max-height: 550px; 143 | } 144 | 145 | .to-top-arrow { 146 | background: transparent; 147 | border: 0px; 148 | padding: 10px 20px; 149 | position: fixed; 150 | font-size: 3em !important; 151 | color: gray; 152 | bottom: 20px; 153 | right: 20px; 154 | } 155 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Awesome Search 2 | == 3 | A website making you access the [awesome](https://github.com/sindresorhus/awesome) lists more quickly. 4 | **This is old version of Awesome Search, you can still access via https://legacy.awesomelists.top** 5 | 6 | To access the new version of Awesome Search, please visit.. 7 | [https://awesomelists.top](https://awesomelists.top) 8 | 9 | ### Make some suggestions 10 | [![Join the chat at https://gitter.im/lockys/AwesomeSearch](https://badges.gitter.im/lockys/AwesomeSearch.svg)](https://gitter.im/lockys/AwesomeSearch?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 11 | 12 | ### kudos 13 | - [John-Lin](https://github.com/John-Lin)'s powerful support. 14 | - The original domain name `http://awesomelists.me/` is provided by [@aleksandar-todorovic](https://github.com/aleksandar-todorovic), thanks!   15 | - Thanks [bashooka](http://bashooka.com/coding/35-best-css-tools-for-2017/) for recommendation. 16 | 17 | ### Support our works 18 | Buy me a coffee if you are willing to. :), I will add your link to the supporter section. Big thanks! 19 | [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=UVV57KZ6F6S34) 20 | 21 | ![screenshot](http://g.recordit.co/LkyiGw1q6c.gif) 22 | 23 | Why 24 | == 25 | In a nutshell, there are many awesome lists in the Awesome :) 26 | We hope to build an application to access them more quickly. 27 | That's why "Awesome Search" was born. :octocat: 28 | 29 | Features 30 | == 31 | ✔ Access and search every awesome repo collected in [sindresorhus/awesome](https://github.com/sindresorhus/awesome) in one page quickly. 32 | ✔ Access an awesome repo by `https://awesomelists.top/#repos/sindresorhus/awesome-nodejs`. (you can BOOKMARK it!) 33 | ✔ Categories of an awesome repo are supported if the that repo uses `headings`. 34 | ✔ Use Github API to retrieve README file of an awesome repo, so it's up-to-date. 35 | ✔ Search links in a specified repo we have parsed, see [supported repo](#supported-awesome-lists) 36 | 37 | Supported awesome lists 38 | == 39 | Currently, searching `links` in most of awesome repositories is supported. 40 | You can see the JSON format of links [here](https://github.com/lockys/Awesome.json/blob/master/awesome/awesome.json).(Contribution is welcome) 41 | We build [awesomelists-index](https://github.com/John-Lin/awesomelists-index) to parse these lists. However, we are still finding a more efficient way. 42 | [awesome.json](https://github.com/lockys/awesome.json) is the place where the data store for now. 43 | 44 | Authors 45 | == 46 | - [lockys](https://github.com/lockys) 47 | - [John-Lin](https://github.com/John-Lin) 48 | 49 | Contributors 50 | == 51 | Thank you, [contributors](https://github.com/lockys/awesome-search/graphs/contributors) 52 | 53 | Contributions 54 | == 55 | Welcome to contribute :) 56 | Please refer to [contribution.md](contribution.md) 57 | Filing a issue to make suggestions or complain anything is always welcome. 58 | 59 | Related Projects 60 | == 61 | - [John-Lin/awesomelists-index](https://github.com/John-Lin/awesomelists-index) - converts an awesome list into a JSON file 62 | - [lockys/awesome.json](https://github.com/lockys/awesome.json) - converts [sindresorhus's awesome](https://github.com/sindresorhus/awesome) to json 63 | - [getAwesomeness()](https://github.com/panzhangwang/getAwesomeness) - search engine based on local JSON data 64 | 65 | Credit 66 | == 67 | Thanks all awesome authors for creating these awesome lists. 68 | - [sindresorhus/awesome](https://github.com/sindresorhus/awesome) 69 | - [All awesome list contributors](https://github.com/sindresorhus/awesome/graphs/contributors) 70 | ![awesome](http://i.imgur.com/qcroMhk.gif) 71 | 72 | LICENSE 73 | == 74 | The MIT License (MIT) 75 | 76 | Copyright (c) 2015 Hao-Wei Jeng, Che-Wei Lin 77 | 78 | Permission is hereby granted, free of charge, to any person obtaining a copy 79 | of this software and associated documentation files (the "Software"), to deal 80 | in the Software without restriction, including without limitation the rights 81 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 82 | copies of the Software, and to permit persons to whom the Software is 83 | furnished to do so, subject to the following conditions: 84 | 85 | The above copyright notice and this permission notice shall be included in all 86 | copies or substantial portions of the Software. 87 | 88 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 89 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 90 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 91 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 92 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 93 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 94 | SOFTWARE. 95 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | Awesome Search 15 | 16 | 17 | 24 | 25 | 26 |
27 |
28 |
29 | 30 |
31 |
32 |
33 |
34 | 35 | 38 |
39 | 40 | 60 | 61 |
62 |
63 |
64 |
65 | 66 |
67 |
68 |
69 |
70 |
71 |

Head to new version of Awesome Search!

72 |

AwesomeSearch

73 | Makes you find what you want in awesome lists more quickly. 74 |
75 | 76 |

77 | awesome badge. 78 |

79 |

80 | awesome lists can be found by AwesomeSearch now. 81 |

82 |

Why

83 |

84 | There are many awesome lists in the Awesome
85 | We hope to build an application to access them more quickly .
86 |

87 |

88 | Features 89 |

90 |

91 | Access and search every awesome repo collected in sindresorhus/awesome in one page without pain.
92 | Access an awesome repo by https://awesomelists.top/#repos/sindresorhus/awesome-nodejs.(you can bookmark your favorite!)
93 | Categories of an awesome repo is supported if that repo uses properly formatted headings.
94 | Search links in a specified repo (supports most repos) and repos listed in sindresorhus/awesome. 95 |

96 |

97 | Get started with a repo. 98 |

99 |

100 | Check out Awesome Node.js! 101 |

102 |

103 | Credit to. 104 |

105 |

106 | sindresorhus/awesome 107 | , all authors of awesome lists 108 |

109 |
110 |

111 | Awesome search is built with by lockys, John-Lin 112 |

113 |

114 | Made with mui, fuse.js 115 |

116 |
117 |
118 |
119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /src/js/index.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function () { 2 | var repoFinder; 3 | var awesomeFinder; 4 | var isAwesome = false; // is it sindre/awesome repo ? 5 | var urlMap = 6 | 'https://raw.githubusercontent.com/lockys/awesome.json/master/awesome/awesome.json'; 7 | var urlMapObj = {}; 8 | var options = { 9 | keys: ['name'], 10 | }; 11 | var $awesome = $('.readme-container'); 12 | var $searchResult = $('.search-result'); 13 | var $searchBlock = $('.search-input-section'); 14 | var $innerDropDownMenu = $('.mui-dropdown__menu'); 15 | var $dropDownMenu = $('.mui-dropdown'); 16 | 17 | function processReadMe(content, repoURL, originRepoHTML) { 18 | $awesome.html('').append(content); 19 | $('#readme').prepend(originRepoHTML); 20 | var $anchor = $('h6 a, h5 a, h4 a, h3 a, h2 a, h1 a'); 21 | var anchorLink = $('#readme a[href^="#"]').not('.anchor'); 22 | var maintainer = repoURL.split('/')[3]; 23 | var repo = repoURL.split('/')[4]; 24 | var githubRawURL = 25 | 'https://raw.githubusercontent.com/' + 26 | maintainer + 27 | '/' + 28 | repo + 29 | '/master/'; 30 | var githubURL = 31 | 'https://github.com/' + maintainer + '/' + repo + '/blob/master'; 32 | var tagLevel; 33 | 34 | /** 35 | * Dealing with some repos use relative image path. 36 | **/ 37 | var $imgArr = $('img'); 38 | var linksArr = []; 39 | 40 | for (var i = 0, len = $imgArr.length; i < len; ++i) { 41 | var relativeSrc = $($imgArr[i]).attr('src'); 42 | if (!isURL(relativeSrc)) { 43 | relativeSrc = relativeSrc.startsWith('/') 44 | ? relativeSrc 45 | : '/' + relativeSrc; 46 | $($imgArr[i]).attr('src', githubRawURL + relativeSrc); 47 | } 48 | } 49 | 50 | /** 51 | insert data-anchor and class cate-anchor so that when the link is clicked, 52 | the page will be scroll the position of anchor. 53 | **/ 54 | for (var i = 0, len = anchorLink.length; i < len; ++i) { 55 | var $anchorEle = $(anchorLink[i]); 56 | $anchorEle 57 | .attr({ 58 | class: 'cate-anchor', 59 | 'data-anchor': $(anchorLink[i]).attr('href'), 60 | }) 61 | .removeAttr('href'); 62 | } 63 | 64 | /** 65 | * Build Category List. 66 | **/ 67 | for (var i = 0, len = $anchor.length; i < len; ++i) { 68 | $anchor[i].id = $anchor[i].id.replace('user-content-', ''); 69 | if ($anchor[i].id) { 70 | var anchorClass = ''; 71 | var anchorPrefix = '━ '; 72 | tagLevel = $($anchor[i]).parent()[0].nodeName; 73 | 74 | if (tagLevel === 'H1') { 75 | anchorClass = 'cate-anchor-h1'; 76 | anchorPrefix = ''; 77 | } else if (tagLevel === 'H2') { 78 | anchorClass = 'cate-anchor-h2'; 79 | } else if (tagLevel === 'H3') { 80 | anchorClass = 'cate-anchor-h3'; 81 | anchorPrefix = '╰ '; 82 | } else if (tagLevel === 'H4') { 83 | anchorClass = 'cate-anchor-h4'; 84 | anchorPrefix = '╰ '; 85 | } else if (tagLevel === 'H5') { 86 | anchorClass = 'cate-anchor-h5'; 87 | anchorPrefix = '┈ '; 88 | } else if (tagLevel === 'H6') { 89 | anchorClass = 'cate-anchor-h6'; 90 | anchorPrefix = '┈ '; 91 | } 92 | 93 | $innerDropDownMenu.append( 94 | '
  • ' + 99 | anchorPrefix + 100 | $($anchor[i]).parent('h6, h5, h4, h3, h2, h1').text() + 101 | '
  • ' 102 | ); 103 | } 104 | } 105 | 106 | $('.cate-anchor').click(scrollToAnchor); 107 | $dropDownMenu.removeClass('content-hidden'); 108 | 109 | // Filter all links in readme but not anchor. 110 | linksArr = $('#readme a').not('.cate-anchor'); 111 | 112 | // the relatvie src to absolute src. 113 | for (var i = 0, len = linksArr.length; i < len; ++i) { 114 | var relativeSrc = $(linksArr[i]).attr('href'); 115 | 116 | if (relativeSrc !== undefined && !isURL(relativeSrc)) { 117 | relativeSrc = relativeSrc.startsWith('/') 118 | ? relativeSrc 119 | : '/' + relativeSrc; 120 | $(linksArr[i]).attr({ href: githubURL + relativeSrc }); 121 | } 122 | 123 | $(linksArr[i]).attr({ target: '_blank' }); 124 | } 125 | } 126 | 127 | /** 128 | * Generate the array of awesome repos for search and display 129 | * the Category on the left sidedrawer using urlMapObj 130 | **/ 131 | function processAwesomeJSON() { 132 | var awesomeData = []; 133 | var $awesomeCate = $('.awesome-cate'); 134 | $awesomeCate.html(''); 135 | 136 | Object.keys(urlMapObj).forEach(function (e) { 137 | var _cateID = e.replace(/\W/g, '').toLowerCase(); 138 | awesomeData = awesomeData.concat(urlMapObj[e]); 139 | 140 | $awesomeCate.append( 141 | ' ' + 142 | e + 143 | '
  • ' 146 | ); 147 | 148 | urlMapObj[e].forEach(function (e) { 149 | var $cateUl = $('.' + _cateID + '-ul'); 150 | var link = ''; 151 | if (e.url.split('/').indexOf('github.com') > -1) { 152 | link = 153 | '
  • ' + 156 | e.name + 157 | '
  • '; 158 | } else { 159 | link = 160 | '
  • ' + 163 | e.name + 164 | '
  • '; 165 | } 166 | 167 | $cateUl.append(link); 168 | }); 169 | }); 170 | 171 | var $sidedrawerEl = $('#sidedrawer'); 172 | var $titleEls = $('strong', $sidedrawerEl); 173 | $titleEls.next().hide(); 174 | $titleEls.off('click'); 175 | $titleEls.on('click', function () { 176 | $titleEls.not(this).next().hide(); 177 | $(this).next().slideToggle(300); 178 | }); 179 | 180 | $('.repo-count-number').html(awesomeData.length); 181 | awesomeFinder = new Fuse(awesomeData, options); 182 | } 183 | 184 | /** 185 | * Retrieve the readme file of an awesome repo from github and store the json for searching. 186 | * @param e It's an object containing repo name and url. 187 | * @param cate The repo name we want to get. 188 | * @return null 189 | **/ 190 | var getCateList = function (maintainer, repo) { 191 | var repoURL = 'https://github.com/' + maintainer + '/' + repo; 192 | isAwesome = repo === 'awesome' ? 1 : 0; 193 | jsonURL = 194 | 'https://raw.githubusercontent.com/lockys/awesome.json/master/repo-json/' + 195 | maintainer + 196 | '-' + 197 | repo + 198 | '.json'; 199 | $dropDownMenu.removeClass('content-hidden'); 200 | $searchResult.addClass('content-hidden'); 201 | 202 | $searchResult.html(''); 203 | $innerDropDownMenu.html(''); 204 | $('.alert').html(''); 205 | $('.awesome-input').val(''); 206 | 207 | /** 208 | * Get readme of awesome repo 209 | **/ 210 | if (!isAwesome) { 211 | var originRepoHTML = 212 | 'View on

    '; 215 | 216 | $awesome.html('
    '); 217 | 218 | getReadme(maintainer, repo, repoURL, originRepoHTML, processReadMe); 219 | updatePageTitle(repo); 220 | 221 | $.getJSON(jsonURL, function (data) { 222 | var list = data; 223 | var d = []; 224 | /** 225 | * Category has not been parsed yet. 226 | **/ 227 | $searchBlock.removeClass('content-hidden'); 228 | 229 | if (Object.keys(list).length === 0) { 230 | $('.alert').html( 231 | 'This repo has not been parsed yet, we will support it soon.
    ' 232 | ); 233 | $searchBlock.addClass('content-hidden'); 234 | return; 235 | } 236 | 237 | /** 238 | * Fill in to data for searching 239 | **/ 240 | list.forEach(function (e) { 241 | if (!isURL(e.url)) { 242 | var maintainer = repoURL.split('/')[3]; 243 | var repo = repoURL.split('/')[4]; 244 | var repoUrlPrefix = 245 | 'https://github.com/' + maintainer + '/' + repo + '/blob/master'; 246 | e.url = repoUrlPrefix + e.url; 247 | } 248 | 249 | d = d.concat(e); 250 | }); 251 | 252 | repoFinder = new Fuse(d, options); 253 | }); 254 | } else { 255 | processAwesomeJSON(); 256 | $dropDownMenu.addClass('content-hidden'); 257 | } 258 | }; 259 | 260 | /** 261 | * Show search result when users search. 262 | **/ 263 | $('input').on('input', function (e) { 264 | var isCateInput = $(e.target).hasClass('cate-input'); 265 | var query = $(this).val(); 266 | var LENGTH_LIMIT = 15; 267 | $searchResult = isCateInput 268 | ? $('.cate-search-result') 269 | : $('.search-result'); 270 | 271 | $searchResult.removeClass('content-hidden'); 272 | $searchResult.html(''); 273 | 274 | if (!query) { 275 | $searchResult.addClass('content-hidden'); 276 | } 277 | 278 | var result = isCateInput 279 | ? awesomeFinder.search(query) 280 | : repoFinder.search(query); 281 | var link = ''; 282 | var description = ''; 283 | if (!result.length) { 284 | $searchResult.html('No result :('); 285 | } 286 | 287 | /** 288 | List the searching result. 289 | **/ 290 | for (var i = 0, len = LENGTH_LIMIT; i < len; ++i) { 291 | if (result[i]) { 292 | var id = result[i].name.replace(/\W/g, '').toLowerCase(); 293 | var href = ' href="' + result[i].url + '" '; 294 | 295 | if (isAwesome) { 296 | href = ''; 297 | } 298 | 299 | // console.log(d); 300 | description = result[i].description 301 | ? ' - ' + result[i].description + '
    ' 302 | : '
    '; 303 | 304 | if (!isCateInput) { 305 | // if parsed(and it is not the top awesome repo), show the searching result about the current repo. 306 | $searchResult.append( 307 | '' + 312 | result[i].name + 313 | '' + 314 | description 315 | ); 316 | } else { 317 | // if not parsed or it is the top awesome repo, show the searching result about the top awesome repo. 318 | if (result[i].url.split('/').indexOf('github.com') > -1) { 319 | $searchResult.append( 320 | '' + 323 | result[i].name + 324 | '' + 325 | description 326 | ); 327 | } else { 328 | $searchResult.append( 329 | '' + 332 | result[i].name + 333 | '' + 334 | description 335 | ); 336 | } 337 | } 338 | } 339 | } // end of for loop 340 | }); 341 | 342 | /** 343 | * @param repoURL 344 | * @param cb to dealing with html of readme. 345 | **/ 346 | function getReadme(maintainer, repo, repoURL, originRepoHTML, cb) { 347 | var apiURL = 348 | 'https://api.github.com/repos/' + maintainer + '/' + repo + '/readme'; 349 | 350 | $.ajax({ 351 | url: apiURL, 352 | headers: { 353 | accept: 'application/vnd.github.v3.html', 354 | }, 355 | success: function (content) { 356 | cb(content, repoURL, originRepoHTML); 357 | }, 358 | }); 359 | } 360 | 361 | function updatePageTitle(repo) { 362 | var formattedRepoName = repo.replace(/-/g, ' '); 363 | 364 | formattedRepoName = formattedRepoName 365 | .split(' ') 366 | .map(function (word) { 367 | return word.replace(word[0], word[0].toUpperCase()); 368 | }) 369 | .join(' '); 370 | 371 | document.title = 'Awesome Search - ' + formattedRepoName; 372 | } 373 | 374 | // The Backbone router configuration. 375 | var AwesomeRouter = Backbone.Router.extend({ 376 | routes: { 377 | 'repos/:maintainer/:repo': 'getRepos', 378 | '': 'getAwesome', 379 | }, 380 | }); 381 | 382 | var awesomeRouter = new AwesomeRouter(); 383 | 384 | // Execute when route matches the awesomelist.top/#repos// 385 | awesomeRouter.on('route:getRepos', function (maintainer, repo) { 386 | $('.search-holder').html('Search ' + repo); 387 | getCateList(maintainer, repo); 388 | }); 389 | 390 | // Root Route, get the sindresorhus/awesome repo. 391 | awesomeRouter.on('route:getAwesome', function () { 392 | getCateList('sindresorhus', 'awesome'); 393 | }); 394 | 395 | /** 396 | * Judge what users click, if user clicks home button, return to home page. 397 | * if users click the body not input area, hide the input. 398 | **/ 399 | $('body').click(function (event) { 400 | // Close the search result when click outside of the input div 401 | if ( 402 | !$(event.target).hasClass('awesome-input') && 403 | !$(event.target).hasClass('search-result') && 404 | !$(event.target).hasClass('search-icon') 405 | ) { 406 | $('.awesome-input').val(''); 407 | $('.search-result').addClass('content-hidden'); 408 | $('.search-input').removeClass('hovered'); 409 | } 410 | 411 | if ( 412 | !$(event.target).hasClass('cate-input') && 413 | !$(event.target).hasClass('cate-search-result') 414 | ) { 415 | $('.cate-input').val(''); 416 | $('.cate-search-result').addClass('content-hidden'); 417 | } 418 | }); 419 | 420 | $('.home-button').click(function (event) { 421 | event.preventDefault(); 422 | window.location.hash = '/'; 423 | location.reload(); 424 | }); 425 | 426 | /** 427 | * Generate urlMapObj for building sidedrawer. 428 | **/ 429 | $.getJSON(urlMap, function (d) { 430 | urlMapObj = d; 431 | getCateList('sindresorhus', 'awesome'); 432 | }); 433 | 434 | Backbone.history.start(); 435 | 436 | // ============= Some Helper functions ================== 437 | 438 | /** 439 | * To check if a string is a url 440 | * @return true or false 441 | **/ 442 | function isURL(str) { 443 | var pattern = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/; 444 | return pattern.test(str); 445 | } 446 | 447 | /** 448 | Back to top button. 449 | **/ 450 | function scrollToAnchor(e) { 451 | var anchor = $(e.target).data('anchor'); 452 | var offset = $(anchor).offset().top - $('#header').height(); 453 | $('html, body').animate( 454 | { 455 | scrollTop: offset, 456 | }, 457 | 300 458 | ); 459 | } 460 | }); 461 | --------------------------------------------------------------------------------