├── .dancer ├── .docker └── config.json ├── .dockerignore ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── config.yml └── workflows │ ├── build-deployment-container.yml │ ├── build-production-container.yml │ └── testsuite.yml ├── .gitignore ├── .perlcriticrc ├── .perltidyrc ├── .tidyallrc ├── .whitesource ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── config ├── docker-compose.development.env ├── docker-compose.production.env └── docker-compose.test.env ├── cpanfile ├── cpanfile.snapshot ├── deploy ├── build.sh ├── push.sh └── vars.sh ├── docker-compose.dev.yml ├── docker-compose.test-setup.yml ├── docker-compose.test.yml ├── docker-compose.yml ├── docker-entrypoint.sh ├── launcher ├── devel-server ├── metacpan-server ├── production-server └── test-production-server ├── src ├── app.psgi ├── bin │ └── app.psgi ├── config.yml ├── docker-entrypoint.sh ├── environments │ ├── development.yml │ ├── metacpan.yml │ ├── production-docker.yml │ ├── production.yml │ └── unit-tests.yml ├── lib │ ├── GrepCpan │ │ ├── Grep.pm │ │ └── std.pm │ └── grepcpan.pm ├── public │ ├── 404.html │ ├── 500.html │ ├── _assets │ │ ├── 20230427152712-8ee3b0e7a6641aed845899d0645808f6.js │ │ ├── 20250504161906-510a05c940bec575d4a5edfd45e2668f.css │ │ └── 20250504161906-8ee3b0e7a6641aed845899d0645808f6.js │ ├── css │ │ ├── error.css │ │ └── style.css │ ├── dispatch.cgi │ ├── dispatch.fcgi │ ├── favicon.ico │ ├── images │ │ ├── grepcpan-logo.pxm │ │ ├── metacpan-logo@2x.png │ │ ├── perldancer-bg.jpg │ │ └── perldancer.jpg │ ├── javascripts │ │ ├── jquery.js │ │ └── mousetrap.min.js │ └── static │ │ ├── css │ │ └── font-awesome.min.css │ │ ├── fonts │ │ ├── FontAwesome.otf │ │ ├── fontawesome-webfont.eot │ │ ├── fontawesome-webfont.svg │ │ ├── fontawesome-webfont.ttf │ │ ├── fontawesome-webfont.woff │ │ └── fontawesome-webfont.woff2 │ │ ├── icons │ │ ├── apple-touch-icon.png │ │ ├── favicon.ico │ │ └── metacpan-icon.png │ │ └── images │ │ ├── grep-cpan-logo-flat.png │ │ ├── grep_cpan_logo.png │ │ ├── grep_cpan_logo.svg │ │ ├── grepcpan-logo.pxm │ │ ├── metacpan-logo@2x.png │ │ ├── perldancer-bg.jpg │ │ ├── perldancer.jpg │ │ └── sponsors │ │ ├── cpanel.png │ │ └── perl-careers.png ├── t │ ├── 001_base.t │ ├── 002_index_route.t │ ├── GrepCpan-Grep-dosearch.t │ ├── GrepCpan-Grep-grep-flavor.t │ ├── GrepCpan-Grep-sanitize-search.t │ ├── GrepCpan-Grep-workers.t │ ├── GrepCpan-Grep.t │ ├── grepcpan-config.t │ ├── lib │ │ └── Test │ │ │ └── Grep │ │ │ └── MetaCPAN.pm │ └── run-tests.sh └── views │ ├── 404.tt │ ├── _display.tt │ ├── about.tt │ ├── api.tt │ ├── faq.tt │ ├── index.tt │ ├── layouts │ └── main.tt │ ├── list-files.tt │ ├── main │ ├── _header.tt │ ├── _last_search.tt │ └── _pagination.tt │ ├── search.tt │ ├── show-ls.tt │ ├── show-search.tt │ └── source-code.tt └── tools ├── pre-commit.pl └── update-assets.pl /.dancer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metacpan/metacpan-grep-front-end/a5f6e6a852fd52203da5345c279b39a5b6ec9ae0/.dancer -------------------------------------------------------------------------------- /.docker/config.json: -------------------------------------------------------------------------------- 1 | # ~/.docker/config.json 2 | { 3 | "features": { 4 | "buildkit": true 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | # .dockerignore 2 | 3 | .git 4 | .gitignore 5 | 6 | README.md 7 | 8 | deploy/ 9 | launcher/ 10 | local/ 11 | 12 | src/blib/ 13 | src/environments/*docker* 14 | src/t/ 15 | src/var/ 16 | 17 | tools/ 18 | 19 | .env 20 | *.log 21 | *.swp 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🐛 Bug report 3 | about: Report a problem with the app 4 | title: "[BUG]" 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## Context 11 | 12 | [provide more detailed introduction to the issue itself and why it is relevant] 13 | 14 | [if possible provide one URL to reproduce the bug] 15 | 16 | ## Process 17 | 18 | [ordered list the process to finding and recreating the issue, example below] 19 | 20 | 1. ... 21 | 2. ... 22 | 3. ... 23 | 24 | ## Expected result 25 | 26 | [describe what you would expect to have resulted from this process] 27 | 28 | ## Current result 29 | 30 | [describe what you you currently experience from this process, and thereby explain the bug] 31 | 32 | ## Possible Fix 33 | 34 | [not obligatory, but suggest fixes or reasons for the bug] 35 | 36 | [if relevant, include a screenshot - simply drag & drop a picture there] 37 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: 💬 Community Support 4 | url: //github.com/metacpan/metacpan-grep-front-end/discussions/ 5 | about: Please use GitHub Discussions for questions and support. 6 | -------------------------------------------------------------------------------- /.github/workflows/build-deployment-container.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Build deployment container 3 | on: 4 | push: 5 | branches: 6 | - prod 7 | - staging 8 | workflow_dispatch: 9 | jobs: 10 | docker: 11 | runs-on: ubuntu-22.04 12 | name: Docker Push 13 | steps: 14 | - uses: actions/checkout@v3 15 | - name: docker build 16 | run: docker build . -t metacpan/metacpan-grep-front-end:$GITHUB_SHA 17 | - name: Log in to Docker Hub 18 | uses: docker/login-action@v2 19 | with: 20 | username: ${{ secrets.DOCKER_HUB_USER }} 21 | password: ${{ secrets.DOCKER_HUB_TOKEN }} 22 | - name: push build to Docker Hub 23 | run: docker push metacpan/metacpan-grep-front-end:$GITHUB_SHA 24 | -------------------------------------------------------------------------------- /.github/workflows/build-production-container.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Build production container 3 | on: 4 | push: 5 | branches: 6 | - master 7 | workflow_dispatch: 8 | jobs: 9 | docker-build: 10 | if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'build-container') 11 | runs-on: ubuntu-22.04 12 | name: Docker Build and Push 13 | steps: 14 | - name: Generate Auth Token 15 | uses: actions/create-github-app-token@v2 16 | id: app-token 17 | with: 18 | app-id: ${{ secrets.APP_ID }} 19 | private-key: ${{ secrets.APP_PRIVATE_KEY }} 20 | owner: metacpan 21 | - name: Log in to Docker Hub 22 | uses: docker/login-action@v3 23 | with: 24 | username: ${{ secrets.DOCKER_HUB_USER }} 25 | password: ${{ secrets.DOCKER_HUB_TOKEN }} 26 | - name: Set up Docker Buildx 27 | uses: docker/setup-buildx-action@v3 28 | - uses: actions/checkout@v4 29 | with: 30 | token: ${{ steps.app-token.outputs.token }} 31 | - name: Docker meta 32 | id: meta 33 | uses: docker/metadata-action@v5 34 | with: 35 | images: ${{ github.repository }} 36 | flavor: | 37 | latest=false 38 | tags: | 39 | type=sha,format=long,priority=2000,enable={{is_default_branch}} 40 | type=ref,event=branch 41 | type=ref,event=pr 42 | type=raw,value=latest,enable={{is_default_branch}} 43 | env: 44 | DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index 45 | - name: Build and push 46 | uses: docker/build-push-action@v6 47 | with: 48 | build-args: | 49 | APP_ENV=poduction 50 | PLACKUP_ARGS=-E production -s Starman --workers=10 51 | push: true 52 | tags: ${{ steps.meta.outputs.tags }} 53 | labels: ${{ steps.meta.outputs.labels }} 54 | annotations: ${{ steps.meta.outputs.annotations }} 55 | - name: Update deployed image 56 | if: ${{ contains( fromJSON(steps.meta.outputs.json).tags, format('{0}:latest', github.repository)) }} 57 | uses: benc-uk/workflow-dispatch@v1 58 | with: 59 | repo: metacpan/metacpan-k8s 60 | ref: main 61 | workflow: set-image.yml 62 | token: ${{ steps.app-token.outputs.token }} 63 | inputs: '{ "app": "grep", "environment": "prod", "base-tag": "${{ github.repository }}:latest", "tag": "${{ fromJSON(steps.meta.outputs.json).tags[0] }}" }' 64 | -------------------------------------------------------------------------------- /.github/workflows/testsuite.yml: -------------------------------------------------------------------------------- 1 | name: Run testsuite for grep.metacpan 2 | 3 | on: 4 | push: 5 | # branches: [ main ] 6 | pull_request: 7 | 8 | jobs: 9 | test: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | # Checkout the main repo 14 | - name: Checkout current repo 15 | uses: actions/checkout@v4 16 | with: 17 | path: main-repo 18 | 19 | # Checkout the metacpan-cpan-extracted-lite repo 20 | - name: Checkout CPAN repo 21 | uses: actions/checkout@v4 22 | with: 23 | repository: metacpan/metacpan-cpan-extracted-lite 24 | path: metacpan-cpan-extracted-lite 25 | token: ${{ secrets.GITHUB_TOKEN }} 26 | 27 | - name: Setup container 28 | run: | 29 | cd main-repo 30 | make test-setup 31 | 32 | # Set up Docker Compose 33 | - name: Run tests 34 | run: | 35 | cd main-repo 36 | make test 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .env 3 | .tidyall.d 4 | MYMETA.json 5 | MYMETA.yml 6 | blib 7 | local 8 | pm_to_blib 9 | var/ 10 | -------------------------------------------------------------------------------- /.perlcriticrc: -------------------------------------------------------------------------------- 1 | # please alpha sort config items as you add them 2 | 3 | severity = 5 4 | verbose = 11 5 | 6 | [-ControlStructures::ProhibitPostfixControls] 7 | [-Documentation::RequirePodLinksIncludeText] 8 | [-Documentation::RequirePodSections] 9 | [-Modules::RequireVersionVar] 10 | [-RegularExpressions::RequireDotMatchAnything] 11 | [-RegularExpressions::RequireExtendedFormatting] 12 | [-RegularExpressions::RequireLineBoundaryMatching] 13 | [-Subroutines::ProhibitExplicitReturnUndef] 14 | [-Subroutines::ProhibitSubroutinePrototypes] 15 | [-ValuesAndExpressions::ProhibitNoisyQuotes] 16 | [-ValuesAndExpressions::ProhibitAccessOfPrivateData] 17 | [-Variables::ProhibitPunctuationVars] 18 | 19 | [CodeLayout::RequireTrailingCommas] 20 | severity = 4 21 | 22 | # Don't use function prototypes 23 | [Community::Prototypes] 24 | severity = 4 25 | signature_enablers = cPstrict GrepCpan::std 26 | 27 | [TestingAndDebugging::RequireUseStrict] 28 | equivalent_modules = MetaCPAN::Moose Mojo::Base Test::Routine 29 | 30 | [TestingAndDebugging::RequireUseWarnings] 31 | equivalent_modules = MetaCPAN::Moose Mojo::Base Test::Routine 32 | 33 | [ValuesAndExpressions::ProhibitEmptyQuotes] 34 | severity = 4 35 | 36 | [ValuesAndExpressions::ProhibitInterpolationOfLiterals] 37 | allow_if_string_contains_single_quote = 1 38 | allow = qq{} qq[] 39 | severity = 4 40 | 41 | [ValuesAndExpressions::ProhibitNoisyQuotes] 42 | severity = 4 43 | -------------------------------------------------------------------------------- /.perltidyrc: -------------------------------------------------------------------------------- 1 | -pbp 2 | -nst 3 | 4 | # Break a line after opening/before closing token. 5 | -vt=0 6 | -vtc=0 7 | -------------------------------------------------------------------------------- /.tidyallrc: -------------------------------------------------------------------------------- 1 | [PerlTidy] 2 | select = {lib,t,tools}/**/*.{pl,pm,t,psgi} 3 | select = Makefile.PL 4 | select = bin/app.psgi 5 | select = cpanfile 6 | ignore = t/var/**/* 7 | ignore = .gitignore 8 | ignore = cpanfile 9 | argv = --profile=$ROOT/.perltidyrc 10 | 11 | [PerlCritic] 12 | select = {lib,t}/**/*.{pl,pm,t,psgi} 13 | ignore = t/var/**/* 14 | 15 | [SortLines] 16 | select = .gitignore 17 | 18 | [UniqueLines] 19 | select = .gitignore 20 | -------------------------------------------------------------------------------- /.whitesource: -------------------------------------------------------------------------------- 1 | { 2 | "generalSettings": { 3 | "shouldScanRepo": true 4 | }, 5 | "checkRunSettings": { 6 | "vulnerableCheckRunConclusionLevel": "failure" 7 | } 8 | } -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ## 2 | ## Temporary image for installing metacpan packages 3 | ## 4 | 5 | FROM metacpan/metacpan-base:latest AS builder 6 | SHELL [ "/bin/bash", "-eo", "pipefail", "-c" ] 7 | 8 | # copy the cpanfile and cpanfile.snapshot 9 | # from the current directory to the /cpan directory in the image 10 | # and install the dependencies using cpm 11 | # we could then reuse the cpanfile and cpanfile.snapshot for testing 12 | WORKDIR /cpan 13 | 14 | COPY cpanfile ./ 15 | COPY cpanfile.snapshot ./ 16 | 17 | RUN < 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | .PHONY: all up-dev up-prod up test test-setup t 3 | 4 | APP_ENV ?= development 5 | DOCKER_ENV := $(if $(filter $(APP_ENV),test-setup),test,$(APP_ENV)) 6 | 7 | # Add overload config for docker-compose 8 | ifeq ($(APP_ENV),development) 9 | COMPOSE_FILE=docker-compose.yml:docker-compose.dev.yml 10 | else ifeq ($(APP_ENV),test-setup) 11 | COMPOSE_FILE=docker-compose.yml:docker-compose.dev.yml:docker-compose.test-setup.yml 12 | else ifeq ($(APP_ENV),test) 13 | COMPOSE_FILE=docker-compose.yml:docker-compose.dev.yml:docker-compose.test.yml 14 | else 15 | COMPOSE_FILE=docker-compose.yml 16 | endif 17 | 18 | all: 19 | $(MAKE) up 20 | 21 | up: 22 | ln -sf config/docker-compose.$(DOCKER_ENV).env .env 23 | APP_ENV=$(DOCKER_ENV) docker compose -f $(subst :, -f ,$(COMPOSE_FILE)) up --build --exit-code-from grep 24 | 25 | up-dev: 26 | $(MAKE) up APP_ENV=development 27 | 28 | up-prod: 29 | $(MAKE) up APP_ENV=production 30 | 31 | t: test 32 | 33 | test-setup: 34 | $(MAKE) up APP_ENV=test-setup 35 | 36 | test: 37 | $(MAKE) up APP_ENV=test 38 | 39 | bash: 40 | docker exec -it grep-container /bin/bash -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # metacpan-grep-front-end 2 | 3 | Grep Front End code for [grep.metacpan.org](https://grep.metacpan.org) 4 | 5 | [![Build Status](https://travis-ci.org/metacpan/metacpan-grep-front-end.svg?branch=master)](https://travis-ci.org/metacpan/metacpan-grep-front-end) 6 | [![Coverage Status](https://coveralls.io/repos/github/metacpan/metacpan-grep-front-end/badge.svg?branch=master&cache=1)](https://coveralls.io/github/metacpan/metacpan-grep-front-end?branch=master) 7 | 8 | [![grep.metacpan](https://raw.githubusercontent.com/metacpan/metacpan-grep-front-end/master/public/static/images/grep-cpan-logo-flat.png)](https://grep.metacpan.org) 9 | 10 | ## GETTING STARTED 11 | 12 | grep.metacpan.org is currently not using [metacpan-developer](https://github.com/metacpan/metacpan-developer), 13 | but it should be pretty straight forward to setup a development environment and starting submitting Pull Request via GitHub. 14 | 15 | ## Requirements 16 | 17 | * docker & docker compose 18 | * checkout a version of `metacpan-extracted` view details after to use `metacpan-cpan-extracted-lite` 19 | 20 | ## Cloning repositories 21 | 22 | You should start forking the main [metacpan-grep-front-end repository](https://github.com/metacpan/metacpan-grep-front-end) 23 | You can then clone it locally (where you should replace ~YOUR-GITHUB-USERNAME~ by your github username ) 24 | 25 | > git clone git@github.com:~YOUR-GITHUB-USERNAME~/metacpan-grep-front-end.git 26 | > cd metacpan-grep-front-end 27 | > git remote add upstream https://github.com/metacpan/metacpan-grep-front-end.git 28 | 29 | The frontend is not using a database, but a `git repo` itself as a backend. 30 | For this the production is using one huge git repository (~20 Go) indexing all the CPAN in one place ! 31 | You can read more on this topic and find tools used to build this Git repo on the [GitHub Repos](https://grep.metacpan.org/source-code) page. 32 | 33 | We do not want to use such a beast during development cycles, we only need a smaller version of it, 34 | you can simply clone it from this [metacpan-cpan-extracted-lite](https://github.com/metacpan/metacpan-cpan-extracted-lite). 35 | It should be clone at the same level of *metacpan-grep-front-end* itself (do not clone it inside the repository). 36 | 37 | # clone at the same level of metacpan-grep-front-end 38 | # cd .. # if you are in metacpan-grep-front-end repo 39 | > git clone https://github.com/metacpan/metacpan-cpan-extracted-lite.git 40 | 41 | # you should have something like this 42 | > ls -d metacpan-* 43 | metacpan-cpan-extracted-lite metacpan-grep-front-end 44 | 45 | ## Starting the development server 46 | 47 | > make # alias to `make up` or `make up-dev` 48 | Watching . bin/lib bin/app.psgi for file updates. 49 | HTTP::Server::PSGI: Accepting connections at http://0:5010/ 50 | 51 | This will start a docker container setup by `docker-compose.yml` using by default the `development` environment. 52 | 53 | You can now open your browser to this url, and you should be able to see the 54 | grep.metacpan.org homepage. 55 | 56 | http://127.0.0.1:5010 57 | 58 | ## Custom configurations 59 | 60 | Each environment comes with its own environment, 61 | by default they all use values from the default configuration `config.yml`, 62 | but they can overwrite some values or provide some custom values using their own 63 | file. 64 | 65 | config.yml 66 | environments/development.yml 67 | environments/metacpan.yml 68 | environments/production.yml 69 | 70 | If you need two tweak your development environment you should look at `environments/development.yml` 71 | You can even create your own environment if required. 72 | 73 | From there you should be ready to 74 | 75 | # hack, hack, hack... 76 | -> Submit a Pull Request to GitHub 77 | # continue to hack, hack, ... 78 | have fun ! 79 | -------------------------------------------------------------------------------- /config/docker-compose.development.env: -------------------------------------------------------------------------------- 1 | HOST_PORT=5010 2 | PLACKUP_ARGS='-R lib,bin' 3 | CPAN_VOLUME_PATH=../metacpan-cpan-extracted-lite 4 | # only setup for development purpose 5 | SRC_VOLUME_PATH=./src -------------------------------------------------------------------------------- /config/docker-compose.production.env: -------------------------------------------------------------------------------- 1 | HOST_PORT=5055 2 | PLACKUP_ARGS='-E production -s Starman --workers=10 -l /tmp/app.sock' 3 | CPAN_VOLUME_PATH=/metacpan-cpan-extracted -------------------------------------------------------------------------------- /config/docker-compose.test.env: -------------------------------------------------------------------------------- 1 | HOST_PORT=5010 2 | PLACKUP_ARGS='-R lib,bin' 3 | CPAN_VOLUME_PATH=../metacpan-cpan-extracted-lite 4 | # only setup for development purpose 5 | SRC_VOLUME_PATH=./src -------------------------------------------------------------------------------- /cpanfile: -------------------------------------------------------------------------------- 1 | requires "Git::Repository" => 0; 2 | requires "Gazelle" => 0; 3 | requires "Proc::ProcessTable" => 0; 4 | requires "Digest::MD5" => 0; 5 | requires "Simple::Accessor" => "1.02"; 6 | requires "Time::HiRes" => 0; 7 | requires "Test::Harness" => 0; 8 | requires "Dancer2" => "0"; 9 | requires "Template" => 0; 10 | requires "JSON::XS" => 0; 11 | requires "Plack" => 0; 12 | requires "Plack::Middleware" => 0; 13 | requires "Plack::Middleware::Deflater" => 0; 14 | requires "Plack::Handler::Starman" => 0; 15 | requires "File::Slurp" => 0; 16 | requires "Fcntl" => 0; 17 | requires "FindBin" => 0; 18 | requires "Cpanel::JSON::XS" => 0; 19 | requires "JSON::MaybeXS" => 0; 20 | requires "HTTP::Entity::Parser" => 0; 21 | requires "Sereal" => 0; 22 | requires "Sereal::Encoder" => 0; 23 | requires "Sereal::Decoder" => 0; 24 | 25 | recommends "YAML" => "0"; 26 | recommends "URL::Encode::XS" => "0"; 27 | recommends "CGI::Deurl::XS" => "0"; 28 | recommends "HTTP::Parser::XS" => "0"; 29 | 30 | on "test" => sub { 31 | requires "File::Temp" => "0"; 32 | requires "Test::More" => "0"; 33 | requires "Test::Builder" => "0"; 34 | requires "HTTP::Request::Common" => "0"; 35 | requires "Test2::Suite" => "0"; 36 | requires "Test2::Bundle::Extended" => "0"; 37 | requires "Test2::Tools::Explain" => "0"; 38 | requires "Test2::Plugin::NoWarnings" => "0"; 39 | requires "List::MoreUtils" => "0"; 40 | }; 41 | 42 | on 'develop' => sub { 43 | recommends 'Devel::NYTProf'; 44 | recommends "Code::TidyAll::Git::Precommit"; 45 | recommends "Code::TidyAll::Plugin::UniqueLines"; 46 | recommends "Perl::Critic::Policy::Documentation::RequirePodLinksIncludeText"; 47 | recommends "Perl::Critic::Nits"; 48 | recommends "Perl::Critic::Policy::Community::Prototypes"; 49 | }; 50 | 51 | -------------------------------------------------------------------------------- /deploy/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DEPLOY_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 4 | 5 | source "${DEPLOY_DIR}/vars.sh" 6 | 7 | # ## Go to where the docker file is 8 | cd "${DEPLOY_DIR}/.." 9 | 10 | ## Pull the latest docker file from docker hub if there is one 11 | docker pull "$DOCKER_HUB_NAME" || true 12 | 13 | ## Issue the build command, adding tags (from CONFIG.sh) 14 | docker build --pull --cache-from "$DOCKER_HUB_NAME" --tag $DOCKER_HUB_NAME --tag $VERSION_TAG . 15 | -------------------------------------------------------------------------------- /deploy/push.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DEPLOY_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 4 | 5 | if [[ "x${DEPLOY_REPO_SLUG}" != "x${TRAVIS_REPO_SLUG}" ]]; then 6 | echo "skip push.sh: only deploy on ${DEPLOY_REPO_SLUG} repo."; 7 | exit; 8 | fi 9 | 10 | if [[ "x$DOCKER_HUB_USER" == "x" ]]; then 11 | echo "DOCKER_HUB_USER env is not defined."; 12 | exit 1; 13 | fi 14 | 15 | if [[ "x$DOCKER_HUB_PASSWD" == "x" ]]; then 16 | echo "DOCKER_HUB_PASSWD env is not defined."; 17 | exit 1; 18 | fi 19 | 20 | source "${DEPLOY_DIR}/vars.sh" 21 | 22 | cd "${DEPLOY_DIR}/.." 23 | 24 | docker login -u "$DOCKER_HUB_USER" -p "$DOCKER_HUB_PASSWD" 25 | docker push "$DOCKER_HUB_NAME" -------------------------------------------------------------------------------- /deploy/vars.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ## Edit this 4 | if [ -z $DOCKER_IMAGE_NAME ]; then 5 | echo "DOCKER_IMAGE_NAME is not defined" 6 | exit 1; 7 | fi 8 | 9 | ## Should not need to edit this 10 | export DOCKER_HUB_NAME="metacpan/${DOCKER_IMAGE_NAME}" 11 | export VERSION="${TRAVIS_BUILD_NUMBER:-UNKNOWN-BUILD-NUMBER}" 12 | export VERSION_TAG="${DOCKER_HUB_NAME}:${VERSION}" 13 | 14 | -------------------------------------------------------------------------------- /docker-compose.dev.yml: -------------------------------------------------------------------------------- 1 | # overload the default docker-compose.yml 2 | # to mount the source code into the container 3 | services: 4 | grep: 5 | volumes: 6 | - ${SRC_VOLUME_PATH:-/not/there}:/metacpan-grep-front-end 7 | -------------------------------------------------------------------------------- /docker-compose.test-setup.yml: -------------------------------------------------------------------------------- 1 | services: 2 | grep: 3 | command: ["/usr/bin/true"] 4 | environment: 5 | - APP_ENV=test -------------------------------------------------------------------------------- /docker-compose.test.yml: -------------------------------------------------------------------------------- 1 | services: 2 | grep: 3 | command: ["bash", "t/run-tests.sh"] 4 | environment: 5 | - APP_ENV=test -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | 3 | grep: 4 | build: 5 | context: . 6 | args: 7 | APP_ENV: development 8 | env_file: 9 | - .env 10 | environment: 11 | - MY_SHARED_ENV=value 12 | volumes: 13 | - ./config:/app/config 14 | - ${SRC_VOLUME_PATH:-}:/metacpan-grep-front-end 15 | # mount the cpan repo as read-only to mimic production 16 | - ${CPAN_VOLUME_PATH}:/metacpan-cpan-extracted:ro 17 | ports: 18 | - "${HOST_PORT:-8088}:3000" 19 | container_name: grep-container 20 | 21 | volumes: 22 | myapp-data: -------------------------------------------------------------------------------- /docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | src/docker-entrypoint.sh -------------------------------------------------------------------------------- /launcher/devel-server: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #killall plackup 4 | killall git 5 | plackup -p 5010 -R lib,bin bin/app.psgi 6 | #carton plackup -p 5000 -R . bin/app.psgi 7 | #carton exec starman -p 5000 -R . bin/app.psgi 8 | -------------------------------------------------------------------------------- /launcher/metacpan-server: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | plackup -E metacpan -p 5055 -R . bin/app.psgi 4 | #plackup -E metacpan -s Starman --workers=10 -l /tmp/app.sock -a ./bin/app.pl 5 | -------------------------------------------------------------------------------- /launcher/production-server: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | plackup -E production -p 5005 bin/app.psgi 4 | #plackup -E production -s Starman --workers=10 -l /tmp/app.sock -a ./bin/app.pl 5 | -------------------------------------------------------------------------------- /launcher/test-production-server: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export PATH=/opt/perl-5.22.2/bin:$PATH 4 | export LD_LIBRARY_PATH=/lib:/home/atoomic/lib 5 | export PATH=/home/atoomic/metacpan-grep-front-end/local/bin:$PATH 6 | 7 | plackup -p 5051 -R . bin/app.psgi 8 | -------------------------------------------------------------------------------- /src/app.psgi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | use FindBin; 6 | use lib "$FindBin::Bin/../lib"; 7 | 8 | 9 | # use this block if you don't need middleware, and only have a single target Dancer app to run here 10 | use grepcpan; 11 | 12 | grepcpan->to_app; 13 | 14 | use Plack::Builder; 15 | 16 | builder { 17 | enable 'Deflater'; 18 | grepcpan->to_app; 19 | } 20 | 21 | 22 | 23 | =begin comment 24 | # use this block if you want to include middleware such as Plack::Middleware::Deflater 25 | 26 | use grepcpan; 27 | use Plack::Builder; 28 | 29 | builder { 30 | enable 'Deflater'; 31 | grepcpan->to_app; 32 | } 33 | 34 | =end comment 35 | 36 | =cut 37 | 38 | =begin comment 39 | # use this block if you want to include middleware such as Plack::Middleware::Deflater 40 | 41 | use grepcpan; 42 | use grepcpan_admin; 43 | 44 | builder { 45 | mount '/' => grepcpan->to_app; 46 | mount '/admin' => grepcpan_admin->to_app; 47 | } 48 | 49 | =end comment 50 | 51 | =cut 52 | 53 | -------------------------------------------------------------------------------- /src/bin/app.psgi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | use FindBin; 6 | use lib "$FindBin::Bin/../lib"; 7 | 8 | 9 | # use this block if you don't need middleware, and only have a single target Dancer app to run here 10 | use grepcpan; 11 | 12 | grepcpan->to_app; 13 | 14 | use Plack::Builder; 15 | 16 | builder { 17 | enable 'Deflater'; 18 | grepcpan->to_app; 19 | } 20 | 21 | 22 | 23 | =begin comment 24 | # use this block if you want to include middleware such as Plack::Middleware::Deflater 25 | 26 | use grepcpan; 27 | use Plack::Builder; 28 | 29 | builder { 30 | enable 'Deflater'; 31 | grepcpan->to_app; 32 | } 33 | 34 | =end comment 35 | 36 | =cut 37 | 38 | =begin comment 39 | # use this block if you want to include middleware such as Plack::Middleware::Deflater 40 | 41 | use grepcpan; 42 | use grepcpan_admin; 43 | 44 | builder { 45 | mount '/' => grepcpan->to_app; 46 | mount '/admin' => grepcpan_admin->to_app; 47 | } 48 | 49 | =end comment 50 | 51 | =cut 52 | 53 | -------------------------------------------------------------------------------- /src/config.yml: -------------------------------------------------------------------------------- 1 | # This is the main configuration file of your Dancer2 app 2 | # env-related settings should go to environments/$env.yml 3 | # all the settings in this file will be loaded at Dancer's startup. 4 | 5 | # Your application's name 6 | appname: "grepcpan" 7 | 8 | # The default layout to use for your application (located in 9 | # views/layouts/main.tt) 10 | layout: "main" 11 | 12 | # when the charset is set to UTF-8 Dancer2 will handle for you 13 | # all the magic of encoding and decoding. You should not care 14 | # about unicode within your app when this setting is set (recommended). 15 | charset: "UTF-8" 16 | 17 | # template engine 18 | # simple: default and very basic template engine 19 | # template_toolkit: TT 20 | 21 | #template: "simple" 22 | 23 | template: "template_toolkit" 24 | engines: 25 | template: 26 | template_toolkit: 27 | start_tag: '<%' 28 | end_tag: '%>' 29 | 30 | # session engine 31 | # 32 | # Simple: in-memory session store - Dancer2::Session::Simple 33 | # YAML: session stored in YAML files - Dancer2::Session::YAML 34 | # 35 | # Check out metacpan for other session storage options: 36 | # https://metacpan.org/search?q=Dancer2%3A%3ASession&search_type=modules 37 | # 38 | # Default value for 'cookie_name' is 'dancer.session'. If you run multiple 39 | # Dancer apps on the same host then you will need to make sure 'cookie_name' 40 | # is different for each app. 41 | # 42 | #engines: 43 | # session: 44 | # Simple: 45 | # cookie_name: testapp.session 46 | # 47 | #engines: 48 | # session: 49 | # YAML: 50 | # cookie_name: eshop.session 51 | # is_secure: 1 52 | # is_http_only: 1 53 | 54 | grepcpan: 55 | demo: 0 56 | nocache: 0 57 | maxworkers: 1000 58 | timeout: 59 | # the main process returning the http request to the user ( in seconds ) 60 | user_search: 18 61 | # the grep process running in background ( in seconds ) 62 | grep_search: 900 63 | cookie: 64 | history_name: 'lastsearch' 65 | history_size: 20 66 | limit: 67 | files_per_search: 60 68 | files_git_run_bg: 2000 69 | distros_per_page: 30 70 | search_context: 5 71 | search_context_distro: 10 72 | search_context_file: 60 73 | gitrepo: '/home/toddr/metacpan-cpan-extracted' 74 | binaries: 75 | git: '/home/atoomic/bin/git' 76 | cache: 77 | directory: '~APPDIR~/var/tmp' 78 | version: '2.11' 79 | 80 | -------------------------------------------------------------------------------- /src/docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | if [ "$1" = "serve" ]; then 4 | echo "Starting the application..." 5 | echo "Environment: $APP_ENV" 6 | echo "Host Port: $HOST_PORT" 7 | echo "Plackup Options: ${PLACKUP_ARGS}" 8 | echo "git binary: $(which git) - $(git --version)" 9 | echo "=========================" 10 | echo "Access the application at http://localhost:${HOST_PORT}" 11 | echo "=========================" 12 | 13 | plackup -p 3000 ${PLACKUP_ARGS} bin/app.psgi 14 | else 15 | echo "Running custom command: $@" 16 | exec "$@" 17 | fi -------------------------------------------------------------------------------- /src/environments/development.yml: -------------------------------------------------------------------------------- 1 | # configuration file for development environment 2 | 3 | # the logger engine to use 4 | # console: log messages to STDOUT (your console where you started the 5 | # application server) 6 | # file: log message to a file in log/ 7 | logger: "console" 8 | 9 | # the log level for this environment 10 | # core is the lowest, it shows Dancer2's core log messages as well as yours 11 | # (debug, info, warning and error) 12 | log: "core" 13 | 14 | # should Dancer2 consider warnings as critical errors? 15 | warnings: 1 16 | 17 | # should Dancer2 show a stacktrace when an 5xx error is caught? 18 | # if set to yes, public/500.html will be ignored and either 19 | # views/500.tt, 'error_template' template, or a default error template will be used. 20 | show_errors: 1 21 | 22 | # print the banner 23 | startup_info: 1 24 | 25 | grepcpan: 26 | nocache: 0 27 | maxworkers: 2 28 | gitrepo: '/metacpan-cpan-extracted' 29 | binaries: 30 | git: '/usr/bin/git' 31 | cache: 32 | directory: '~APPDIR~/var/tmp' 33 | -------------------------------------------------------------------------------- /src/environments/metacpan.yml: -------------------------------------------------------------------------------- 1 | # configuration file for production environment 2 | 3 | # only log warning and error messsages 4 | log: "warning" 5 | 6 | # log message to a file in logs/ 7 | logger: "file" 8 | 9 | # don't consider warnings critical 10 | warnings: 0 11 | 12 | # hide errors 13 | show_errors: 0 14 | 15 | # disable server tokens in production environments 16 | no_server_tokens: 1 17 | 18 | grepcpan: 19 | nocache: 0 20 | maxworkers: 1000 21 | root_dir: '/metacpan-grep-front-end' 22 | gitrepo: '/metacpan-cpan-extracted' 23 | binaries: 24 | git: '/usr/bin/git' 25 | cache: 26 | directory: '~APPDIR~/var/tmp' 27 | -------------------------------------------------------------------------------- /src/environments/production-docker.yml: -------------------------------------------------------------------------------- 1 | # configuration file for production environment 2 | 3 | # only log warning and error messsages 4 | log: "warning" 5 | 6 | # log message to a file in logs/ 7 | logger: "file" 8 | 9 | # don't consider warnings critical 10 | warnings: 0 11 | 12 | # hide errors 13 | show_errors: 0 14 | 15 | # disable server tokens in production environments 16 | no_server_tokens: 1 17 | 18 | grepcpan: 19 | nocache: 0 20 | maxworkers: 256 21 | root_dir: '/metacpan-grep-front-end' 22 | gitrepo: '/shared/metacpan_git' 23 | cache: 24 | directory: '/var/tmp' 25 | -------------------------------------------------------------------------------- /src/environments/production.yml: -------------------------------------------------------------------------------- 1 | # configuration file for production environment 2 | 3 | # only log warning and error messsages 4 | log: "warning" 5 | 6 | # log message to a file in logs/ 7 | logger: "file" 8 | 9 | # don't consider warnings critical 10 | warnings: 0 11 | 12 | # hide errors 13 | show_errors: 0 14 | 15 | # disable server tokens in production environments 16 | no_server_tokens: 1 17 | 18 | grepcpan: 19 | nocache: 0 20 | maxworkers: 1000 21 | root_dir: '/metacpan-grep-front-end' 22 | gitrepo: '/shared/metacpan_git' 23 | binaries: 24 | git: '/usr/bin/git' 25 | cache: 26 | directory: '~APPDIR~/var/tmp' 27 | -------------------------------------------------------------------------------- /src/environments/unit-tests.yml: -------------------------------------------------------------------------------- 1 | # configuration file for development environment 2 | 3 | # the logger engine to use 4 | # console: log messages to STDOUT (your console where you started the 5 | # application server) 6 | # file: log message to a file in log/ 7 | logger: "console" 8 | 9 | # the log level for this environment 10 | # core is the lowest, it shows Dancer2's core log messages as well as yours 11 | # (debug, info, warning and error) 12 | log: "core" 13 | 14 | # should Dancer2 consider warnings as critical errors? 15 | warnings: 1 16 | 17 | # should Dancer2 show a stacktrace when an 5xx error is caught? 18 | # if set to yes, public/500.html will be ignored and either 19 | # views/500.tt, 'error_template' template, or a default error template will be used. 20 | show_errors: 1 21 | 22 | # print the banner 23 | startup_info: 1 24 | 25 | grepcpan: 26 | nocache: 0 27 | maxworkers: 2 28 | gitrepo: '/metacpan-cpan-extracted' 29 | cache: 30 | directory: '/tmp' 31 | -------------------------------------------------------------------------------- /src/lib/GrepCpan/Grep.pm: -------------------------------------------------------------------------------- 1 | package GrepCpan::Grep; 2 | 3 | use v5.036; 4 | use GrepCpan::std; 5 | 6 | use Git::Repository (); 7 | use Sereal (); 8 | 9 | =pod 10 | 11 | git grep -l to a file to cache the result ( limit it to 200 files and run it in background after ?? ) 12 | use this list for pagination 13 | then do a query for a set of files with context 14 | 15 | grepcpan@grep.cpan.me [~/minicpan_grep.git]# time git grep -C15 -n xyz HEAD | head -n 200 16 | 17 | =cut 18 | 19 | use Simple::Accessor qw{ 20 | config git cache distros_per_page search_context 21 | search_context_file search_context_distro 22 | git_binary root HEAD 23 | }; 24 | 25 | use POSIX qw{:sys_wait_h setsid}; 26 | use Proc::ProcessTable (); 27 | use Time::HiRes (); 28 | use File::Path (); 29 | use File::Slurp (); 30 | use IO::Handle (); 31 | use Fcntl qw(:flock SEEK_END); 32 | 33 | use FindBin; 34 | use utf8; 35 | 36 | use Digest::MD5 qw( md5_hex ); 37 | 38 | use constant END_OF_FILE_MARKER => qq{##______END_OF_FILE_MARKER______##}; 39 | use constant TOO_BUSY_MARKER => qq{##______TOO_BUSY_MARKER______##}; 40 | 41 | use constant CACHE_IS_ENABLED => 1; 42 | 43 | sub _build_git($self) { 44 | 45 | my $gitdir = $self->massage_path( $self->config()->{'gitrepo'} ); 46 | die qq{Invalid git directory $gitdir} 47 | unless defined $gitdir && -d $gitdir; 48 | 49 | return Git::Repository->new( 50 | work_tree => $gitdir, 51 | { git => $self->git_binary } 52 | ); 53 | } 54 | 55 | sub _build_git_binary($self) { 56 | 57 | my $git = $self->config()->{'binaries'}->{'git'}; 58 | return $git if $git && -x $git; 59 | $git = qx{which git}; 60 | chomp $git; 61 | 62 | return $git; 63 | } 64 | 65 | sub _build_HEAD($self) { 66 | 67 | my $head = $self->git()->run(qw{rev-parse --short HEAD}); 68 | chomp $head if defined $head; 69 | die unless length($head); 70 | 71 | return $head; 72 | } 73 | 74 | sub cpan_index_at($self) { 75 | 76 | my $now = time(); 77 | my $last_refresh = $self->{_cpan_index_last_refresh_at} // 0; 78 | 79 | # cache the value for 90 minutes 80 | if ( !$last_refresh || ( $now - $last_refresh ) > ( 60 * 90 ) ) { 81 | $self->{_cpan_index_last_refresh_at} = $now; 82 | $self->{_cpan_index_at} = $self->_build_cpan_index_at(); 83 | } 84 | 85 | return $self->{_cpan_index_at}; 86 | } 87 | 88 | sub _build_cpan_index_at($self) { 89 | 90 | # git log -n1 --date=format:'%B %-d %Y' --pretty=format:'%ad' 91 | my $out = $self->git()->run( 92 | 'log', '-n1', 93 | q[--date=format:'%B %-d %Y'], q[--pretty=format:'%ad'] 94 | ) // ''; 95 | chomp $out; 96 | $out =~ s{['"]}{}g; 97 | 98 | return $out; 99 | } 100 | 101 | sub _build_cache($self) { 102 | 103 | my $dir 104 | = $self->_current_cache_version_directory() . '/HEAD-' . $self->HEAD; 105 | 106 | $dir = $self->massage_path($dir); 107 | 108 | return $dir if -d $dir; 109 | 110 | File::Path::make_path( $dir, { mode => 0711, } ) 111 | or die "Failed to create $dir: $!"; 112 | die unless -d $dir; 113 | 114 | # cleanup after directory structure creation 115 | $self->cache_cleanup($dir); 116 | 117 | return $dir; 118 | } 119 | 120 | sub _current_cache_version_directory($self) { 121 | 122 | return ( $self->config()->{'cache'}->{'directory'} ) . '/' 123 | . ( $self->config()->{'cache'}->{'version'} || 0 ); 124 | } 125 | 126 | sub _build_root($self) { 127 | 128 | # hard code root dir in production 129 | return $self->config()->{'root_dir'} if $self->config()->{'root_dir'}; 130 | 131 | return $FindBin::Bin . '/'; 132 | } 133 | 134 | sub cache_cleanup( $self, $current_cachedir = undef ) { # aka tmpwatch 135 | 136 | return unless $current_cachedir; 137 | 138 | my @path = split qr{/}, $current_cachedir; 139 | 140 | if ( my $cache_root = $self->config()->{'cache'}->{'directory'} ) { 141 | 142 | # purge old cache versions 143 | if ( opendir( my $tmp_dh, $cache_root ) ) { 144 | foreach my $dir ( readdir($tmp_dh) ) { 145 | next if $dir eq '.' || $dir eq '..'; 146 | my $fdir = $cache_root . '/' . $dir; 147 | next 148 | if $dir eq 149 | ( $self->config()->{'cache'}->{'version'} || 0 ); 150 | next if -l $fdir; 151 | next unless -d $fdir; 152 | next unless length $fdir > 5; 153 | 154 | # kind of dangerous but should be ok, we are controlling these values 155 | File::Path::remove_tree( $fdir, { safe => 1 } ) 156 | or warn "Failed to remove $fdir: $!"; 157 | } 158 | } 159 | } 160 | 161 | if ( my $version_cache = $self->_current_cache_version_directory() ) { 162 | 163 | # purge old HEAD directories for the same version 164 | if ( opendir( my $tmp_dh, $version_cache ) ) { 165 | foreach my $dir ( readdir($tmp_dh) ) { 166 | next if $dir eq '.' || $dir eq '..'; 167 | my $fdir = $version_cache . '/' . $dir; 168 | next if -l $fdir; 169 | next unless -d $fdir; 170 | next if $fdir eq $current_cachedir; 171 | 172 | # purge old cache, in the same weird fashion 173 | File::Path::remove_tree( $fdir, { safe => 1 } ) 174 | or warn "Failed to remove $fdir: $!"; 175 | } 176 | } 177 | } 178 | 179 | return; 180 | } 181 | 182 | sub massage_path ( $self, $s ) { 183 | 184 | return unless length $s; 185 | 186 | my $appdir = $self->root; 187 | $appdir =~ s{/(?:bin|t)/?$}{}; 188 | 189 | $s =~ s{~APPDIR~}{$appdir}g; 190 | 191 | return $s; 192 | } 193 | 194 | ## TODO factorize 195 | # Define builder methods for integer configuration values 196 | BEGIN { 197 | # initialize (integer) value from config 198 | foreach my $key ( 199 | qw{distros_per_page search_context search_context_distro search_context_file} 200 | ) 201 | { 202 | my $sub = '_build_' . $key; 203 | my $code = sub ($self) { 204 | my $v = $self->config()->{limit}{$key}; 205 | die "Missing configuration for limit.$key" unless defined $v; 206 | return int($v); 207 | }; 208 | 209 | # Install the method in the current package 210 | no strict 'refs'; ## no critic qw(ProhibitNoStrict) 211 | *$sub = $code; 212 | } 213 | } 214 | 215 | sub _sanitize_search($s) { 216 | 217 | return undef unless defined $s; 218 | $s =~ s{\n}{}g; 219 | $s =~ s{'}{\'}g; 220 | 221 | # whitelist possible characters ? 222 | $s =~ s{[^\^a-zA-Z0-9\-\.\?\\*\&_'"~!\$\%()\[\]\{\}:;<>,/\@| =]}{.}g; 223 | 224 | return $s; 225 | } 226 | 227 | sub _get_git_grep_flavor($s) { 228 | 229 | # regular characters 230 | return q{--fixed-string} 231 | if !defined $s || $s =~ qr{^[a-zA-Z0-9&_'"~:;<>,/ =]+$}; 232 | return q{-P}; 233 | } 234 | 235 | # idea use git rev-parse HEAD to include it in the cache name 236 | 237 | sub do_search ( $self, %opts ) { 238 | 239 | my ( $search, $search_distro, $search_file, $filetype, 240 | $caseinsensitive, $ignore_files, ) 241 | = ( 242 | $opts{search}, $opts{search_distro}, 243 | $opts{search_file}, $opts{filetype}, 244 | $opts{caseinsensitive}, $opts{ignore_files}, 245 | ); 246 | 247 | my $t0 = [Time::HiRes::gettimeofday]; 248 | 249 | my $gitdir = $self->git()->work_tree; 250 | 251 | $search = _sanitize_search($search); 252 | 253 | my $results = $self->_do_search(%opts); 254 | 255 | my $cache = $results->{cache}; 256 | my $output = $results->{output}; 257 | my $is_a_known_distro = $results->{is_a_known_distro}; 258 | 259 | my $elapsed = sprintf( "%.3f", 260 | Time::HiRes::tv_interval( $t0, [Time::HiRes::gettimeofday] ) ); 261 | 262 | return { 263 | is_incomplete => $cache->{is_incomplete} || 0, 264 | search_in_progress => $cache->{search_in_progress} || 0, 265 | match => $cache->{match}, 266 | adjusted_request => $cache->{adjusted_request} // {}, 267 | results => $output, 268 | time_elapsed => $elapsed, 269 | is_a_known_distro => $is_a_known_distro, 270 | version => $self->current_version(), 271 | }; 272 | } 273 | 274 | sub _do_search ( $self, %opts ) { 275 | 276 | my ( $search, $page, $search_distro, $search_file, 277 | $filetype, $caseinsensitive, $ignore_files ) 278 | = ( 279 | $opts{search}, $opts{page}, $opts{search_distro}, $opts{search_file}, 280 | $opts{filetype}, $opts{caseinsensitive}, $opts{ignore_files} 281 | ); 282 | 283 | $page //= 0; 284 | $page = 0 if $page < 0; 285 | 286 | # 287 | my $cache = $self->_get_match_cache( $search, $search_distro, $filetype, 288 | $caseinsensitive, $ignore_files ); 289 | 290 | my $is_a_known_distro 291 | = defined $search_distro 292 | && length $search_distro 293 | && exists $cache->{distros}->{$search_distro}; 294 | 295 | my $context = $self->search_context(); # default context 296 | if ( defined $search_file ) { 297 | $context = $self->search_context_file(); 298 | } 299 | elsif ($is_a_known_distro) { 300 | $context = $self->search_context_distro(); 301 | } 302 | 303 | my $files_to_search 304 | = $self->get_list_of_files_to_search( $cache, $search, $page, 305 | $search_distro, $search_file, $filetype ); ## notidy 306 | 307 | # can also probably simply use Git::Repo there 308 | my $matches; 309 | 310 | if ( scalar @$files_to_search ) { 311 | my $flavor = _get_git_grep_flavor($search); 312 | my @git_cmd = ('grep'); 313 | push @git_cmd, '-i' if $caseinsensitive; 314 | push @git_cmd, 315 | ( 316 | '-n', '--heading', '-C', $context, $flavor, '-e', $search, '--', 317 | @$files_to_search 318 | ); 319 | my @out = $self->git->run(@git_cmd); 320 | $matches = \@out; 321 | } 322 | 323 | # now format the output in order to be able to use it 324 | my @output; 325 | my $current_file; 326 | my @diffblocks; 327 | my $diff = ''; 328 | my $line_number; 329 | my $start_line; 330 | my @matching_lines; 331 | 332 | my $add_block = sub { 333 | return unless $diff && length($diff); 334 | push @diffblocks, 335 | { 336 | code => $diff, 337 | start_at => $start_line || 1, 338 | matchlines => [@matching_lines] 339 | }; 340 | return; 341 | }; 342 | 343 | my $process_file = sub { 344 | return unless defined $current_file; 345 | $add_block->(); # push the last block 346 | 347 | my ( $where, $distro, $shortpath ) = massage_filepath($current_file); 348 | return unless length $shortpath; 349 | my $prefix = join '/', $where, $distro; 350 | 351 | my $result = $cache->{distros}->{$distro} // {}; 352 | $result->{distro} //= $distro; 353 | $result->{matches} //= []; 354 | 355 | #@diffblocks = scalar @diffblocks; # debugging clear the blocks 356 | push @{ $result->{matches} }, 357 | { file => $shortpath, blocks => [@diffblocks] }; 358 | return 359 | if scalar @output 360 | && $output[-1] eq 361 | $result; # same hash do not add it more than once 362 | push @output, $result; 363 | 364 | return; 365 | }; 366 | 367 | my $previous_file; 368 | my $qr_match_line = qr{^([0-9]+)([-:])}; 369 | 370 | foreach my $line (@$matches) { 371 | if ( !defined $current_file ) { 372 | 373 | # when more than one block match we are just going to have a -- separator 374 | if ( $line =~ m{^distros/} ) { 375 | $previous_file = $current_file = $line; 376 | next; 377 | } 378 | $current_file //= $previous_file; 379 | } 380 | 381 | if ( $line eq '--' ) { 382 | 383 | # we found a new block, it's either from the current file or a new one 384 | $process_file->(); 385 | undef $current_file; # reset: could use previous or next file 386 | $diff = ''; 387 | @diffblocks = (); 388 | undef $start_line; 389 | undef $line_number; 390 | @matching_lines = (); 391 | next; 392 | } 393 | 394 | # matching the main part 395 | next unless $line =~ s/$qr_match_line//; 396 | my ( $new_line, $prefix ) = ( $1, $2 ); 397 | 398 | $start_line //= $new_line; 399 | if ( length($line) > 250 ) 400 | { # max length autorized ( js minified & co ) 401 | $line = substr( $line, 0, 250 ) . '...'; 402 | } 403 | if ( !defined $line_number || $new_line == $line_number + 1 ) { 404 | 405 | # same block 406 | push @matching_lines, $new_line if $prefix eq ':'; 407 | $diff .= $line . "\n"; 408 | } 409 | else { 410 | # new block 411 | $add_block->(); 412 | $diff = $line . "\n"; # reset the block 413 | } 414 | $line_number = $new_line; 415 | 416 | } 417 | $process_file->(); # process the last block 418 | 419 | # update results... 420 | #update_match_counter( $cache ); 421 | 422 | return { 423 | cache => $cache, 424 | output => \@output, 425 | is_a_known_distro => $is_a_known_distro 426 | }; 427 | } 428 | 429 | sub update_match_counter($cache) { # dead 430 | 431 | my ( $count_distro, $count_files ) = ( 0, 0 ); 432 | foreach my $distro ( sort keys %{ $cache->{distros} } ) { 433 | my $c 434 | = eval { scalar @{ $cache->{distros}->{$distro}->{matches} } } 435 | // 0; 436 | next unless $c; 437 | ++$count_distro; 438 | $count_files += $c; 439 | } 440 | 441 | $cache->{match} = { 442 | files => $count_files, 443 | distros => $count_distro 444 | }; 445 | 446 | return; 447 | } 448 | 449 | sub current_version($self) { 450 | my $now = time(); 451 | my $cache_ttl = 600; # 10 minutes in seconds 452 | 453 | # Check if we need to refresh the cache 454 | if ( !exists $self->{__version__} 455 | || !exists $self->{__version_timestamp__} 456 | || ( $now - $self->{__version_timestamp__} ) > $cache_ttl ) 457 | { 458 | 459 | $self->{__version__} = join( 460 | '-', 461 | $grepcpan::VERSION, 462 | 'cache' => $self->config()->{'cache'}->{'version'}, 463 | 'cpan' => 464 | eval { scalar $self->git->run(qw{rev-parse --short HEAD}) } 465 | // '', 466 | ); 467 | 468 | $self->{__version_timestamp__} = $now; 469 | } 470 | 471 | return $self->{__version__}; 472 | } 473 | 474 | sub get_list_of_files_to_search( $self, $cache, $search, $page, $distro, 475 | $search_file, $filetype ) 476 | { 477 | 478 | # try to get one file per distro except if we do not have enough distros matching 479 | # maybe sort the files by distros having the most matches ?? 480 | 481 | my @flat_list; # full flat list before pagination 482 | 483 | # if we have enough distros 484 | my $limit = $self->distros_per_page; 485 | if ( defined $distro && exists $cache->{distros}->{$distro} ) { 486 | 487 | # let's pick all the files for this distro: as we are looking for it 488 | return [] unless exists $cache->{distros}->{$distro}; 489 | my $prefix = $cache->{distros}->{$distro}->{prefix}; 490 | @flat_list = map { $prefix . '/' . $_ } 491 | @{ $cache->{distros}->{$distro}->{files} }; # all the files 492 | if ( defined $search_file ) { 493 | @flat_list = grep { $_ eq $prefix . '/' . $search_file } 494 | @flat_list; # make sure the file is known and sanitize 495 | } 496 | } 497 | else { # pick one single file per distro 498 | @flat_list = map { 499 | my $distro = $_; # warning this is over riding the input variable 500 | my $prefix = $cache->{distros}->{$distro}->{prefix}; 501 | my $list_of_files = $cache->{distros}->{$distro}->{files}; 502 | my $candidate = $list_of_files->[0]; # only the first file 503 | if ( scalar @$list_of_files > 1 ) { 504 | 505 | # try to find a more perlish file first 506 | foreach my $f (@$list_of_files) { 507 | if ( $f =~ qr{\.p[lm]$} ) { 508 | $candidate = $f; 509 | last; 510 | } 511 | } 512 | } 513 | 514 | # use our best candidate ( and add our prefix ) 515 | $prefix . '/' . $candidate; 516 | } 517 | grep { 518 | my $key = $_; 519 | my $keep = 1; 520 | 521 | # check if there is a distro filter and apply it 522 | if ( defined $distro && length $distro ) { 523 | $keep = $key =~ qr{$distro}i ? 1 : 0; 524 | } 525 | $keep; 526 | } 527 | sort keys %{ $cache->{distros} }; 528 | } 529 | 530 | # now do the pagination 531 | # page 0: from 0 to limit - 1 532 | # page 1: from limit to 2 * limit - 1 533 | # page 2: from 2*limit to 3 * limit - 1 534 | 535 | my @short; 536 | my $offset = $page * $limit; 537 | if ( $offset <= scalar @flat_list ) { # offset protection 538 | @short = splice( @flat_list, $page * $limit, $limit ); 539 | } 540 | 541 | return \@short; 542 | } 543 | 544 | sub _save_cache ( $self, $cache_file, $cache ) { 545 | 546 | # cache is disabled 547 | return if $self->config()->{nocache}; 548 | 549 | Sereal::write_sereal( $cache_file, $cache ); 550 | 551 | my $raw_cache_file = $cache_file . '.raw'; 552 | unlink($raw_cache_file) if -e $raw_cache_file; 553 | 554 | return; 555 | } 556 | 557 | sub _get_cache_file ( $self, $keys, $type = undef ) { 558 | 559 | $type //= q[search-ls]; 560 | $type .= '-'; 561 | 562 | my $cache_file 563 | = ( $self->cache() // '' ) . '/' 564 | . $type 565 | . md5_hex( join( q{|}, map { defined $_ ? $_ : '' } @$keys ) ) 566 | . '.cache'; 567 | 568 | return $cache_file; 569 | } 570 | 571 | sub _load_cache ( $self, $cache_file ) { 572 | 573 | return unless CACHE_IS_ENABLED; 574 | 575 | # cache is disabled 576 | return if $self->config()->{nocache}; 577 | 578 | return unless defined $cache_file && -e $cache_file; 579 | return Sereal::read_sereal($cache_file); 580 | } 581 | 582 | sub _parse_and_check_query_filetype ( $self, $query_filetype, $adjusted_request={} ) { 583 | 584 | return unless length $query_filetype; 585 | 586 | my $rules = $self->_parse_query_filetype($query_filetype); 587 | 588 | my $r = $rules // []; 589 | my $value = join( ',', @$r ); 590 | $query_filetype =~ s{\s+}{}g; 591 | if ( $query_filetype ne $value ) { 592 | $adjusted_request->{'qft'} = { 593 | error => "Incorrect search filter: invalid characters - $query_filetype", 594 | value => $value, 595 | } 596 | } 597 | 598 | return $rules; 599 | } 600 | 601 | sub _parse_query_filetype ( $self, $query_filetype ) { 602 | 603 | return unless defined $query_filetype; 604 | return unless length $query_filetype; 605 | 606 | my @filetypes = split( /\s*,\s*/, $query_filetype ); 607 | @filetypes 608 | = grep { length($_) && m{^ [a-zA-Z0-9_\-\.\*]+ $}x } @filetypes; 609 | 610 | # ignore rules using '..' 611 | return if grep {m{\.\.}} @filetypes; 612 | 613 | return \@filetypes; 614 | } 615 | 616 | sub _parse_and_check_ignore_files ( $self, $ignore_files, $adjusted_request={} ) { 617 | 618 | return unless length $ignore_files; 619 | 620 | my $rules = $self->_parse_ignore_files($ignore_files); 621 | 622 | if ( ! $rules ) { 623 | $adjusted_request->{'qifl'} = { 624 | error => "Incorrect ignore files: invalid characters.", 625 | value => $ignore_files, # not updated 626 | } 627 | } 628 | 629 | return $rules; 630 | } 631 | 632 | 633 | # convert a string of patterns (file to exclude) to a list of git rules to ignore the path 634 | # t/*, *.md, *.json, *.yaml, *.yml, *.conf, cpanfile, LICENSE, MANIFEST, INSTALL, Changes, Makefile.PL, Build.PL, Copying, *.SKIP, *.ini, README 635 | sub _parse_ignore_files ( $self, $ignore_files ) { 636 | 637 | return unless length $ignore_files; 638 | 639 | my @ignorelist = grep { length($_) && m{^ [a-zA-Z0-9_\-\.\*/]+ $}x } 640 | split( /\s*,\s*/, $ignore_files ); 641 | 642 | # ignore rules using '..' 643 | return if grep {m{\.\.}} @ignorelist; 644 | 645 | return unless scalar @ignorelist; 646 | 647 | my @rules; 648 | foreach my $ignore (@ignorelist) { 649 | $ignore = '/*' . $ignore unless $ignore =~ m{^\*}; 650 | push @rules, qq[:!$ignore]; 651 | } 652 | 653 | return \@rules; 654 | } 655 | 656 | sub _get_match_cache( 657 | $self, $search, $search_distro, $query_filetype, 658 | $caseinsensitive = 0, 659 | $ignore_files = undef 660 | ) 661 | { 662 | 663 | $caseinsensitive //= 0; 664 | 665 | my $gitdir = $self->git()->work_tree; 666 | my $limit = $self->config()->{limit}->{files_per_search} or die; 667 | 668 | my $flavor = _get_git_grep_flavor($search); 669 | my @git_cmd = qw{grep -l}; 670 | push @git_cmd, q{-i} if $caseinsensitive; 671 | push @git_cmd, $flavor, '-e', $search, q{--}, q{distros/}; 672 | 673 | my @keys_for_cache = ( 674 | $flavor, $caseinsensitive ? 1 : 0, 675 | $search, $search_distro, $query_filetype, 676 | $caseinsensitive, $ignore_files // '' 677 | ); 678 | 679 | # use the full cache when available -- need to filter it later 680 | my $request_cache_file = $self->_get_cache_file( \@keys_for_cache ); 681 | if ( my $load = $self->_load_cache($request_cache_file) ) { 682 | return $load if $load; 683 | } 684 | 685 | my $adjusted_request = {}; 686 | 687 | $search_distro =~ s{::+}{-}g if defined $search_distro; 688 | 689 | # the distro can either come from url or the query with some glob 690 | if ( defined $search_distro 691 | && length($search_distro) 692 | && $search_distro =~ qr{^([0-9a-zA-Z_\*])[0-9a-zA-Z_\*\-]*$} ) 693 | { 694 | # replace the disros search 695 | $git_cmd[-1] 696 | = q{distros/} 697 | . $1 . '/' 698 | . $search_distro 699 | . '/*'; # add a / to do not match some other distro 700 | } 701 | 702 | # filter on some type files distro + query filetype 703 | if ( my $rules = $self->_parse_and_check_query_filetype($query_filetype, $adjusted_request) ) { 704 | my $base_search = $git_cmd[-1]; 705 | my $is_first_rule = 1; 706 | foreach my $rule (@$rules) { 707 | 708 | my $search = $base_search . '*' . $rule; 709 | 710 | if ($is_first_rule) { 711 | $git_cmd[-1] = $search; 712 | $is_first_rule = 0; 713 | next; 714 | } 715 | 716 | push @git_cmd, $search; 717 | } 718 | } 719 | 720 | if ( my $rules = $self->_parse_and_check_ignore_files($ignore_files, $adjusted_request) ) { 721 | push @git_cmd, $rules->@*; 722 | } 723 | 724 | # fallback to a shorter search ( and a different cache ) 725 | my $cache_file = $self->_get_cache_file( [@git_cmd] ); 726 | if ( my $load = $self->_load_cache($cache_file) ) { 727 | return $load if $load; 728 | } 729 | 730 | my $raw_cache_file = $cache_file . q{.raw}; 731 | 732 | my $raw_limit = $self->config()->{limit}->{files_git_run_bg}; 733 | 734 | my $list_files = $self->run_git_cmd_limit( 735 | cache_file => $raw_cache_file, 736 | cmd => [@git_cmd], # git command 737 | limit => $limit, 738 | limit_bg_process => $raw_limit, #files_git_run_bg 739 | #pre_run => sub { chdir($gitdir) } 740 | ); 741 | 742 | # remove the final marker if there 743 | my $search_in_progress = 1; 744 | 745 | #say "LAST LINE .... " . $list_files->[-1]; 746 | #say " check ? ", $list_files->[-1] eq END_OF_FILE_MARKER() ? 1 : 0; 747 | if ( scalar @$list_files && $list_files->[-1] eq END_OF_FILE_MARKER() ) { 748 | pop @$list_files; 749 | $search_in_progress = 0; 750 | } 751 | 752 | my $cache = { 753 | distros => {}, 754 | search => $search, 755 | search_in_progress => $search_in_progress 756 | }; 757 | my $match_files = scalar @$list_files; 758 | $cache->{is_incomplete} = 1 if $match_files >= $raw_limit; 759 | 760 | my $last_distro; 761 | foreach my $line (@$list_files) { 762 | my ( $where, $distro, $shortpath ) = massage_filepath($line); 763 | next unless defined $shortpath; 764 | $last_distro = $distro; 765 | my $prefix = join '/', $where, $distro; 766 | $cache->{distros}->{$distro} //= { files => [], prefix => $prefix }; 767 | push @{ $cache->{distros}->{$distro}->{files} }, $shortpath; 768 | } 769 | 770 | if ( $cache->{is_incomplete} ) 771 | { # flag the last distro as potentially incomplete 772 | $cache->{distros}->{$last_distro}->{'is_incomplete'} = 1; 773 | } 774 | 775 | $cache->{match} = { 776 | files => $match_files, 777 | distros => scalar keys $cache->{distros}->%*, 778 | }; 779 | $cache->{adjusted_request} = $adjusted_request; 780 | 781 | if ( !$search_in_progress ) { 782 | 783 | #say "Search in progress..... done caching yaml file"; 784 | $self->_save_cache( $request_cache_file, $cache ); 785 | $self->_save_cache( $cache_file, $cache ); 786 | unlink $raw_cache_file if -e $raw_cache_file; 787 | } 788 | 789 | return $cache; 790 | } 791 | 792 | sub massage_filepath ($line) { 793 | my ( $where, $letter, $distro, $shortpath ) = split( q{/}, $line, 4 ); 794 | $where //= ''; 795 | $letter //= ''; 796 | $where .= '/' . $letter; 797 | return ( $where, $distro, $shortpath ); 798 | } 799 | 800 | sub run_git_cmd_limit ( $self, %opts ) { 801 | 802 | my $cache_file = $opts{cache_file}; 803 | my $cmd = $opts{cmd} // die; 804 | ref $cmd eq 'ARRAY' or die "cmd should be an ARRAY ref"; 805 | my $limit = $opts{limit} || 10; 806 | my $limit_bg_process = $opts{limit_bg_process} || $limit; 807 | 808 | my @lines; 809 | 810 | if ( $cache_file && -e $cache_file && !$self->config()->{nocache} ) { 811 | 812 | # check if the file is empty and has more than X seconds 813 | 814 | while ( waitpid( -1, WNOHANG ) > 0 ) { 815 | 1; 816 | }; # catch any zombies we could have from previous run 817 | 818 | if ( -z $cache_file ) { # the file is empty 819 | my ( $mtime, $ctime ) = ( stat($cache_file) )[ 9, 10 ]; 820 | $mtime //= 0; 821 | $ctime //= 0; 822 | 823 | # return an empty cache if the file exists and is empty... 824 | return [] if ( time() - $mtime < 60 * 30 ); 825 | 826 | # give it a second try after some time... 827 | } 828 | else { 829 | # return the content of our current cache from previous run 830 | #say "use our cache from previous run"; 831 | my @from_cache = File::Slurp::read_file($cache_file); 832 | chomp @from_cache; 833 | return \@from_cache; 834 | } 835 | } 836 | 837 | local $| = 1; 838 | local $SIG{'USR1'} = sub {exit}; # avoid a race condition and exit cleanly 839 | 840 | #my $child_pid = open( my $from_kid, "-|" ) // die "Can't fork: $!"; 841 | 842 | local $SIG{'CHLD'} = 'DEFAULT'; 843 | 844 | my ( $from_kid, $CW ) = ( IO::Handle->new(), IO::Handle->new() ); 845 | pipe( $from_kid, $CW ) or die "Fail to pipe $!"; 846 | $CW->autoflush(1); 847 | 848 | my $child_pid = fork(); 849 | die "Fork failed" unless defined $child_pid; 850 | 851 | local $SIG{'ALRM'} = sub { die "Alarm signal triggered - $$" }; 852 | 853 | if ($child_pid) { # parent process 854 | my $c = 1; 855 | alarm( $self->config->{timeout}->{user_search} ); 856 | eval { 857 | while ( my $line = readline($from_kid) ) { 858 | chomp $line; 859 | if ( $c == 1 && $line eq TOO_BUSY_MARKER() ) { 860 | return []; 861 | } 862 | push @lines, $line; 863 | last if ++$c > $limit; 864 | 865 | #say "GOT: $line ", $line eq END_OF_FILE_MARKER() ? 1 : 0; 866 | last if $line eq END_OF_FILE_MARKER(); 867 | } 868 | alarm(0); 869 | 1; 870 | }; # or warn $@; 871 | close($from_kid); 872 | kill 'USR1' => $child_pid; 873 | while ( waitpid( -1, WNOHANG ) > 0 ) { 874 | 1; 875 | }; # catch what we can at this step... the process is running in bg 876 | } 877 | else { 878 | # in kid process 879 | local $| = 1; 880 | my $current_pid = $$; 881 | my $can_write_to_pipe = 1; 882 | local $SIG{'USR1'} = sub { # not really used anymore 883 | #warn "SIGUSR1.... start"; 884 | $can_write_to_pipe = 0; 885 | close($CW); 886 | open STDIN, '>', '/dev/null'; 887 | open STDOUT, '>', '/dev/null'; 888 | open STDERR, '>', '/dev/null'; 889 | setsid(); 890 | 891 | return; 892 | }; 893 | 894 | #kill 'USR1' => $$; # >>>> 895 | my $run; 896 | 897 | local $SIG{'ALRM'} = sub { 898 | warn "alarm triggered while running git command"; 899 | 900 | if ( ref $run ) { 901 | my $pid; 902 | local $@; 903 | $pid = eval { $run->pid }; 904 | if ($pid) { 905 | warn "killing 'git' process $pid..."; 906 | if ( kill( 0, $pid ) ) { 907 | sleep 2; 908 | kill( 9, $pid ); 909 | } 910 | } 911 | } 912 | 913 | die 914 | "alarm triggered while running git command: git grep too long..."; 915 | }; 916 | 917 | # limit our search in time... 918 | alarm( $self->config->{timeout}->{grep_search} // 600 ) 919 | ; # make sure we always have a value set 920 | $opts{pre_run}->() if ref $opts{pre_run} eq 'CODE'; 921 | 922 | my $lock = $self->check_if_a_worker_is_available(); 923 | if ( !$lock ) { 924 | print {$CW} TOO_BUSY_MARKER() . "\n"; 925 | exit 42; 926 | } 927 | 928 | say "Running in kid command: " . join( ' ', 'git', @$cmd ); 929 | say "KID is caching to file ", $cache_file; 930 | 931 | my $to_cache; 932 | 933 | if ($cache_file) { 934 | $to_cache = IO::Handle->new; 935 | open( $to_cache, q{>}, $cache_file ) 936 | or die "Cannot open cache file: $!"; 937 | $to_cache->autoflush(1); 938 | } 939 | 940 | $run = $self->git->command(@$cmd); 941 | my $log = $run->stdout; 942 | my $counter = 1; 943 | 944 | while ( readline $log ) { 945 | print {$CW} $_ 946 | if $can_write_to_pipe; # return the line to our parent 947 | if ($cache_file) { 948 | print {$to_cache} $_ or die; # if file is removed 949 | } 950 | last if ++$counter > $limit_bg_process; 951 | } 952 | $run->close; 953 | print {$to_cache} 954 | qq{\n}; # in case of the last line did not had a newline 955 | print {$to_cache} END_OF_FILE_MARKER() . qq{\n} if $cache_file; 956 | print {$CW} END_OF_FILE_MARKER() . qq{\n} if $can_write_to_pipe; 957 | say "-- Request finished by kid: $counter lines - " 958 | . join( ' ', 'git', @$cmd ); 959 | exit $?; 960 | } 961 | 962 | return \@lines; 963 | } 964 | 965 | sub check_if_a_worker_is_available($self) { 966 | 967 | my $maxworkers = $self->config->{maxworkers} || 1; 968 | 969 | my $dir = $self->cache(); 970 | return unless -d $dir; 971 | 972 | foreach my $id ( 1 .. $maxworkers ) { 973 | my $f = $dir . '/worker-id-' . $id; 974 | open( my $fh, '>', $f ) or next; 975 | if ( flock( $fh, LOCK_EX | LOCK_NB ) ) { 976 | seek( $fh, 0, SEEK_END ); 977 | print {$fh} "$$\n"; 978 | return $fh; 979 | } 980 | } 981 | 982 | return; 983 | } 984 | 985 | 1; 986 | -------------------------------------------------------------------------------- /src/lib/GrepCpan/std.pm: -------------------------------------------------------------------------------- 1 | package GrepCpan::std; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | sub import { 7 | 8 | # auto import strict and warnings to our caller 9 | 10 | warnings->import(); 11 | strict->import(); 12 | 13 | require feature; 14 | feature->import( ':5.30', 'signatures' ); 15 | warnings->unimport('experimental::signatures'); 16 | 17 | return; 18 | } 19 | 20 | 1; 21 | -------------------------------------------------------------------------------- /src/lib/grepcpan.pm: -------------------------------------------------------------------------------- 1 | package grepcpan; # the dancer app 2 | 3 | # smoke one more time 4 | use Dancer2; 5 | use Dancer2::Serializer::JSON; 6 | use Encode; 7 | 8 | use GrepCpan::Grep (); 9 | 10 | use GrepCpan::std; 11 | 12 | use utf8; 13 | 14 | our $VERSION = '1.01'; 15 | 16 | my $Config = config()->{'grepcpan'}; 17 | 18 | # patch the LD_LIBRARY_PATH to load libpcre 19 | if ( $Config->{'ENV'} && $Config->{'ENV'}{'LD_LIBRARY_PATH'} ) { 20 | $ENV{'LD_LIBRARY_PATH'} = $Config->{'ENV'}{'LD_LIBRARY_PATH'}; 21 | } 22 | 23 | my $grep = GrepCpan::Grep->new( config => $Config ); 24 | $grep->cache(); # create and cleanup cache directory at startup 25 | 26 | my $COOKIE_LAST_SEARCH = $Config->{'cookie'}->{'history_name'} 27 | or die "missing cookie:history entry"; 28 | 29 | ### 30 | ### regular routes 31 | ### 32 | 33 | get '/' => \&home; 34 | 35 | get '/about' => sub { 36 | _set_cache_headers_for('aboutpage'); 37 | return template 'about' => 38 | { 'title' => 'About grep::metacpan', menu => 'about' }; 39 | }; 40 | 41 | get '/faq' => sub { 42 | _set_cache_headers_for('faqpage'); 43 | return template 'faq' => 44 | { 'title' => 'FAQs for grep::metacpan', menu => 'faq' }; 45 | }; 46 | 47 | get '/api' => sub { 48 | _set_cache_headers_for('apipage'); 49 | return template 'api' => 50 | { 'title' => 'APIs how to use grep::metacpan APIs', menu => 'api' }; 51 | }; 52 | 53 | get '/source-code' => sub { 54 | return template 'source-code' => { 55 | 'title' => 'Source code of grep::metacpan, list of git reposities', 56 | menu => 'gh' 57 | }; 58 | }; 59 | 60 | get '/search' => sub { 61 | my %i = ( # input 62 | q => param('q'), # search query 63 | qft => param('qft'), # filetype 64 | qd => param('qd'), # distro 65 | qls => param('qls'), # only list files 66 | qifl => param('qifl'), # ignore files 67 | ); 68 | 69 | my $qci = param('qci'); # case insensitive 70 | my $page = param('p') || 1; 71 | my $file = param('f'); 72 | 73 | my $query = $grep->do_search( 74 | search => $i{'q'}, 75 | page => $page - 1, 76 | search_distro => $i{'qd'}, # filter on a distribution 77 | search_file => $file, 78 | filetype => $i{'qft'}, 79 | caseinsensitive => $qci, 80 | list_files => $i{'qls'}, # not used for now, only impact the view 81 | ignore_files => $i{'qifl'}, 82 | ); 83 | 84 | my $nopagination = defined $file && length $file ? 1 : 0; 85 | my $show_sumup = !$query->{is_a_known_distro} 86 | ; #defined $distro && length $distro ? 0 : 1; 87 | 88 | my $template = $i{'qls'} ? 'list-files' : 'search'; 89 | 90 | my $alerts = {}; 91 | 92 | # check if some of the input parameters are invalid and updated 93 | if ( my $adjustments = $query->{adjusted_request} ) { 94 | foreach my $key ( keys $adjustments->%* ) { 95 | my $adjustment = $adjustments->{$key} // {}; 96 | if ( $adjustment->{error} ) { 97 | $alerts->{danger} //= ''; 98 | $alerts->{danger} .= $adjustment->{error}; 99 | } 100 | $i{$key} = $adjustment->{value} if defined $adjustment->{value}; 101 | } 102 | } 103 | 104 | return template $template => { 105 | search => $i{'q'}, 106 | search_distro => $i{'qd'}, 107 | query => $query, 108 | page => $page, 109 | last_searches => _update_history_cookie($i{'q'}), 110 | nopagination => $nopagination, 111 | show_sumup => $show_sumup, 112 | qft => $i{'qft'} // '', 113 | qd => $i{'qd'} // '', 114 | qls => $i{'qls'}, 115 | qci => $qci, 116 | qifl => $i{'qifl'}, 117 | alert => $alerts // {}, 118 | }; 119 | }; 120 | 121 | ### API routes 122 | get '/api/search' => sub { 123 | my $q = param('q'); 124 | my $filetype = param('qft'); 125 | my $qdistro = param('qd'); 126 | my $qci = param('qci'); # case insensitive 127 | my $page = param('p') || 1; 128 | my $file = param('f'); 129 | my $ignore_files = param('qifl'); 130 | 131 | my $query = $grep->do_search( 132 | search => $q, 133 | page => $page - 1, 134 | search_distro => $qdistro, # filter on a distribution 135 | filetype => $filetype, 136 | caseinsensitive => $qci, 137 | ignore_files => $ignore_files, 138 | ); 139 | 140 | content_type 'application/json'; 141 | return to_json $query; 142 | }; 143 | 144 | ### 145 | ### dummies helpers 146 | ### 147 | 148 | sub _update_history_cookie ($search) 149 | { # and return the human version list in all cases... 150 | 151 | my $separator = q{||}; 152 | 153 | my $value = Encode::decode( 'UTF-8', cookie($COOKIE_LAST_SEARCH) ); 154 | 155 | my @last_searches = split( qr{\Q$separator\E}, $value // '' ); 156 | 157 | if ( defined $search && length $search ) { 158 | $value =~ s{\Q$separator\E}{.}g if defined $value; # mmmm 159 | @last_searches = grep { $_ ne $search } 160 | @last_searches; # remove it from history if there 161 | unshift @last_searches, $search; # move it first 162 | @last_searches = splice( @last_searches, 0, 163 | $Config->{'cookie'}->{'history_size'} ); 164 | cookie 165 | $COOKIE_LAST_SEARCH => 166 | Encode::encode( 'UTF-8', join( $separator, @last_searches ) ), 167 | expires => "21 days"; 168 | } 169 | 170 | return \@last_searches; 171 | } 172 | 173 | sub home { 174 | 175 | _set_cache_headers_for('homepage'); 176 | 177 | template( 178 | 'index' => { 179 | 'title' => 'grepcpan', 180 | 'cpan_index_at' => $grep->cpan_index_at() 181 | } 182 | ); 183 | } 184 | 185 | sub _set_cache_headers_for($key) { 186 | 187 | # for browsers 188 | response_header( 'Cache-Control' => 'max-age=3600' ); 189 | 190 | # for CDN, reverse proxies & co 191 | response_header( 192 | 'Surrogate-Control' => 'max-age=3600, stale-while-revalidate=60' ); 193 | response_header( 'Surrogate-Key' => $key ); 194 | 195 | return; 196 | } 197 | 198 | true; 199 | -------------------------------------------------------------------------------- /src/public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Error 404 - grep.metacpan.org - this is the void there ! 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 38 |
39 |
40 | 41 |
42 | 43 | /!\ 44 | Error 404 45 |

Sorry this page does not exist !

46 |
47 | 48 | 49 | -------------------------------------------------------------------------------- /src/public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Error 500 - grep.metacpan.org Oh Yeah It Can Happen ! 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 38 |
39 |
40 | 41 |
42 | 43 | Error 500 44 | Error 500 45 |
46 | 47 | 48 | -------------------------------------------------------------------------------- /src/public/css/error.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: Lucida,sans-serif; 3 | } 4 | 5 | h1 { 6 | color: #AA0000; 7 | border-bottom: 1px solid #444; 8 | } 9 | 10 | h2 { color: #444; } 11 | 12 | pre { 13 | font-family: "lucida console","monaco","andale mono","bitstream vera sans mono","consolas",monospace; 14 | font-size: 12px; 15 | border-left: 2px solid #777; 16 | padding-left: 1em; 17 | } 18 | 19 | footer { 20 | font-size: 10px; 21 | } 22 | 23 | span.key { 24 | color: #449; 25 | font-weight: bold; 26 | width: 120px; 27 | display: inline; 28 | } 29 | 30 | span.value { 31 | color: #494; 32 | } 33 | 34 | /* these are for the message boxes */ 35 | 36 | pre.content { 37 | background-color: #eee; 38 | color: #000; 39 | padding: 1em; 40 | margin: 0; 41 | border: 1px solid #aaa; 42 | border-top: 0; 43 | margin-bottom: 1em; 44 | overflow-x: auto; 45 | } 46 | 47 | div.title { 48 | font-family: "lucida console","monaco","andale mono","bitstream vera sans mono","consolas",monospace; 49 | font-size: 12px; 50 | background-color: #aaa; 51 | color: #444; 52 | font-weight: bold; 53 | padding: 3px; 54 | padding-left: 10px; 55 | } 56 | 57 | table.context { 58 | border-spacing: 0; 59 | } 60 | 61 | table.context th, table.context td { 62 | padding: 0; 63 | } 64 | 65 | table.context th { 66 | color: #889; 67 | font-weight: normal; 68 | padding-right: 15px; 69 | text-align: right; 70 | } 71 | 72 | .errline { 73 | color: red; 74 | } 75 | 76 | pre.error { 77 | background: #334; 78 | color: #ccd; 79 | padding: 1em; 80 | border-top: 1px solid #000; 81 | border-left: 1px solid #000; 82 | border-right: 1px solid #eee; 83 | border-bottom: 1px solid #eee; 84 | } 85 | 86 | -------------------------------------------------------------------------------- /src/public/css/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | margin-bottom: 25px; 4 | padding: 0; 5 | background-color: #ddd; 6 | background-image: url("/images/perldancer-bg.jpg"); 7 | background-repeat: no-repeat; 8 | background-position: top left; 9 | 10 | font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana"; 11 | font-size: 13px; 12 | color: #333; 13 | } 14 | 15 | h1 { 16 | font-size: 28px; 17 | color: #000; 18 | } 19 | 20 | a {color: #03c} 21 | a:hover { 22 | background-color: #03c; 23 | color: white; 24 | text-decoration: none; 25 | } 26 | 27 | #page { 28 | background-color: #ddd; 29 | width: 750px; 30 | margin: auto; 31 | margin-left: auto; 32 | padding-left: 0px; 33 | margin-right: auto; 34 | } 35 | 36 | #content { 37 | background-color: white; 38 | border: 3px solid #aaa; 39 | border-top: none; 40 | padding: 25px; 41 | width: 500px; 42 | } 43 | 44 | #sidebar { 45 | float: right; 46 | width: 175px; 47 | } 48 | 49 | #header, #about, #getting-started { 50 | padding-left: 75px; 51 | padding-right: 30px; 52 | } 53 | 54 | 55 | #header { 56 | background-image: url("/images/perldancer.jpg"); 57 | background-repeat: no-repeat; 58 | background-position: top left; 59 | height: 64px; 60 | } 61 | #header h1, #header h2 {margin: 0} 62 | #header h2 { 63 | color: #888; 64 | font-weight: normal; 65 | font-size: 16px; 66 | } 67 | 68 | #about h3 { 69 | margin: 0; 70 | margin-bottom: 10px; 71 | font-size: 14px; 72 | } 73 | 74 | #about-content { 75 | background-color: #ffd; 76 | border: 1px solid #fc0; 77 | margin-left: -11px; 78 | } 79 | #about-content table { 80 | margin-top: 10px; 81 | margin-bottom: 10px; 82 | font-size: 11px; 83 | border-collapse: collapse; 84 | } 85 | #about-content td { 86 | padding: 10px; 87 | padding-top: 3px; 88 | padding-bottom: 3px; 89 | } 90 | #about-content td.name {color: #555} 91 | #about-content td.value {color: #000} 92 | 93 | #about-content.failure { 94 | background-color: #fcc; 95 | border: 1px solid #f00; 96 | } 97 | #about-content.failure p { 98 | margin: 0; 99 | padding: 10px; 100 | } 101 | 102 | #getting-started { 103 | border-top: 1px solid #ccc; 104 | margin-top: 25px; 105 | padding-top: 15px; 106 | } 107 | #getting-started h1 { 108 | margin: 0; 109 | font-size: 20px; 110 | } 111 | #getting-started h2 { 112 | margin: 0; 113 | font-size: 14px; 114 | font-weight: normal; 115 | color: #333; 116 | margin-bottom: 25px; 117 | } 118 | #getting-started ol { 119 | margin-left: 0; 120 | padding-left: 0; 121 | } 122 | #getting-started li { 123 | font-size: 18px; 124 | color: #888; 125 | margin-bottom: 25px; 126 | } 127 | #getting-started li h2 { 128 | margin: 0; 129 | font-weight: normal; 130 | font-size: 18px; 131 | color: #333; 132 | } 133 | #getting-started li p { 134 | color: #555; 135 | font-size: 13px; 136 | } 137 | 138 | #search { 139 | margin: 0; 140 | padding-top: 10px; 141 | padding-bottom: 10px; 142 | font-size: 11px; 143 | } 144 | #search input { 145 | font-size: 11px; 146 | margin: 2px; 147 | } 148 | #search-text {width: 170px} 149 | 150 | #sidebar ul { 151 | margin-left: 0; 152 | padding-left: 0; 153 | } 154 | #sidebar ul h3 { 155 | margin-top: 25px; 156 | font-size: 16px; 157 | padding-bottom: 10px; 158 | border-bottom: 1px solid #ccc; 159 | } 160 | #sidebar li { 161 | list-style-type: none; 162 | } 163 | #sidebar ul.links li { 164 | margin-bottom: 5px; 165 | } 166 | 167 | h1, h2, h3, h4, h5 { 168 | font-family: sans-serif; 169 | margin: 1.2em 0 0.6em 0; 170 | } 171 | 172 | p { 173 | line-height: 1.5em; 174 | margin: 1.6em 0; 175 | } 176 | 177 | code, .filepath, .app-info { 178 | font-family: 'Andale Mono', Monaco, 'Liberation Mono', 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', monospace; 179 | } 180 | 181 | #footer { 182 | clear: both; 183 | padding-top: 2em; 184 | text-align: center; 185 | padding-right: 160px; 186 | font-family: sans-serif; 187 | font-size: 10px; 188 | } 189 | 190 | .alert { 191 | display: inline-block; 192 | padding: 5px 2em; 193 | border-radius: 7px; 194 | } 195 | 196 | .alert-info { 197 | color: #4083a3; 198 | background-color: #d9edf7; 199 | border-color: #4083a3; 200 | } 201 | 202 | /* Form styles */ 203 | .form-section { 204 | width: 100%; 205 | max-width: 600px; 206 | margin: 0 auto; 207 | padding: 1rem; 208 | box-sizing: border-box; 209 | } 210 | 211 | .form-row { 212 | display: flex; 213 | flex-direction: row; 214 | align-items: center; 215 | margin-bottom: 1rem; 216 | gap: 1rem; 217 | width: 100%; 218 | } 219 | 220 | .form-row label { 221 | flex: 0 0 150px; 222 | text-align: right; 223 | } 224 | 225 | .form-row input[type="text"] { 226 | flex: 1; 227 | min-width: 0; 228 | padding: 0.5rem; 229 | border: 1px solid #ccc; 230 | border-radius: 4px; 231 | width: 100%; 232 | box-sizing: border-box; 233 | } 234 | 235 | .home-search-input, 236 | .home-search-distro-input { 237 | width: 100% !important; 238 | box-sizing: border-box; 239 | margin: 0; 240 | } 241 | 242 | .search-btn { 243 | background-color: #03c; 244 | color: white; 245 | padding: 0.75rem 1.5rem; 246 | border: none; 247 | border-radius: 4px; 248 | cursor: pointer; 249 | font-size: 1rem; 250 | } 251 | 252 | .search-btn:hover { 253 | background-color: #02a; 254 | } 255 | 256 | .checkbox-container { 257 | display: flex; 258 | align-items: center; 259 | gap: 0.5rem; 260 | } 261 | 262 | /* Mobile responsive styles */ 263 | @media screen and (max-width: 768px) { 264 | .form-row { 265 | flex-direction: column; 266 | align-items: stretch; 267 | gap: 0.5rem; 268 | width: 100%; 269 | margin: 0 0 1rem 0; 270 | } 271 | 272 | .form-row label { 273 | flex: none; 274 | text-align: left; 275 | margin-bottom: 0.25rem; 276 | width: 100%; 277 | } 278 | 279 | .form-row input[type="text"] { 280 | width: 100%; 281 | margin: 0; 282 | } 283 | 284 | .form-section { 285 | padding: 0.5rem; 286 | width: 100%; 287 | } 288 | 289 | .search-btn { 290 | width: 100%; 291 | } 292 | 293 | .alert { 294 | margin: 0.5rem; 295 | padding: 0.75rem 1rem; 296 | } 297 | 298 | .checkbox-container { 299 | margin-left: 0; 300 | width: 100%; 301 | } 302 | 303 | body { 304 | background-size: contain; 305 | } 306 | } 307 | 308 | /* Small mobile devices */ 309 | @media screen and (max-width: 480px) { 310 | body { 311 | font-size: 14px; 312 | } 313 | 314 | .form-section { 315 | padding: 0.25rem; 316 | } 317 | 318 | .form-row input[type="text"] { 319 | padding: 0.75rem; 320 | } 321 | } 322 | -------------------------------------------------------------------------------- /src/public/dispatch.cgi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | BEGIN { $ENV{DANCER_APPHANDLER} = 'PSGI';} 3 | use Dancer2; 4 | use FindBin '$RealBin'; 5 | use Plack::Runner; 6 | 7 | # For some reason Apache SetEnv directives don't propagate 8 | # correctly to the dispatchers, so forcing PSGI and env here 9 | # is safer. 10 | set apphandler => 'PSGI'; 11 | set environment => 'production'; 12 | 13 | my $psgi = path($RealBin, '..', 'bin', 'app.psgi'); 14 | die "Unable to read startup script: $psgi" unless -r $psgi; 15 | 16 | Plack::Runner->run($psgi); 17 | -------------------------------------------------------------------------------- /src/public/dispatch.fcgi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | BEGIN { $ENV{DANCER_APPHANDLER} = 'PSGI';} 3 | use Dancer2; 4 | use FindBin '$RealBin'; 5 | use Plack::Handler::FCGI; 6 | 7 | # For some reason Apache SetEnv directives don't propagate 8 | # correctly to the dispatchers, so forcing PSGI and env here 9 | # is safer. 10 | set apphandler => 'PSGI'; 11 | set environment => 'production'; 12 | 13 | my $psgi = path($RealBin, '..', 'bin', 'app.psgi'); 14 | my $app = do($psgi); 15 | die "Unable to read startup script: $@" if $@; 16 | my $server = Plack::Handler::FCGI->new(nproc => 5, detach => 1); 17 | 18 | $server->run($app); 19 | -------------------------------------------------------------------------------- /src/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metacpan/metacpan-grep-front-end/a5f6e6a852fd52203da5345c279b39a5b6ec9ae0/src/public/favicon.ico -------------------------------------------------------------------------------- /src/public/images/grepcpan-logo.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metacpan/metacpan-grep-front-end/a5f6e6a852fd52203da5345c279b39a5b6ec9ae0/src/public/images/grepcpan-logo.pxm -------------------------------------------------------------------------------- /src/public/images/metacpan-logo@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metacpan/metacpan-grep-front-end/a5f6e6a852fd52203da5345c279b39a5b6ec9ae0/src/public/images/metacpan-logo@2x.png -------------------------------------------------------------------------------- /src/public/images/perldancer-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metacpan/metacpan-grep-front-end/a5f6e6a852fd52203da5345c279b39a5b6ec9ae0/src/public/images/perldancer-bg.jpg -------------------------------------------------------------------------------- /src/public/images/perldancer.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metacpan/metacpan-grep-front-end/a5f6e6a852fd52203da5345c279b39a5b6ec9ae0/src/public/images/perldancer.jpg -------------------------------------------------------------------------------- /src/public/javascripts/mousetrap.min.js: -------------------------------------------------------------------------------- 1 | /* mousetrap v1.6.5 craig.is/killing/mice */ 2 | (function(q,u,c){function v(a,b,g){a.addEventListener?a.addEventListener(b,g,!1):a.attachEvent("on"+b,g)}function z(a){if("keypress"==a.type){var b=String.fromCharCode(a.which);a.shiftKey||(b=b.toLowerCase());return b}return n[a.which]?n[a.which]:r[a.which]?r[a.which]:String.fromCharCode(a.which).toLowerCase()}function F(a){var b=[];a.shiftKey&&b.push("shift");a.altKey&&b.push("alt");a.ctrlKey&&b.push("ctrl");a.metaKey&&b.push("meta");return b}function w(a){return"shift"==a||"ctrl"==a||"alt"==a|| 3 | "meta"==a}function A(a,b){var g,d=[];var e=a;"+"===e?e=["+"]:(e=e.replace(/\+{2}/g,"+plus"),e=e.split("+"));for(g=0;gc||n.hasOwnProperty(c)&&(p[n[c]]=c)}g=p[e]?"keydown":"keypress"}"keypress"==g&&d.length&&(g="keydown");return{key:m,modifiers:d,action:g}}function D(a,b){return null===a||a===u?!1:a===b?!0:D(a.parentNode,b)}function d(a){function b(a){a= 4 | a||{};var b=!1,l;for(l in p)a[l]?b=!0:p[l]=0;b||(x=!1)}function g(a,b,t,f,g,d){var l,E=[],h=t.type;if(!k._callbacks[a])return[];"keyup"==h&&w(a)&&(b=[a]);for(l=0;l":".","?":"/","|":"\\"},B={option:"alt",command:"meta","return":"enter", 9 | escape:"esc",plus:"+",mod:/Mac|iPod|iPhone|iPad/.test(navigator.platform)?"meta":"ctrl"},p;for(c=1;20>c;++c)n[111+c]="f"+c;for(c=0;9>=c;++c)n[c+96]=c.toString();d.prototype.bind=function(a,b,c){a=a instanceof Array?a:[a];this._bindMultiple.call(this,a,b,c);return this};d.prototype.unbind=function(a,b){return this.bind.call(this,a,function(){},b)};d.prototype.trigger=function(a,b){if(this._directMap[a+":"+b])this._directMap[a+":"+b]({},a);return this};d.prototype.reset=function(){this._callbacks={}; 10 | this._directMap={};return this};d.prototype.stopCallback=function(a,b){if(-1<(" "+b.className+" ").indexOf(" mousetrap ")||D(b,this.target))return!1;if("composedPath"in a&&"function"===typeof a.composedPath){var c=a.composedPath()[0];c!==a.target&&(b=c)}return"INPUT"==b.tagName||"SELECT"==b.tagName||"TEXTAREA"==b.tagName||b.isContentEditable};d.prototype.handleKey=function(){return this._handleKey.apply(this,arguments)};d.addKeycodes=function(a){for(var b in a)a.hasOwnProperty(b)&&(n[b]=a[b]);p=null}; 11 | d.init=function(){var a=d(u),b;for(b in a)"_"!==b.charAt(0)&&(d[b]=function(b){return function(){return a[b].apply(a,arguments)}}(b))};d.init();q.Mousetrap=d;"undefined"!==typeof module&&module.exports&&(module.exports=d);"function"===typeof define&&define.amd&&define(function(){return d})}})("undefined"!==typeof window?window:null,"undefined"!==typeof window?document:null); 12 | -------------------------------------------------------------------------------- /src/public/static/css/font-awesome.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Font Awesome 4.7.0 by @davegandy - http://fontawesome.io - @fontawesome 3 | * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) 4 | */@font-face{font-family:'FontAwesome';src:url('../fonts/fontawesome-webfont.eot?v=4.7.0');src:url('../fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'),url('../fonts/fontawesome-webfont.woff2?v=4.7.0') format('woff2'),url('../fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'),url('../fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype'),url('../fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');font-weight:normal;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.fa-lg{font-size:1.33333333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.28571429em;text-align:center}.fa-ul{padding-left:0;margin-left:2.14285714em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.14285714em;width:2.14285714em;top:.14285714em;text-align:center}.fa-li.fa-lg{left:-1.85714286em}.fa-border{padding:.2em .25em .15em;border:solid .08em #eee;border-radius:.1em}.fa-pull-left{float:left}.fa-pull-right{float:right}.fa.fa-pull-left{margin-right:.3em}.fa.fa-pull-right{margin-left:.3em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left{margin-right:.3em}.fa.pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=1)";-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2)";-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=3)";-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)";-webkit-transform:scale(-1, 1);-ms-transform:scale(-1, 1);transform:scale(-1, 1)}.fa-flip-vertical{-ms-filter:"progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)";-webkit-transform:scale(1, -1);-ms-transform:scale(1, -1);transform:scale(1, -1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:"\f000"}.fa-music:before{content:"\f001"}.fa-search:before{content:"\f002"}.fa-envelope-o:before{content:"\f003"}.fa-heart:before{content:"\f004"}.fa-star:before{content:"\f005"}.fa-star-o:before{content:"\f006"}.fa-user:before{content:"\f007"}.fa-film:before{content:"\f008"}.fa-th-large:before{content:"\f009"}.fa-th:before{content:"\f00a"}.fa-th-list:before{content:"\f00b"}.fa-check:before{content:"\f00c"}.fa-remove:before,.fa-close:before,.fa-times:before{content:"\f00d"}.fa-search-plus:before{content:"\f00e"}.fa-search-minus:before{content:"\f010"}.fa-power-off:before{content:"\f011"}.fa-signal:before{content:"\f012"}.fa-gear:before,.fa-cog:before{content:"\f013"}.fa-trash-o:before{content:"\f014"}.fa-home:before{content:"\f015"}.fa-file-o:before{content:"\f016"}.fa-clock-o:before{content:"\f017"}.fa-road:before{content:"\f018"}.fa-download:before{content:"\f019"}.fa-arrow-circle-o-down:before{content:"\f01a"}.fa-arrow-circle-o-up:before{content:"\f01b"}.fa-inbox:before{content:"\f01c"}.fa-play-circle-o:before{content:"\f01d"}.fa-rotate-right:before,.fa-repeat:before{content:"\f01e"}.fa-refresh:before{content:"\f021"}.fa-list-alt:before{content:"\f022"}.fa-lock:before{content:"\f023"}.fa-flag:before{content:"\f024"}.fa-headphones:before{content:"\f025"}.fa-volume-off:before{content:"\f026"}.fa-volume-down:before{content:"\f027"}.fa-volume-up:before{content:"\f028"}.fa-qrcode:before{content:"\f029"}.fa-barcode:before{content:"\f02a"}.fa-tag:before{content:"\f02b"}.fa-tags:before{content:"\f02c"}.fa-book:before{content:"\f02d"}.fa-bookmark:before{content:"\f02e"}.fa-print:before{content:"\f02f"}.fa-camera:before{content:"\f030"}.fa-font:before{content:"\f031"}.fa-bold:before{content:"\f032"}.fa-italic:before{content:"\f033"}.fa-text-height:before{content:"\f034"}.fa-text-width:before{content:"\f035"}.fa-align-left:before{content:"\f036"}.fa-align-center:before{content:"\f037"}.fa-align-right:before{content:"\f038"}.fa-align-justify:before{content:"\f039"}.fa-list:before{content:"\f03a"}.fa-dedent:before,.fa-outdent:before{content:"\f03b"}.fa-indent:before{content:"\f03c"}.fa-video-camera:before{content:"\f03d"}.fa-photo:before,.fa-image:before,.fa-picture-o:before{content:"\f03e"}.fa-pencil:before{content:"\f040"}.fa-map-marker:before{content:"\f041"}.fa-adjust:before{content:"\f042"}.fa-tint:before{content:"\f043"}.fa-edit:before,.fa-pencil-square-o:before{content:"\f044"}.fa-share-square-o:before{content:"\f045"}.fa-check-square-o:before{content:"\f046"}.fa-arrows:before{content:"\f047"}.fa-step-backward:before{content:"\f048"}.fa-fast-backward:before{content:"\f049"}.fa-backward:before{content:"\f04a"}.fa-play:before{content:"\f04b"}.fa-pause:before{content:"\f04c"}.fa-stop:before{content:"\f04d"}.fa-forward:before{content:"\f04e"}.fa-fast-forward:before{content:"\f050"}.fa-step-forward:before{content:"\f051"}.fa-eject:before{content:"\f052"}.fa-chevron-left:before{content:"\f053"}.fa-chevron-right:before{content:"\f054"}.fa-plus-circle:before{content:"\f055"}.fa-minus-circle:before{content:"\f056"}.fa-times-circle:before{content:"\f057"}.fa-check-circle:before{content:"\f058"}.fa-question-circle:before{content:"\f059"}.fa-info-circle:before{content:"\f05a"}.fa-crosshairs:before{content:"\f05b"}.fa-times-circle-o:before{content:"\f05c"}.fa-check-circle-o:before{content:"\f05d"}.fa-ban:before{content:"\f05e"}.fa-arrow-left:before{content:"\f060"}.fa-arrow-right:before{content:"\f061"}.fa-arrow-up:before{content:"\f062"}.fa-arrow-down:before{content:"\f063"}.fa-mail-forward:before,.fa-share:before{content:"\f064"}.fa-expand:before{content:"\f065"}.fa-compress:before{content:"\f066"}.fa-plus:before{content:"\f067"}.fa-minus:before{content:"\f068"}.fa-asterisk:before{content:"\f069"}.fa-exclamation-circle:before{content:"\f06a"}.fa-gift:before{content:"\f06b"}.fa-leaf:before{content:"\f06c"}.fa-fire:before{content:"\f06d"}.fa-eye:before{content:"\f06e"}.fa-eye-slash:before{content:"\f070"}.fa-warning:before,.fa-exclamation-triangle:before{content:"\f071"}.fa-plane:before{content:"\f072"}.fa-calendar:before{content:"\f073"}.fa-random:before{content:"\f074"}.fa-comment:before{content:"\f075"}.fa-magnet:before{content:"\f076"}.fa-chevron-up:before{content:"\f077"}.fa-chevron-down:before{content:"\f078"}.fa-retweet:before{content:"\f079"}.fa-shopping-cart:before{content:"\f07a"}.fa-folder:before{content:"\f07b"}.fa-folder-open:before{content:"\f07c"}.fa-arrows-v:before{content:"\f07d"}.fa-arrows-h:before{content:"\f07e"}.fa-bar-chart-o:before,.fa-bar-chart:before{content:"\f080"}.fa-twitter-square:before{content:"\f081"}.fa-facebook-square:before{content:"\f082"}.fa-camera-retro:before{content:"\f083"}.fa-key:before{content:"\f084"}.fa-gears:before,.fa-cogs:before{content:"\f085"}.fa-comments:before{content:"\f086"}.fa-thumbs-o-up:before{content:"\f087"}.fa-thumbs-o-down:before{content:"\f088"}.fa-star-half:before{content:"\f089"}.fa-heart-o:before{content:"\f08a"}.fa-sign-out:before{content:"\f08b"}.fa-linkedin-square:before{content:"\f08c"}.fa-thumb-tack:before{content:"\f08d"}.fa-external-link:before{content:"\f08e"}.fa-sign-in:before{content:"\f090"}.fa-trophy:before{content:"\f091"}.fa-github-square:before{content:"\f092"}.fa-upload:before{content:"\f093"}.fa-lemon-o:before{content:"\f094"}.fa-phone:before{content:"\f095"}.fa-square-o:before{content:"\f096"}.fa-bookmark-o:before{content:"\f097"}.fa-phone-square:before{content:"\f098"}.fa-twitter:before{content:"\f099"}.fa-facebook-f:before,.fa-facebook:before{content:"\f09a"}.fa-github:before{content:"\f09b"}.fa-unlock:before{content:"\f09c"}.fa-credit-card:before{content:"\f09d"}.fa-feed:before,.fa-rss:before{content:"\f09e"}.fa-hdd-o:before{content:"\f0a0"}.fa-bullhorn:before{content:"\f0a1"}.fa-bell:before{content:"\f0f3"}.fa-certificate:before{content:"\f0a3"}.fa-hand-o-right:before{content:"\f0a4"}.fa-hand-o-left:before{content:"\f0a5"}.fa-hand-o-up:before{content:"\f0a6"}.fa-hand-o-down:before{content:"\f0a7"}.fa-arrow-circle-left:before{content:"\f0a8"}.fa-arrow-circle-right:before{content:"\f0a9"}.fa-arrow-circle-up:before{content:"\f0aa"}.fa-arrow-circle-down:before{content:"\f0ab"}.fa-globe:before{content:"\f0ac"}.fa-wrench:before{content:"\f0ad"}.fa-tasks:before{content:"\f0ae"}.fa-filter:before{content:"\f0b0"}.fa-briefcase:before{content:"\f0b1"}.fa-arrows-alt:before{content:"\f0b2"}.fa-group:before,.fa-users:before{content:"\f0c0"}.fa-chain:before,.fa-link:before{content:"\f0c1"}.fa-cloud:before{content:"\f0c2"}.fa-flask:before{content:"\f0c3"}.fa-cut:before,.fa-scissors:before{content:"\f0c4"}.fa-copy:before,.fa-files-o:before{content:"\f0c5"}.fa-paperclip:before{content:"\f0c6"}.fa-save:before,.fa-floppy-o:before{content:"\f0c7"}.fa-square:before{content:"\f0c8"}.fa-navicon:before,.fa-reorder:before,.fa-bars:before{content:"\f0c9"}.fa-list-ul:before{content:"\f0ca"}.fa-list-ol:before{content:"\f0cb"}.fa-strikethrough:before{content:"\f0cc"}.fa-underline:before{content:"\f0cd"}.fa-table:before{content:"\f0ce"}.fa-magic:before{content:"\f0d0"}.fa-truck:before{content:"\f0d1"}.fa-pinterest:before{content:"\f0d2"}.fa-pinterest-square:before{content:"\f0d3"}.fa-google-plus-square:before{content:"\f0d4"}.fa-google-plus:before{content:"\f0d5"}.fa-money:before{content:"\f0d6"}.fa-caret-down:before{content:"\f0d7"}.fa-caret-up:before{content:"\f0d8"}.fa-caret-left:before{content:"\f0d9"}.fa-caret-right:before{content:"\f0da"}.fa-columns:before{content:"\f0db"}.fa-unsorted:before,.fa-sort:before{content:"\f0dc"}.fa-sort-down:before,.fa-sort-desc:before{content:"\f0dd"}.fa-sort-up:before,.fa-sort-asc:before{content:"\f0de"}.fa-envelope:before{content:"\f0e0"}.fa-linkedin:before{content:"\f0e1"}.fa-rotate-left:before,.fa-undo:before{content:"\f0e2"}.fa-legal:before,.fa-gavel:before{content:"\f0e3"}.fa-dashboard:before,.fa-tachometer:before{content:"\f0e4"}.fa-comment-o:before{content:"\f0e5"}.fa-comments-o:before{content:"\f0e6"}.fa-flash:before,.fa-bolt:before{content:"\f0e7"}.fa-sitemap:before{content:"\f0e8"}.fa-umbrella:before{content:"\f0e9"}.fa-paste:before,.fa-clipboard:before{content:"\f0ea"}.fa-lightbulb-o:before{content:"\f0eb"}.fa-exchange:before{content:"\f0ec"}.fa-cloud-download:before{content:"\f0ed"}.fa-cloud-upload:before{content:"\f0ee"}.fa-user-md:before{content:"\f0f0"}.fa-stethoscope:before{content:"\f0f1"}.fa-suitcase:before{content:"\f0f2"}.fa-bell-o:before{content:"\f0a2"}.fa-coffee:before{content:"\f0f4"}.fa-cutlery:before{content:"\f0f5"}.fa-file-text-o:before{content:"\f0f6"}.fa-building-o:before{content:"\f0f7"}.fa-hospital-o:before{content:"\f0f8"}.fa-ambulance:before{content:"\f0f9"}.fa-medkit:before{content:"\f0fa"}.fa-fighter-jet:before{content:"\f0fb"}.fa-beer:before{content:"\f0fc"}.fa-h-square:before{content:"\f0fd"}.fa-plus-square:before{content:"\f0fe"}.fa-angle-double-left:before{content:"\f100"}.fa-angle-double-right:before{content:"\f101"}.fa-angle-double-up:before{content:"\f102"}.fa-angle-double-down:before{content:"\f103"}.fa-angle-left:before{content:"\f104"}.fa-angle-right:before{content:"\f105"}.fa-angle-up:before{content:"\f106"}.fa-angle-down:before{content:"\f107"}.fa-desktop:before{content:"\f108"}.fa-laptop:before{content:"\f109"}.fa-tablet:before{content:"\f10a"}.fa-mobile-phone:before,.fa-mobile:before{content:"\f10b"}.fa-circle-o:before{content:"\f10c"}.fa-quote-left:before{content:"\f10d"}.fa-quote-right:before{content:"\f10e"}.fa-spinner:before{content:"\f110"}.fa-circle:before{content:"\f111"}.fa-mail-reply:before,.fa-reply:before{content:"\f112"}.fa-github-alt:before{content:"\f113"}.fa-folder-o:before{content:"\f114"}.fa-folder-open-o:before{content:"\f115"}.fa-smile-o:before{content:"\f118"}.fa-frown-o:before{content:"\f119"}.fa-meh-o:before{content:"\f11a"}.fa-gamepad:before{content:"\f11b"}.fa-keyboard-o:before{content:"\f11c"}.fa-flag-o:before{content:"\f11d"}.fa-flag-checkered:before{content:"\f11e"}.fa-terminal:before{content:"\f120"}.fa-code:before{content:"\f121"}.fa-mail-reply-all:before,.fa-reply-all:before{content:"\f122"}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:"\f123"}.fa-location-arrow:before{content:"\f124"}.fa-crop:before{content:"\f125"}.fa-code-fork:before{content:"\f126"}.fa-unlink:before,.fa-chain-broken:before{content:"\f127"}.fa-question:before{content:"\f128"}.fa-info:before{content:"\f129"}.fa-exclamation:before{content:"\f12a"}.fa-superscript:before{content:"\f12b"}.fa-subscript:before{content:"\f12c"}.fa-eraser:before{content:"\f12d"}.fa-puzzle-piece:before{content:"\f12e"}.fa-microphone:before{content:"\f130"}.fa-microphone-slash:before{content:"\f131"}.fa-shield:before{content:"\f132"}.fa-calendar-o:before{content:"\f133"}.fa-fire-extinguisher:before{content:"\f134"}.fa-rocket:before{content:"\f135"}.fa-maxcdn:before{content:"\f136"}.fa-chevron-circle-left:before{content:"\f137"}.fa-chevron-circle-right:before{content:"\f138"}.fa-chevron-circle-up:before{content:"\f139"}.fa-chevron-circle-down:before{content:"\f13a"}.fa-html5:before{content:"\f13b"}.fa-css3:before{content:"\f13c"}.fa-anchor:before{content:"\f13d"}.fa-unlock-alt:before{content:"\f13e"}.fa-bullseye:before{content:"\f140"}.fa-ellipsis-h:before{content:"\f141"}.fa-ellipsis-v:before{content:"\f142"}.fa-rss-square:before{content:"\f143"}.fa-play-circle:before{content:"\f144"}.fa-ticket:before{content:"\f145"}.fa-minus-square:before{content:"\f146"}.fa-minus-square-o:before{content:"\f147"}.fa-level-up:before{content:"\f148"}.fa-level-down:before{content:"\f149"}.fa-check-square:before{content:"\f14a"}.fa-pencil-square:before{content:"\f14b"}.fa-external-link-square:before{content:"\f14c"}.fa-share-square:before{content:"\f14d"}.fa-compass:before{content:"\f14e"}.fa-toggle-down:before,.fa-caret-square-o-down:before{content:"\f150"}.fa-toggle-up:before,.fa-caret-square-o-up:before{content:"\f151"}.fa-toggle-right:before,.fa-caret-square-o-right:before{content:"\f152"}.fa-euro:before,.fa-eur:before{content:"\f153"}.fa-gbp:before{content:"\f154"}.fa-dollar:before,.fa-usd:before{content:"\f155"}.fa-rupee:before,.fa-inr:before{content:"\f156"}.fa-cny:before,.fa-rmb:before,.fa-yen:before,.fa-jpy:before{content:"\f157"}.fa-ruble:before,.fa-rouble:before,.fa-rub:before{content:"\f158"}.fa-won:before,.fa-krw:before{content:"\f159"}.fa-bitcoin:before,.fa-btc:before{content:"\f15a"}.fa-file:before{content:"\f15b"}.fa-file-text:before{content:"\f15c"}.fa-sort-alpha-asc:before{content:"\f15d"}.fa-sort-alpha-desc:before{content:"\f15e"}.fa-sort-amount-asc:before{content:"\f160"}.fa-sort-amount-desc:before{content:"\f161"}.fa-sort-numeric-asc:before{content:"\f162"}.fa-sort-numeric-desc:before{content:"\f163"}.fa-thumbs-up:before{content:"\f164"}.fa-thumbs-down:before{content:"\f165"}.fa-youtube-square:before{content:"\f166"}.fa-youtube:before{content:"\f167"}.fa-xing:before{content:"\f168"}.fa-xing-square:before{content:"\f169"}.fa-youtube-play:before{content:"\f16a"}.fa-dropbox:before{content:"\f16b"}.fa-stack-overflow:before{content:"\f16c"}.fa-instagram:before{content:"\f16d"}.fa-flickr:before{content:"\f16e"}.fa-adn:before{content:"\f170"}.fa-bitbucket:before{content:"\f171"}.fa-bitbucket-square:before{content:"\f172"}.fa-tumblr:before{content:"\f173"}.fa-tumblr-square:before{content:"\f174"}.fa-long-arrow-down:before{content:"\f175"}.fa-long-arrow-up:before{content:"\f176"}.fa-long-arrow-left:before{content:"\f177"}.fa-long-arrow-right:before{content:"\f178"}.fa-apple:before{content:"\f179"}.fa-windows:before{content:"\f17a"}.fa-android:before{content:"\f17b"}.fa-linux:before{content:"\f17c"}.fa-dribbble:before{content:"\f17d"}.fa-skype:before{content:"\f17e"}.fa-foursquare:before{content:"\f180"}.fa-trello:before{content:"\f181"}.fa-female:before{content:"\f182"}.fa-male:before{content:"\f183"}.fa-gittip:before,.fa-gratipay:before{content:"\f184"}.fa-sun-o:before{content:"\f185"}.fa-moon-o:before{content:"\f186"}.fa-archive:before{content:"\f187"}.fa-bug:before{content:"\f188"}.fa-vk:before{content:"\f189"}.fa-weibo:before{content:"\f18a"}.fa-renren:before{content:"\f18b"}.fa-pagelines:before{content:"\f18c"}.fa-stack-exchange:before{content:"\f18d"}.fa-arrow-circle-o-right:before{content:"\f18e"}.fa-arrow-circle-o-left:before{content:"\f190"}.fa-toggle-left:before,.fa-caret-square-o-left:before{content:"\f191"}.fa-dot-circle-o:before{content:"\f192"}.fa-wheelchair:before{content:"\f193"}.fa-vimeo-square:before{content:"\f194"}.fa-turkish-lira:before,.fa-try:before{content:"\f195"}.fa-plus-square-o:before{content:"\f196"}.fa-space-shuttle:before{content:"\f197"}.fa-slack:before{content:"\f198"}.fa-envelope-square:before{content:"\f199"}.fa-wordpress:before{content:"\f19a"}.fa-openid:before{content:"\f19b"}.fa-institution:before,.fa-bank:before,.fa-university:before{content:"\f19c"}.fa-mortar-board:before,.fa-graduation-cap:before{content:"\f19d"}.fa-yahoo:before{content:"\f19e"}.fa-google:before{content:"\f1a0"}.fa-reddit:before{content:"\f1a1"}.fa-reddit-square:before{content:"\f1a2"}.fa-stumbleupon-circle:before{content:"\f1a3"}.fa-stumbleupon:before{content:"\f1a4"}.fa-delicious:before{content:"\f1a5"}.fa-digg:before{content:"\f1a6"}.fa-pied-piper-pp:before{content:"\f1a7"}.fa-pied-piper-alt:before{content:"\f1a8"}.fa-drupal:before{content:"\f1a9"}.fa-joomla:before{content:"\f1aa"}.fa-language:before{content:"\f1ab"}.fa-fax:before{content:"\f1ac"}.fa-building:before{content:"\f1ad"}.fa-child:before{content:"\f1ae"}.fa-paw:before{content:"\f1b0"}.fa-spoon:before{content:"\f1b1"}.fa-cube:before{content:"\f1b2"}.fa-cubes:before{content:"\f1b3"}.fa-behance:before{content:"\f1b4"}.fa-behance-square:before{content:"\f1b5"}.fa-steam:before{content:"\f1b6"}.fa-steam-square:before{content:"\f1b7"}.fa-recycle:before{content:"\f1b8"}.fa-automobile:before,.fa-car:before{content:"\f1b9"}.fa-cab:before,.fa-taxi:before{content:"\f1ba"}.fa-tree:before{content:"\f1bb"}.fa-spotify:before{content:"\f1bc"}.fa-deviantart:before{content:"\f1bd"}.fa-soundcloud:before{content:"\f1be"}.fa-database:before{content:"\f1c0"}.fa-file-pdf-o:before{content:"\f1c1"}.fa-file-word-o:before{content:"\f1c2"}.fa-file-excel-o:before{content:"\f1c3"}.fa-file-powerpoint-o:before{content:"\f1c4"}.fa-file-photo-o:before,.fa-file-picture-o:before,.fa-file-image-o:before{content:"\f1c5"}.fa-file-zip-o:before,.fa-file-archive-o:before{content:"\f1c6"}.fa-file-sound-o:before,.fa-file-audio-o:before{content:"\f1c7"}.fa-file-movie-o:before,.fa-file-video-o:before{content:"\f1c8"}.fa-file-code-o:before{content:"\f1c9"}.fa-vine:before{content:"\f1ca"}.fa-codepen:before{content:"\f1cb"}.fa-jsfiddle:before{content:"\f1cc"}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-saver:before,.fa-support:before,.fa-life-ring:before{content:"\f1cd"}.fa-circle-o-notch:before{content:"\f1ce"}.fa-ra:before,.fa-resistance:before,.fa-rebel:before{content:"\f1d0"}.fa-ge:before,.fa-empire:before{content:"\f1d1"}.fa-git-square:before{content:"\f1d2"}.fa-git:before{content:"\f1d3"}.fa-y-combinator-square:before,.fa-yc-square:before,.fa-hacker-news:before{content:"\f1d4"}.fa-tencent-weibo:before{content:"\f1d5"}.fa-qq:before{content:"\f1d6"}.fa-wechat:before,.fa-weixin:before{content:"\f1d7"}.fa-send:before,.fa-paper-plane:before{content:"\f1d8"}.fa-send-o:before,.fa-paper-plane-o:before{content:"\f1d9"}.fa-history:before{content:"\f1da"}.fa-circle-thin:before{content:"\f1db"}.fa-header:before{content:"\f1dc"}.fa-paragraph:before{content:"\f1dd"}.fa-sliders:before{content:"\f1de"}.fa-share-alt:before{content:"\f1e0"}.fa-share-alt-square:before{content:"\f1e1"}.fa-bomb:before{content:"\f1e2"}.fa-soccer-ball-o:before,.fa-futbol-o:before{content:"\f1e3"}.fa-tty:before{content:"\f1e4"}.fa-binoculars:before{content:"\f1e5"}.fa-plug:before{content:"\f1e6"}.fa-slideshare:before{content:"\f1e7"}.fa-twitch:before{content:"\f1e8"}.fa-yelp:before{content:"\f1e9"}.fa-newspaper-o:before{content:"\f1ea"}.fa-wifi:before{content:"\f1eb"}.fa-calculator:before{content:"\f1ec"}.fa-paypal:before{content:"\f1ed"}.fa-google-wallet:before{content:"\f1ee"}.fa-cc-visa:before{content:"\f1f0"}.fa-cc-mastercard:before{content:"\f1f1"}.fa-cc-discover:before{content:"\f1f2"}.fa-cc-amex:before{content:"\f1f3"}.fa-cc-paypal:before{content:"\f1f4"}.fa-cc-stripe:before{content:"\f1f5"}.fa-bell-slash:before{content:"\f1f6"}.fa-bell-slash-o:before{content:"\f1f7"}.fa-trash:before{content:"\f1f8"}.fa-copyright:before{content:"\f1f9"}.fa-at:before{content:"\f1fa"}.fa-eyedropper:before{content:"\f1fb"}.fa-paint-brush:before{content:"\f1fc"}.fa-birthday-cake:before{content:"\f1fd"}.fa-area-chart:before{content:"\f1fe"}.fa-pie-chart:before{content:"\f200"}.fa-line-chart:before{content:"\f201"}.fa-lastfm:before{content:"\f202"}.fa-lastfm-square:before{content:"\f203"}.fa-toggle-off:before{content:"\f204"}.fa-toggle-on:before{content:"\f205"}.fa-bicycle:before{content:"\f206"}.fa-bus:before{content:"\f207"}.fa-ioxhost:before{content:"\f208"}.fa-angellist:before{content:"\f209"}.fa-cc:before{content:"\f20a"}.fa-shekel:before,.fa-sheqel:before,.fa-ils:before{content:"\f20b"}.fa-meanpath:before{content:"\f20c"}.fa-buysellads:before{content:"\f20d"}.fa-connectdevelop:before{content:"\f20e"}.fa-dashcube:before{content:"\f210"}.fa-forumbee:before{content:"\f211"}.fa-leanpub:before{content:"\f212"}.fa-sellsy:before{content:"\f213"}.fa-shirtsinbulk:before{content:"\f214"}.fa-simplybuilt:before{content:"\f215"}.fa-skyatlas:before{content:"\f216"}.fa-cart-plus:before{content:"\f217"}.fa-cart-arrow-down:before{content:"\f218"}.fa-diamond:before{content:"\f219"}.fa-ship:before{content:"\f21a"}.fa-user-secret:before{content:"\f21b"}.fa-motorcycle:before{content:"\f21c"}.fa-street-view:before{content:"\f21d"}.fa-heartbeat:before{content:"\f21e"}.fa-venus:before{content:"\f221"}.fa-mars:before{content:"\f222"}.fa-mercury:before{content:"\f223"}.fa-intersex:before,.fa-transgender:before{content:"\f224"}.fa-transgender-alt:before{content:"\f225"}.fa-venus-double:before{content:"\f226"}.fa-mars-double:before{content:"\f227"}.fa-venus-mars:before{content:"\f228"}.fa-mars-stroke:before{content:"\f229"}.fa-mars-stroke-v:before{content:"\f22a"}.fa-mars-stroke-h:before{content:"\f22b"}.fa-neuter:before{content:"\f22c"}.fa-genderless:before{content:"\f22d"}.fa-facebook-official:before{content:"\f230"}.fa-pinterest-p:before{content:"\f231"}.fa-whatsapp:before{content:"\f232"}.fa-server:before{content:"\f233"}.fa-user-plus:before{content:"\f234"}.fa-user-times:before{content:"\f235"}.fa-hotel:before,.fa-bed:before{content:"\f236"}.fa-viacoin:before{content:"\f237"}.fa-train:before{content:"\f238"}.fa-subway:before{content:"\f239"}.fa-medium:before{content:"\f23a"}.fa-yc:before,.fa-y-combinator:before{content:"\f23b"}.fa-optin-monster:before{content:"\f23c"}.fa-opencart:before{content:"\f23d"}.fa-expeditedssl:before{content:"\f23e"}.fa-battery-4:before,.fa-battery:before,.fa-battery-full:before{content:"\f240"}.fa-battery-3:before,.fa-battery-three-quarters:before{content:"\f241"}.fa-battery-2:before,.fa-battery-half:before{content:"\f242"}.fa-battery-1:before,.fa-battery-quarter:before{content:"\f243"}.fa-battery-0:before,.fa-battery-empty:before{content:"\f244"}.fa-mouse-pointer:before{content:"\f245"}.fa-i-cursor:before{content:"\f246"}.fa-object-group:before{content:"\f247"}.fa-object-ungroup:before{content:"\f248"}.fa-sticky-note:before{content:"\f249"}.fa-sticky-note-o:before{content:"\f24a"}.fa-cc-jcb:before{content:"\f24b"}.fa-cc-diners-club:before{content:"\f24c"}.fa-clone:before{content:"\f24d"}.fa-balance-scale:before{content:"\f24e"}.fa-hourglass-o:before{content:"\f250"}.fa-hourglass-1:before,.fa-hourglass-start:before{content:"\f251"}.fa-hourglass-2:before,.fa-hourglass-half:before{content:"\f252"}.fa-hourglass-3:before,.fa-hourglass-end:before{content:"\f253"}.fa-hourglass:before{content:"\f254"}.fa-hand-grab-o:before,.fa-hand-rock-o:before{content:"\f255"}.fa-hand-stop-o:before,.fa-hand-paper-o:before{content:"\f256"}.fa-hand-scissors-o:before{content:"\f257"}.fa-hand-lizard-o:before{content:"\f258"}.fa-hand-spock-o:before{content:"\f259"}.fa-hand-pointer-o:before{content:"\f25a"}.fa-hand-peace-o:before{content:"\f25b"}.fa-trademark:before{content:"\f25c"}.fa-registered:before{content:"\f25d"}.fa-creative-commons:before{content:"\f25e"}.fa-gg:before{content:"\f260"}.fa-gg-circle:before{content:"\f261"}.fa-tripadvisor:before{content:"\f262"}.fa-odnoklassniki:before{content:"\f263"}.fa-odnoklassniki-square:before{content:"\f264"}.fa-get-pocket:before{content:"\f265"}.fa-wikipedia-w:before{content:"\f266"}.fa-safari:before{content:"\f267"}.fa-chrome:before{content:"\f268"}.fa-firefox:before{content:"\f269"}.fa-opera:before{content:"\f26a"}.fa-internet-explorer:before{content:"\f26b"}.fa-tv:before,.fa-television:before{content:"\f26c"}.fa-contao:before{content:"\f26d"}.fa-500px:before{content:"\f26e"}.fa-amazon:before{content:"\f270"}.fa-calendar-plus-o:before{content:"\f271"}.fa-calendar-minus-o:before{content:"\f272"}.fa-calendar-times-o:before{content:"\f273"}.fa-calendar-check-o:before{content:"\f274"}.fa-industry:before{content:"\f275"}.fa-map-pin:before{content:"\f276"}.fa-map-signs:before{content:"\f277"}.fa-map-o:before{content:"\f278"}.fa-map:before{content:"\f279"}.fa-commenting:before{content:"\f27a"}.fa-commenting-o:before{content:"\f27b"}.fa-houzz:before{content:"\f27c"}.fa-vimeo:before{content:"\f27d"}.fa-black-tie:before{content:"\f27e"}.fa-fonticons:before{content:"\f280"}.fa-reddit-alien:before{content:"\f281"}.fa-edge:before{content:"\f282"}.fa-credit-card-alt:before{content:"\f283"}.fa-codiepie:before{content:"\f284"}.fa-modx:before{content:"\f285"}.fa-fort-awesome:before{content:"\f286"}.fa-usb:before{content:"\f287"}.fa-product-hunt:before{content:"\f288"}.fa-mixcloud:before{content:"\f289"}.fa-scribd:before{content:"\f28a"}.fa-pause-circle:before{content:"\f28b"}.fa-pause-circle-o:before{content:"\f28c"}.fa-stop-circle:before{content:"\f28d"}.fa-stop-circle-o:before{content:"\f28e"}.fa-shopping-bag:before{content:"\f290"}.fa-shopping-basket:before{content:"\f291"}.fa-hashtag:before{content:"\f292"}.fa-bluetooth:before{content:"\f293"}.fa-bluetooth-b:before{content:"\f294"}.fa-percent:before{content:"\f295"}.fa-gitlab:before{content:"\f296"}.fa-wpbeginner:before{content:"\f297"}.fa-wpforms:before{content:"\f298"}.fa-envira:before{content:"\f299"}.fa-universal-access:before{content:"\f29a"}.fa-wheelchair-alt:before{content:"\f29b"}.fa-question-circle-o:before{content:"\f29c"}.fa-blind:before{content:"\f29d"}.fa-audio-description:before{content:"\f29e"}.fa-volume-control-phone:before{content:"\f2a0"}.fa-braille:before{content:"\f2a1"}.fa-assistive-listening-systems:before{content:"\f2a2"}.fa-asl-interpreting:before,.fa-american-sign-language-interpreting:before{content:"\f2a3"}.fa-deafness:before,.fa-hard-of-hearing:before,.fa-deaf:before{content:"\f2a4"}.fa-glide:before{content:"\f2a5"}.fa-glide-g:before{content:"\f2a6"}.fa-signing:before,.fa-sign-language:before{content:"\f2a7"}.fa-low-vision:before{content:"\f2a8"}.fa-viadeo:before{content:"\f2a9"}.fa-viadeo-square:before{content:"\f2aa"}.fa-snapchat:before{content:"\f2ab"}.fa-snapchat-ghost:before{content:"\f2ac"}.fa-snapchat-square:before{content:"\f2ad"}.fa-pied-piper:before{content:"\f2ae"}.fa-first-order:before{content:"\f2b0"}.fa-yoast:before{content:"\f2b1"}.fa-themeisle:before{content:"\f2b2"}.fa-google-plus-circle:before,.fa-google-plus-official:before{content:"\f2b3"}.fa-fa:before,.fa-font-awesome:before{content:"\f2b4"}.fa-handshake-o:before{content:"\f2b5"}.fa-envelope-open:before{content:"\f2b6"}.fa-envelope-open-o:before{content:"\f2b7"}.fa-linode:before{content:"\f2b8"}.fa-address-book:before{content:"\f2b9"}.fa-address-book-o:before{content:"\f2ba"}.fa-vcard:before,.fa-address-card:before{content:"\f2bb"}.fa-vcard-o:before,.fa-address-card-o:before{content:"\f2bc"}.fa-user-circle:before{content:"\f2bd"}.fa-user-circle-o:before{content:"\f2be"}.fa-user-o:before{content:"\f2c0"}.fa-id-badge:before{content:"\f2c1"}.fa-drivers-license:before,.fa-id-card:before{content:"\f2c2"}.fa-drivers-license-o:before,.fa-id-card-o:before{content:"\f2c3"}.fa-quora:before{content:"\f2c4"}.fa-free-code-camp:before{content:"\f2c5"}.fa-telegram:before{content:"\f2c6"}.fa-thermometer-4:before,.fa-thermometer:before,.fa-thermometer-full:before{content:"\f2c7"}.fa-thermometer-3:before,.fa-thermometer-three-quarters:before{content:"\f2c8"}.fa-thermometer-2:before,.fa-thermometer-half:before{content:"\f2c9"}.fa-thermometer-1:before,.fa-thermometer-quarter:before{content:"\f2ca"}.fa-thermometer-0:before,.fa-thermometer-empty:before{content:"\f2cb"}.fa-shower:before{content:"\f2cc"}.fa-bathtub:before,.fa-s15:before,.fa-bath:before{content:"\f2cd"}.fa-podcast:before{content:"\f2ce"}.fa-window-maximize:before{content:"\f2d0"}.fa-window-minimize:before{content:"\f2d1"}.fa-window-restore:before{content:"\f2d2"}.fa-times-rectangle:before,.fa-window-close:before{content:"\f2d3"}.fa-times-rectangle-o:before,.fa-window-close-o:before{content:"\f2d4"}.fa-bandcamp:before{content:"\f2d5"}.fa-grav:before{content:"\f2d6"}.fa-etsy:before{content:"\f2d7"}.fa-imdb:before{content:"\f2d8"}.fa-ravelry:before{content:"\f2d9"}.fa-eercast:before{content:"\f2da"}.fa-microchip:before{content:"\f2db"}.fa-snowflake-o:before{content:"\f2dc"}.fa-superpowers:before{content:"\f2dd"}.fa-wpexplorer:before{content:"\f2de"}.fa-meetup:before{content:"\f2e0"}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);border:0}.sr-only-focusable:active,.sr-only-focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto} 5 | -------------------------------------------------------------------------------- /src/public/static/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metacpan/metacpan-grep-front-end/a5f6e6a852fd52203da5345c279b39a5b6ec9ae0/src/public/static/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /src/public/static/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metacpan/metacpan-grep-front-end/a5f6e6a852fd52203da5345c279b39a5b6ec9ae0/src/public/static/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /src/public/static/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metacpan/metacpan-grep-front-end/a5f6e6a852fd52203da5345c279b39a5b6ec9ae0/src/public/static/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /src/public/static/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metacpan/metacpan-grep-front-end/a5f6e6a852fd52203da5345c279b39a5b6ec9ae0/src/public/static/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /src/public/static/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metacpan/metacpan-grep-front-end/a5f6e6a852fd52203da5345c279b39a5b6ec9ae0/src/public/static/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /src/public/static/icons/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metacpan/metacpan-grep-front-end/a5f6e6a852fd52203da5345c279b39a5b6ec9ae0/src/public/static/icons/apple-touch-icon.png -------------------------------------------------------------------------------- /src/public/static/icons/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metacpan/metacpan-grep-front-end/a5f6e6a852fd52203da5345c279b39a5b6ec9ae0/src/public/static/icons/favicon.ico -------------------------------------------------------------------------------- /src/public/static/icons/metacpan-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metacpan/metacpan-grep-front-end/a5f6e6a852fd52203da5345c279b39a5b6ec9ae0/src/public/static/icons/metacpan-icon.png -------------------------------------------------------------------------------- /src/public/static/images/grep-cpan-logo-flat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metacpan/metacpan-grep-front-end/a5f6e6a852fd52203da5345c279b39a5b6ec9ae0/src/public/static/images/grep-cpan-logo-flat.png -------------------------------------------------------------------------------- /src/public/static/images/grep_cpan_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metacpan/metacpan-grep-front-end/a5f6e6a852fd52203da5345c279b39a5b6ec9ae0/src/public/static/images/grep_cpan_logo.png -------------------------------------------------------------------------------- /src/public/static/images/grep_cpan_logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/public/static/images/grepcpan-logo.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metacpan/metacpan-grep-front-end/a5f6e6a852fd52203da5345c279b39a5b6ec9ae0/src/public/static/images/grepcpan-logo.pxm -------------------------------------------------------------------------------- /src/public/static/images/metacpan-logo@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metacpan/metacpan-grep-front-end/a5f6e6a852fd52203da5345c279b39a5b6ec9ae0/src/public/static/images/metacpan-logo@2x.png -------------------------------------------------------------------------------- /src/public/static/images/perldancer-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metacpan/metacpan-grep-front-end/a5f6e6a852fd52203da5345c279b39a5b6ec9ae0/src/public/static/images/perldancer-bg.jpg -------------------------------------------------------------------------------- /src/public/static/images/perldancer.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metacpan/metacpan-grep-front-end/a5f6e6a852fd52203da5345c279b39a5b6ec9ae0/src/public/static/images/perldancer.jpg -------------------------------------------------------------------------------- /src/public/static/images/sponsors/cpanel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metacpan/metacpan-grep-front-end/a5f6e6a852fd52203da5345c279b39a5b6ec9ae0/src/public/static/images/sponsors/cpanel.png -------------------------------------------------------------------------------- /src/public/static/images/sponsors/perl-careers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/metacpan/metacpan-grep-front-end/a5f6e6a852fd52203da5345c279b39a5b6ec9ae0/src/public/static/images/sponsors/perl-careers.png -------------------------------------------------------------------------------- /src/t/001_base.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | BEGIN { 5 | use FindBin; 6 | unshift @INC, $FindBin::Bin . "/lib"; 7 | } 8 | 9 | use Test::Grep::MetaCPAN; 10 | 11 | use Test::More tests => 1; 12 | 13 | use_ok 'grepcpan'; 14 | -------------------------------------------------------------------------------- /src/t/002_index_route.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | BEGIN { 5 | use FindBin; 6 | unshift @INC, $FindBin::Bin . "/lib"; 7 | } 8 | 9 | use Test::Grep::MetaCPAN; 10 | 11 | use grepcpan; 12 | use Test::More tests => 2; 13 | use Plack::Test; 14 | use HTTP::Request::Common; 15 | 16 | my $app = grepcpan->to_app; 17 | is( ref $app, 'CODE', 'Got app' ); 18 | 19 | my $test = Plack::Test->create($app); 20 | my $res = $test->request( GET '/' ); 21 | 22 | ok( $res->is_success, '[GET /] successful' ); 23 | -------------------------------------------------------------------------------- /src/t/GrepCpan-Grep-dosearch.t: -------------------------------------------------------------------------------- 1 | use v5.36; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | local $| = 1; 7 | 8 | BEGIN { 9 | use FindBin; 10 | unshift @INC, $FindBin::Bin . "/lib"; 11 | } 12 | 13 | use Test::Grep::MetaCPAN; 14 | 15 | use Test2::V0; 16 | use Test2::Tools::Explain; 17 | use Test2::Plugin::NoWarnings; 18 | 19 | use GrepCpan::Grep; 20 | use List::MoreUtils qw{natatime}; 21 | 22 | use File::Temp (); 23 | 24 | my $tmp = File::Temp->newdir( "grep-XXXXXX", DIR => q[/tmp], UNLINK => 1 ); 25 | my $tmpdir = $tmp->dirname; 26 | ok -d $tmpdir, "using tmp directory: $tmpdir"; 27 | 28 | $grepcpan::VERSION = "0.01"; 29 | 30 | my $git; 31 | 32 | foreach my $c ( 33 | qw{ /opt/homebrew/bin/git /usr/local/cpanel/3rdparty/bin/git /usr/bin/git } 34 | ) 35 | { 36 | next unless -x $c; 37 | $git = $c; 38 | } 39 | 40 | die "missing git binary" unless length $git; 41 | 42 | ### probably move to a test helper somewhere 43 | my $config = { 44 | 'binaries' => { 'git' => $git }, 45 | 'cache' => { 46 | 'directory' => $tmpdir, 47 | 'version' => "0.$$" 48 | }, 49 | 'cookie' => { 50 | 'history_name' => 'lastsearch', 51 | 'history_size' => '20' 52 | }, 53 | 'demo' => '0', 54 | 'gitrepo' => '/metacpan-cpan-extracted', 55 | 'limit' => { 56 | 'distros_per_page' => '30', 57 | 'files_git_run_bg' => '2000', 58 | 'files_per_search' => '60', 59 | 'search_context' => '5', 60 | 'search_context_distro' => '10', 61 | 'search_context_file' => '60' 62 | }, 63 | 'maxworkers' => '2', 64 | 'nocache' => '0', 65 | 'timeout' => { 66 | 'grep_search' => '900', 67 | 'user_search' => '18' 68 | } 69 | }; 70 | 71 | #note explain $query; 72 | 73 | my $is_number = validator( 74 | sub { 75 | match(qr{^[0-9]+$}); 76 | } 77 | ); 78 | 79 | my $is_boolean = validator( 80 | sub { 81 | match(qr{^[0-]$}); 82 | } 83 | ); 84 | 85 | my $is_a_known_distro = ''; 86 | 87 | my $query_looks_sane = validator( 88 | sub { 89 | my $got = $_; 90 | like $got, hash { 91 | 92 | field is_a_known_distro => $is_a_known_distro; 93 | field is_incomplete => $is_boolean; # cannot guess the value 94 | 95 | field match => hash { 96 | field distros => D(); 97 | field files => D(); 98 | }; 99 | 100 | field results => array { 101 | 102 | #all_items sub { is ref $_, 'HASH', "results entry is a hash" }; 103 | all_items hash { 104 | field distro => D(); 105 | field files => array { 106 | all_items sub { 107 | like $_ => qr{^[/\w\-_\.\+]+$}, 108 | 'results/file: valid path file'; 109 | }; 110 | }; 111 | field matches => array { 112 | 113 | #all_items sub { is ref $_, 'HASH', "match is one hash" }; 114 | all_items hash { 115 | field file => D(); 116 | field blocks => array { 117 | 118 | #all_items sub { is ref $_, 'HASH', "match is one hash" }; 119 | all_items hash { 120 | field code => D(); 121 | field matchlines => array { 122 | all_items $is_number; 123 | }; 124 | field start_at => 125 | $is_number; #match(qr{^[0-9]+$}); 126 | }; 127 | }; 128 | }; 129 | }; 130 | field 'prefix' => D(); 131 | }; 132 | }; 133 | 134 | field search_in_progress => $is_boolean; # cannot guess the value 135 | field 'time_elapsed' => match(qr{^[0-9]+\.[0-9]+}); 136 | field version => D(); 137 | field adjusted_request => hash{}; 138 | 139 | } 140 | } 141 | ); 142 | 143 | my $grep = GrepCpan::Grep->new( config => $config ); 144 | 145 | my $queries = [ 146 | 'basic query without optional parameters' => { search => 'test' }, 147 | "pcre query without optional parameters" => { search => '[a-z]est' }, 148 | 'second page' => { search => 'test', page => 1 }, 149 | 'third page' => { search => 'test', page => 2 }, 150 | 'fourth page' => { search => 'test', page => 3 }, 151 | 152 | # sub { $is_a_known_distro = 1 }, undef, 153 | # 'search distro Try-Tiny' => 154 | # { search => 'try', search_distro => 'Try-Tiny' }, 155 | ]; 156 | 157 | my $iterator = natatime 2, @$queries; 158 | 159 | while ( my ( $name, $opts ) = $iterator->() ) { 160 | if ( ref $name eq 'CODE' ) { 161 | 162 | # custom code before next test 163 | $name->(); 164 | next; 165 | } 166 | 167 | my $query = $grep->do_search(%$opts); 168 | is( $query, $query_looks_sane, $name ) or diag explain $query; 169 | } 170 | 171 | done_testing; 172 | -------------------------------------------------------------------------------- /src/t/GrepCpan-Grep-grep-flavor.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use Test2::Bundle::Extended; 5 | use Test2::Tools::Explain; 6 | use Test2::Plugin::NoWarnings; 7 | 8 | use GrepCpan::Grep; 9 | 10 | my @fixed_string = ( undef, "Something to drink", "a basic= research~ 1", ); 11 | 12 | my @pcre = ( q{[a-z]}, q{?:(a|b)}, q{^abcd}, q{abcd$}, ); 13 | 14 | is GrepCpan::Grep::_get_git_grep_flavor($_) => '--fixed-string' 15 | foreach @fixed_string; 16 | is GrepCpan::Grep::_get_git_grep_flavor($_) => '-P' foreach @pcre; 17 | 18 | done_testing; 19 | -------------------------------------------------------------------------------- /src/t/GrepCpan-Grep-sanitize-search.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use Test2::Bundle::Extended; 5 | use Test2::Tools::Explain; 6 | use Test2::Plugin::NoWarnings; 7 | 8 | use GrepCpan::Grep; 9 | 10 | my @tests = ( 11 | [ qq{some\ttabs\t\t} => q{some.tabs..} ], 12 | [ 13 | q{somethïng diffêrènt with àccęnts} => 14 | q{someth.ng diff.r.nt with .cc.nts} 15 | ], 16 | ); 17 | 18 | my @preserve = ( 19 | undef, '', 20 | "Something to drink", "with some 123456789 numbers", 21 | q{and now some quotes '"' <--}, q{some\tescaped\ttabs\t\t}, 22 | q[.*:;{}&-?()<>()@$|=], q{()}, 23 | ); 24 | 25 | push @tests, map { [ $_, $_ ] } @preserve; 26 | 27 | foreach my $t (@tests) { 28 | my ( $in, $out ) = @$t; 29 | is GrepCpan::Grep::_sanitize_search($in), $out, 30 | "_sanitize_search(" . ( $in // 'undef' ) . ")"; 31 | } 32 | 33 | done_testing; 34 | -------------------------------------------------------------------------------- /src/t/GrepCpan-Grep-workers.t: -------------------------------------------------------------------------------- 1 | #package grepcpan; 2 | #use Dancer2; 3 | 4 | use strict; 5 | use warnings; 6 | 7 | use Test2::Bundle::Extended; 8 | use Test2::Tools::Explain; 9 | use Test2::Plugin::NoWarnings; 10 | 11 | use GrepCpan::Grep; 12 | 13 | use File::Temp (); 14 | 15 | my $tmp = File::Temp->newdir( "grep-XXXXXX", DIR => q[/tmp], UNLINK => 1 ); 16 | my $tmpdir = $tmp->dirname; 17 | ok -d $tmpdir, "using tmp directory: $tmpdir"; 18 | 19 | my $config = { 20 | 'maxworkers' => '2', 21 | 'gitrepo' => '/metacpan-cpan-extracted', 22 | 'cache' => { 23 | 'directory' => $tmpdir, 24 | 'version' => "0.$$" 25 | }, 26 | }; 27 | 28 | my $grep = GrepCpan::Grep->new( config => $config ); 29 | 30 | note "test check_if_a_worker_is_available -- main pid $$"; 31 | 32 | my $MAX_WORKER = 2; 33 | is $grep->config->{maxworkers}, $MAX_WORKER, "only $MAX_WORKER workers max"; 34 | 35 | my $mainpid = $$; 36 | 37 | my @kids; 38 | my $usr1 = 0; 39 | local $SIG{USR1} 40 | = sub { ++$usr1 }; # used by the parent to know when the kid is ready 41 | my $usr2 = 0; 42 | local $SIG{USR2} 43 | = sub { ++$usr2 }; # used by the kid to know if the parent is alive 44 | 45 | my $fork_a_worker = sub { 46 | $usr1 = 0; 47 | 48 | my $child_pid = fork(); 49 | die "Fork failed" unless defined $child_pid; 50 | if ($child_pid) { 51 | push @kids, $child_pid; 52 | sleep 1 unless $usr1; 53 | note "kid $child_pid is ready"; 54 | } 55 | else { 56 | my $ok = $grep->check_if_a_worker_is_available(); 57 | die "Worker cannot get a pool" unless $ok; 58 | die unless kill USR1 => $mainpid; # send a ready signal once 59 | # the worker is working.... 60 | while ( kill USR2 => $mainpid ) 61 | { # run until as long as our parent is running 62 | #note "sending USR2 from $$"; 63 | sleep 1; 64 | } 65 | exit; 66 | } 67 | return $child_pid; 68 | }; 69 | 70 | ok $fork_a_worker->(), 'fork_a_worker' for ( 1 .. $MAX_WORKER ); 71 | 72 | is $grep->check_if_a_worker_is_available(), undef, 73 | "$_ cannot get an extra worker" 74 | for 1 .. 4; 75 | 76 | kill 'KILL' => $kids[0]; 77 | ok waitpid( $kids[0], 0 ), 'one worker finished'; 78 | ok $fork_a_worker->(), 'can fork an extra worker'; 79 | is $grep->check_if_a_worker_is_available(), undef, 80 | "queue is full: cannot start an extra worker"; 81 | 82 | kill_all(); 83 | ok $fork_a_worker->(), 'fork extra worker' for ( 1 .. $MAX_WORKER ); 84 | kill_all(); 85 | 86 | done_testing; 87 | 88 | sub kill_all { 89 | 90 | foreach my $pid (@kids) { 91 | kill 'KILL' => $pid; 92 | note "waiting $pid"; 93 | ok waitpid( $pid, 0 ), "waiting for $pid"; 94 | } 95 | @kids = (); 96 | } 97 | -------------------------------------------------------------------------------- /src/t/GrepCpan-Grep.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use Test2::Bundle::Extended; 5 | use Test2::Tools::Explain; 6 | use Test2::Plugin::NoWarnings; 7 | 8 | use GrepCpan::Grep; 9 | 10 | my $test_methods = { 11 | config => D(), 12 | git => D(), 13 | cache => D(), 14 | distros_per_page => 30, 15 | search_context => 5, 16 | search_context_file => 60, 17 | search_context_distro => 10, 18 | git_binary => D(), 19 | root => D(), 20 | HEAD => D(), #qr{^[0-9a-f]+$}, 21 | }; 22 | 23 | my $config = { 24 | 'binaries' => { 'git' => '/home/atoomic/bin/git' }, 25 | 'cache' => { 26 | 'directory' => '~APPDIR~/var/tmp', 27 | 'version' => '1.03' 28 | }, 29 | 'cookie' => { 30 | 'history_name' => 'lastsearch', 31 | 'history_size' => '20' 32 | }, 33 | 'demo' => '0', 34 | 'gitrepo' => '/metacpan-cpan-extracted', 35 | 'limit' => { 36 | 'distros_per_page' => '30', 37 | 'files_git_run_bg' => '2000', 38 | 'files_per_search' => '60', 39 | 'search_context' => '5', 40 | 'search_context_distro' => '10', 41 | 'search_context_file' => '60' 42 | }, 43 | 'maxworkers' => '2', 44 | 'nocache' => '0', 45 | 'timeout' => { 46 | 'grep_search' => '900', 47 | 'user_search' => '18' 48 | } 49 | }; 50 | 51 | $grepcpan::VERSION = '1.00_01'; # devel version 52 | 53 | my $grep = GrepCpan::Grep->new( config => $config ); 54 | isa_ok $grep, 'GrepCpan::Grep'; 55 | 56 | #note explain config()->{'grepcpan'}; 57 | 58 | foreach my $k ( sort keys %$test_methods ) { 59 | can_ok $grep, $k; 60 | is $grep->can($k)->($grep), $test_methods->{$k}, "$k - default value"; 61 | 62 | #note $grep->can($k)->($grep); 63 | } 64 | 65 | ok -x $grep->git_binary, "git is executable"; 66 | 67 | like $grep->current_version, 68 | qr{^ 69 | [0-9]+\.[0-9_]+ 70 | -cache- 71 | [0-9]+\.[0-9]+ 72 | -cpan- 73 | [0-9a-f]+ 74 | $}xs, 75 | "current_version"; 76 | 77 | { 78 | my $valid_input = { 79 | 'distros/a/abbreviation/MANIFEST' => 80 | [ 'distros/a', 'abbreviation', 'MANIFEST' ], 81 | 'distros/a/accessors-fast/MANIFEST' => 82 | [ 'distros/a', 'accessors-fast', 'MANIFEST' ], 83 | 'distros/a/accessors/lib/accessors.pm' => 84 | [ 'distros/a', 'accessors', 'lib/accessors.pm' ], 85 | 'distros/e/eBay-API/eg/XML/getSearchResults.pl' => 86 | [ 'distros/e', 'eBay-API', 'eg/XML/getSearchResults.pl' ], 87 | 'distros/f/failures/lib/failures.pm' => 88 | [ 'distros/f', 'failures', 'lib/failures.pm' ], 89 | 'distros/f/fewer/Changes' => [ 'distros/f', 'fewer', 'Changes' ], 90 | 'distros/s/snapcast/LICENSE' => 91 | [ 'distros/s', 'snapcast', 'LICENSE' ], 92 | }; 93 | 94 | foreach my $input ( sort keys %$valid_input ) { 95 | is [ GrepCpan::Grep::massage_filepath($input) ] => 96 | $valid_input->{$input}, 97 | "massage_filepath($input)"; 98 | } 99 | 100 | } 101 | 102 | done_testing; 103 | -------------------------------------------------------------------------------- /src/t/grepcpan-config.t: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | BEGIN { 4 | use FindBin; 5 | unshift @INC, $FindBin::Bin . "/lib"; 6 | } 7 | 8 | use Test::Grep::MetaCPAN; 9 | 10 | package grepcpan; 11 | use Dancer2; 12 | 13 | package main; 14 | use strict; 15 | use warnings; 16 | 17 | use Test2::Bundle::Extended; 18 | use Test2::Tools::Explain; 19 | use Test2::Plugin::NoWarnings; 20 | 21 | use grepcpan; 22 | 23 | my $config = grepcpan::config()->{'grepcpan'}; 24 | 25 | #note explain $config; 26 | 27 | like $config, hash { 28 | 29 | #field binaries => like 30 | field demo => 0; 31 | field nocache => 0; 32 | field maxworkers => match(qr/^[0-9]+$/); 33 | 34 | field binaries => hash { 35 | field git => D(); 36 | }; 37 | 38 | field cache => hash { 39 | field directory => match(qr{^[~a-z\./]+$}i); 40 | field version => match(qr/^[0-9]+\.[0-9]+$/); 41 | }; 42 | 43 | field cookie => hash { 44 | field history_name => 'lastsearch'; 45 | field history_size => match(qr/^[0-9]+$/); 46 | }; 47 | 48 | }, 'config looks sane'; 49 | 50 | done_testing; 51 | -------------------------------------------------------------------------------- /src/t/lib/Test/Grep/MetaCPAN.pm: -------------------------------------------------------------------------------- 1 | package Test::Grep::MetaCPAN; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use Test::More; 7 | 8 | sub import { 9 | 10 | if ( $ENV{PLACK_ENV} ) { 11 | note "PLACK_ENV is already defined to: ", $ENV{PLACK_ENV}; 12 | } 13 | else { 14 | $ENV{PLACK_ENV} = 'unit-tests'; 15 | note "Set PLACK_ENV=", $ENV{PLACK_ENV}, " for testing"; 16 | } 17 | 18 | return; 19 | } 20 | 21 | 1; 22 | -------------------------------------------------------------------------------- /src/t/run-tests.sh: -------------------------------------------------------------------------------- 1 | #!bash 2 | 3 | set -ex 4 | 5 | ## 6 | ## install the extra test dependencies 7 | ## 8 | cd /cpan 9 | 10 | cpm install -g \ 11 | --with-test \ 12 | --with-recommends \ 13 | --with-develop \ 14 | --cpanfile cpanfile 15 | 16 | ## validate the git repository (for CI) 17 | git config --global --add safe.directory /metacpan-cpan-extracted 18 | 19 | ## 20 | ## run the tests 21 | ## 22 | cd /metacpan-grep-front-end 23 | 24 | export TABLE_TERM_SIZE=120 25 | 26 | prove -l -Ilib -r -v t -------------------------------------------------------------------------------- /src/views/404.tt: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 |
5 |

6 | 7 | /!\ 8 | Error <% status %> 9 |

10 |

<% message || "Not Found" %>

11 |
12 | -------------------------------------------------------------------------------- /src/views/_display.tt: -------------------------------------------------------------------------------- 1 | <% IF query.time_elapsed %> 2 | <% 3 | SET gram_sec = 'second';# : 'second'; 4 | SET gram_sec = 'seconds' IF query.time_elapsed >= 2; 5 | SET html_time_elapsed = "( run in ${query.time_elapsed} )"; 6 | SET html_time_elapsed_with_version = "( run in ${query.time_elapsed} $gram_sec using v${query.version} )"; 7 | %> 8 | <% END %> 9 |
10 |
11 | 14 |
15 | 16 |
17 |
18 | 19 |
20 |
21 | 22 |
23 |
24 | 25 |
26 |
27 | 28 | 29 |
30 |
31 | 32 |
33 |
34 | 35 |
36 |
37 | 38 |
39 |
40 | 41 | 42 |
43 |
44 | 47 | 50 | 53 |
54 |
55 |
56 |
57 | 58 | <% IF alert.danger %> 59 |
60 |
61 |
62 | <% alert.danger %> 63 |
64 |
65 |
66 | <% END %> 67 | 68 |
69 |
70 | 71 |
72 |
73 | 76 | <% IF query.results.size %> 77 |
78 | <% INCLUDE main/_pagination.tt %> 79 |
80 | <% END %> 81 | 82 |
83 | 84 | <% IF show_sumup %> 85 |
86 | Result: 87 |
88 | 89 | <% IF query.search_in_progress %> 90 | 91 | Your query is still running in background...Search in progress... 92 | at this time found <% query.match.distros %> distributions and <% query.match.files %> files matching your query. 93 |
Next refresh should show more results. 94 | <% ELSE %> 95 | <% IF query.is_incomplete %> 96 | found more than <% query.match.distros %> distributions - search limited to the first <% query.match.files %> files matching your query 97 | <% ELSE %> 98 | found <% query.match.distros %> distributions and <% query.match.files %> files matching your query ! 99 | <% END %> 100 | 101 | <% END # END of search_in_progress %> 102 | <% html_time_elapsed %> 103 |
104 |

105 | <% END %> 106 | 107 | <% INCLUDE "${subview}.tt" %> 108 | 109 | <% IF query.results.size || page > 1 %> 110 | <% INCLUDE main/_pagination.tt %> 111 |
<% html_time_elapsed_with_version %>
112 | <% END %> 113 |
114 |
115 |
116 |
117 |
118 | -------------------------------------------------------------------------------- /src/views/about.tt: -------------------------------------------------------------------------------- 1 |
2 |

About grep::metacpan

3 | 4 |

grep::metacpan is an open source search engine for the Comprehensive Perl Archive 5 | Network (CPAN), an ever growing archive of code and 6 | documentation for the Perl programming language. This includes a 7 | comfortable web-based view and a first class mirror of the canonical 8 | CPAN content.

9 | 10 |

This is Yet Another project for searching the CPAN.

11 | 12 |

This is not the first attempt to provide a grep through all CPAN distributions, 13 | but we hope you'll find it helpful. You should also try the original 14 | grep.cpan.me which uses a Redis database as backend. 15 |

16 | 17 |

This project is purely experimental. The goal is to see how 'git grep' can compete with a more 18 | traditional database approach. One of its main advantages is that it's easy to deploy on a standalone server/workstation. 19 | The drawback is that it can be *slow*... but you might be surprised by how fast it can be for some searches. :-) 20 | The more frequently a term is searched for, the faster the grep for that term gets. 21 |

22 | 23 | 24 |

Using grep::metacpan

25 | 26 |

You can consume grep::metacpan in two different ways:

27 | 28 | 32 | 33 |

Read more about how the code is organized by reading our GitHub repositories introduction. 34 | 35 |

(grep::)?MetaCPAN is a community effort. The original idea came about when Todd R. was working on the 'dot removal from @INC' (and grep.cpan.me wasn't available at that particular time).

36 | 37 | 38 |

Help wanted

39 | 40 |

We are always in need of more contributors, so feel free to submit merge request to one of our source code repositories.

41 | 42 | 43 | 44 |

45 | The logo was stolen from metacpan, which came from Raul Matei who won the MetaCPAN logo competition 46 | (sponsored by the Enlightened Perl Organization) with his entry. 47 | 48 |
Babs V. kindly provided an altered version for this grep::metacpan website :-) 49 | 50 |

51 | 52 | 53 |
54 | -------------------------------------------------------------------------------- /src/views/api.tt: -------------------------------------------------------------------------------- 1 |
2 |

API 101

3 | 4 |

5 | The API is currently in its first version and very naive / limited, but it exists... 6 | the API is not versionned yet, but if a number should be picked '0.0' will be the best match, this gives you an idea of how far you can go with it. 7 |

8 | 9 |

Basic concepts

10 |

11 | The API is built around these simple concepts: 12 |

    13 |
  • simple http GET queries
  • 14 |
  • the output format is JSON
  • 15 |
  • just add the '/api' prefix to any of your search, and you should be to go !
  • 16 |
17 | 18 | Here is a simple example: 19 | 20 | if you are browsing grep.metacpan.org, just copy paste your URL which should looks like this 21 |
 22 | 	https://grep.metacpan.org/api/search?q=test&qd=&qft=
 23 | 
24 | 25 | You just want to add the /api/ prefix to your URI 26 |
 27 | 	curl -X GET 'https://grep.metacpan.org/api/search?q=test&qd=&qft' | json
 28 | 
29 | 30 |

31 | 32 |

The Output Format

33 | 34 | The format is not definitive and still in an early stage development, but here's what it should looks like 35 | 36 |

Keys used at the main level of the output format

37 |
    38 |
  • results: array which contains all the matching informations
  • 39 |
  • is_incomplete: boolean which tell you if the request was truncated (after 2000 files), or if it contains all result from CPAN
  • 40 |
  • search_in_progress: boolean to tell you if you need to query it a little later, as the query might still be running in background
  • 41 |
  • time_elapsed: time in seconds to render the request
  • 42 |
  • is_a_known_distro: boolean to tell you if the distro filter matches a known CPAN distribution
  • 43 |
  • match: quick sumup metrics for your query
  • 44 |
45 | 46 |

The results values

47 | The match of your query are stored in the results array at the main level. 48 | This is a list hashes of all matching results. Where each hash describes the results 49 | for a specific distribution. 50 | 51 | The format of a distribution result is the following: 52 |
    53 |
  • files: list of all files for this distribution matching your query
  • 54 |
  • matches: list of array representing all matching codeblocks for a file
  • 55 |
  • prefix: distribution filepath on disk
  • 56 |
  • distro: distribution name
  • 57 |
58 | 59 |

Codeblock structure

60 | A codeblock represent the output of git grep with some context, 61 | so we need to indicate which line is the first one in the code extract 62 | and which lines are the one matching your query. 63 |
    64 |
  • matchlines: array of integers listing all the file line number matching the query.
  • 65 |
  • code: code extract for the match with some context
  • 66 |
  • start_at: integer indicating the first line number in the code extract
  • 67 |
68 | 69 |

The sumup statistics

70 | Basic metrics about your query, you can know how many distributions and files match your query. 71 | 72 |
    73 |
  • distros: integer value with the number of total distributions matching your query
  • 74 |
  • files: integer value with the number of total files matching your query
  • 75 |
76 | 77 |

Sample output format

78 |
 79 | {
 80 |   "results": [
 81 |     {
 82 |       "files": [
 83 |         "MANIFEST",
 84 |         "t/test.t"
 85 |       ],
 86 |       "matches": [
 87 |         {
 88 |           "blocks": [
 89 |             {
 90 |               "matchlines": [
 91 |                 "6",
 92 |                 "7",
 93 |                 "8",
 94 |                 "9",
 95 |                 "10"
 96 |               ],
 97 |               "code": "Changes\nMANIFEST\nMakefile.PL\nREADME\nlib/abbreviation.pm\nt/test.t\ntestlib/CAPS/On.pm\ntestlib/Foo.pm\ntestlib/FooBar/Baz.pm\ntestlib/FooBar/Baz/Doh.pm\n",
 98 |               "start_at": "1"
 99 |             }
100 |           ],
101 |           "file": "MANIFEST"
102 |         }
103 |       ],
104 |       "prefix": "distros/a/abbreviation",
105 |       "distro": "abbreviation"
106 |     },
107 |     ... --- additional results where cut from there ---
108 |   ],
109 |   "is_incomplete": 0,
110 |   "search_in_progress": 0,
111 |   "time_elapsed": 0.016502,
112 |   "is_a_known_distro": "",
113 |   "match": {
114 |     "files": "64",
115 |     "distros": "7"
116 |   }
117 | }
118 | 
119 | 120 | 121 |

Adding a filter to your query

122 | 123 | Here are the valid parameters for your http query: 124 | 125 |
    126 |
  • q: string for the query pattern (required)
  • 127 |
  • qci: boolean 0 or 1 for a case insensitive search (optional - default 0)
  • 128 |
  • qd: string for the distribution filter pattern (optional)
  • 129 |
  • qft: string for the file type filter pattern (optional)
  • 130 |
  • f: string for a specific file name filter pattern (optional)
  • 131 |
  • p: integer for the page number. As the WebUI this is using pagination (optional - default 1)
  • 132 |
133 | 134 |
135 | Some API queries samples: 136 |
137 | - search for 'test' among all CPAN distributions: 138 | /api/search?q=test 139 |
140 | - case insensitive search for 'test' among all CPAN distributions: 141 | /api/search?q=test&qci=1 142 |
143 | - search for 'test' among all distributions matching '*snap*': 144 | /api/search?q=test&qd=*snap* 145 |
146 | 147 |

Thumb Rules

148 | 149 |

Use it, but do not abuse it for now, or at your own risks :-) Try to be a good citizen. 150 | This is not designed on the same architecture than fastapi.metacpan.org... 151 |

152 | 153 |
-------------------------------------------------------------------------------- /src/views/faq.tt: -------------------------------------------------------------------------------- 1 |
2 |

Frequently Asked Questions about grep.cpan

3 | 4 | 5 |

6 | Why grepcpan is slow ? 7 |
8 | short answer: this is a *young* experimental project using a 17Gb git repository with about a 1.5Gb index... this is pushing git to the limit... 9 |
10 | read the source code description page to have a better idea of the internal implementation. 11 |

12 | 13 |

14 | Can I user Regular Expression in my query ? 15 |
16 | yes you can ! we are using a 'git grep -P', which mean you can use the power of perl Regular Expression in your queries. 17 |

18 | 19 |

20 | What about UniCode characters ? 21 |
22 | no, you cannot use directly unicode as part of your query but you can use code points. 23 |
24 | more details from perlunicode manual 25 |

26 | 27 | 28 |

29 | Any other questions ? 30 |
31 | join us on IRC @irc.perl.org channel #metacpan 32 |
33 | new to IRC ? go to www.irc.perl.org 34 |

35 | 36 | 37 |
-------------------------------------------------------------------------------- /src/views/index.tt: -------------------------------------------------------------------------------- 1 | <% USE Math; %> 2 | 3 |
4 | 5 |
6 |
7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 |
15 | 16 | 17 |
18 | 19 | 20 |
21 | 22 | 23 |
24 | 25 | 26 |
27 | 28 | 29 |
30 | 31 | 32 |
33 | 34 | 35 |
36 | 37 |
38 | 42 |
43 |
44 | 45 | 46 | 47 | 48 |
49 | 50 |
51 | 55 |
56 |
57 | 58 | 59 |
60 | 61 |
62 | 66 |
67 |
68 | 69 |
70 | 71 |
72 |
73 |
74 | 75 |
76 |
77 |
78 | Info: search is using a copy of CPAN from <% cpan_index_at | html %> 79 |
80 |
81 |
82 | 83 |
84 | 85 | 90 | -------------------------------------------------------------------------------- /src/views/layouts/main.tt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <% IF search; THEN %> 6 | <% search | html %> results from the CPAN 7 | <% ELSIF title %> 8 | <% title %> - Let's grep the CPAN together 9 | <% ELSE %> 10 | Let's grep the CPAN together: search a pattern among all perl distributions 11 | <% END %> 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 31 | 32 | 33 | <% INCLUDE main/_header.tt %> 34 |
35 |
36 |
37 | <% content %> 38 |
39 |
40 |
41 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /src/views/list-files.tt: -------------------------------------------------------------------------------- 1 | <% INCLUDE '_display.tt' 2 | subview = 'show-ls' 3 | %> -------------------------------------------------------------------------------- /src/views/main/_header.tt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/views/main/_last_search.tt: -------------------------------------------------------------------------------- 1 | <% IF last_searches && last_searches.size %> 2 |
3 | 4 |
  • 5 |
    6 | 11 |
    12 |
  • 13 |
    14 | <% END %> -------------------------------------------------------------------------------- /src/views/main/_pagination.tt: -------------------------------------------------------------------------------- 1 | <% IF !nopagination %> 2 | <% 3 | USE pagination_uri = URL('/search', qd=qd, qft=qft, qci=qci, q=search, qls=qls, qifl=qifl ); 4 | %> 5 | 6 |
    7 |
      8 | <% SET pagefrom = ( page div 10 ) * 10 || 1; %> 9 | <% SET pageto = query.results.size ? pagefrom + 10 : pagefrom %> 10 | <% SET lastpage = (query.match.distros || 0 ) div 30 + 1 %> 11 | <% IF pageto > lastpage %> 12 | <% pageto = lastpage < pagefrom ? pagefrom : lastpage %> 13 | <% SET disable_next_p = 1 %> 14 | <% END %> 15 | <% IF page < 10 # disable pagination « %> 16 |
    • 17 | « 18 |
    • 19 | <% ELSE %> 20 |
    • 21 | « 22 |
    • 23 | <% END %> 24 | <% IF query.results.size %> 25 | <% FOREACH p in [ pagefrom..pageto] %> 26 | <% IF p == page %> 27 |
    • 28 | <% ELSE %> 29 |
    • 30 | <% END %> 31 | <% p %> 32 |
    • 33 | <% END %> 34 | <%IF disable_next_p # disable pagination » %> 35 |
    • 36 | » 37 |
    • 38 | <% ELSE %> 39 |
    • 40 | » 41 |
    • 42 | <% END %> 43 | <% END # end check query.results.size %> 44 |
    45 |
    46 | 47 | <% END %> -------------------------------------------------------------------------------- /src/views/search.tt: -------------------------------------------------------------------------------- 1 | <% INCLUDE '_display.tt' 2 | subview = 'show-search' 3 | %> 4 | -------------------------------------------------------------------------------- /src/views/show-ls.tt: -------------------------------------------------------------------------------- 1 | <% FOREACH item IN query.results %> 2 | 3 | 4 | <% 5 | l2d_qci = qci | html_entity; 6 | l2d_q = search | html_entity; 7 | l2d_qd = item.distro | html_entity; 8 | l2d_qft = qft | html_entity; 9 | l2d_qls = qls | html_entity; 10 | l2d_qifl = qifl | html_entity; 11 | 12 | SET link_to_distro = "/search?qci=${l2d_qci}&q=${l2d_q}&qft=${l2d_qft}&qd=${l2d_qd}&qls=${l2d_qls}&qifl=${l2d_qifl}"; 13 | SET link_withmatch = "/search?qci=${l2d_qci}&q=${l2d_q}&qft=${l2d_qft}&qd=${l2d_qd}&qls=0&qifl=${l2d_qifl}"; 14 | %> 15 |
    16 | 17 | <% item.distro | html %> 18 | 19 | 23 | 24 |
    25 |

    26 | 27 | <% IF qd %> 28 | 29 | <% FOREACH match IN item.matches %> 30 |

    31 | <% match.file %> 32 |

    33 | <% END %> 34 | 35 | <% END # fi %> 36 | 37 |
    38 | 39 | <% END # foreach query.results %> 40 | -------------------------------------------------------------------------------- /src/views/show-search.tt: -------------------------------------------------------------------------------- 1 | <% FOREACH item IN query.results %> 2 | 3 | <% 4 | l2d_qci = qci | uri; 5 | l2d_q = search | uri; 6 | l2d_qd = item.distro | uri; 7 | l2d_qft = qft | uri; 8 | l2d_qifl = qifl | html_entity; 9 | 10 | SET link_to_distro = "/search?qci=${l2d_qci}&q=${l2d_q}&qft=${l2d_qft}&qd=${l2d_qd}&=l2d_qifl=${l2d_qifl}"; 11 | %> 12 |
    13 | 14 | <% item.distro | html %> 15 | 16 | 20 | 21 |
    22 |

    23 | 24 |

    25 |  view release on metacpan 26 | or  search on metacpan 27 |

    28 | 29 | <% FOREACH match IN item.matches %> 30 | <% 31 | SET line = 0; 32 | IF match.blocks && match.blocks.0 && match.blocks.0.matchlines && match.blocks.0.matchlines.0; 33 | line = match.blocks.0.matchlines.0; 34 | END; 35 | %> 36 |

    37 | <% match.file %> 38 |  view on Meta::CPAN 39 | <% FOREACH bl IN match.blocks %> 40 |

    <%= bl.code | html_entity -%>
    41 | <% END %> 42 |

    43 | <% END %> 44 | 45 | <% IF qd != item.distro %> 46 |  view all matches for this distribution
    47 | <% IF qd && qd.length && item.matches.size %> 48 |  view release on metacpan 49 | -  search on metacpan 50 | <% END %> 51 | <% END %> 52 | 53 | <% item.version %> 54 |
    55 | 56 |
    57 |
    58 | 59 | <% END # foreach query.results %> 60 | -------------------------------------------------------------------------------- /src/views/source-code.tt: -------------------------------------------------------------------------------- 1 |
    2 |

    Where to find the source code of grep::metacpan ?

    3 | 4 |

    grep::metacpan is an open source experimental project developped by the Perl Community. 5 | 6 |

    The source code is divided into three git repositories:

    7 | 8 | <% 9 | 10 | SET gh_metacpan_grep_front_end = ' metacpan-grep-front-end'; 11 | SET gh_metacpan_grep_builder = ' metacpan-grep-builder'; 12 | SET gh_metacpan_cpan_extracted = ' metacpan-cpan-extracted'; 13 | 14 | %> 15 | 16 |
      17 |
    • <% gh_metacpan_grep_front_end %>, the Front End website which is this website...
    • 18 |
    • <% gh_metacpan_grep_builder %> experiment on building a git grep service of current CPAN.
    • 19 |
    • <% gh_metacpan_cpan_extracted %> extracted CPAN, all latest files extracted in one single *big* repository. Thanks GitHub !
    • 20 |
    21 | 22 |

    The concept is very basic: extract all CPAN distribution (performed by <% gh_metacpan_grep_builder %>) in one single git directory (which lives in <% gh_metacpan_cpan_extracted %>). 23 |

    24 |

    25 | Then from there, cross fingers and use a pure 'git grep' implementation with a frontend on top of it: <% gh_metacpan_grep_front_end %>. 26 |

    27 |

    28 | The git grep is divided in two stages: 'git grep -l' to get the list 29 | of files matching the pattern (this is cached for future queries), then use the list of files to perform the actual 'git grep'. 30 |

    31 | 32 | You can also browse other metacpan projects by visiting the community github homepage. 33 |
    34 | -------------------------------------------------------------------------------- /tools/pre-commit.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | # Hack to use carton's local::lib. 7 | use lib 'local/lib/perl5'; 8 | 9 | use Test::More; 10 | 11 | exit( run() // 0 ) unless caller; 12 | 13 | sub run { 14 | 15 | if ( -e '/tmp/nohook' ) { 16 | note "skipping pre-commit hook: /tmp/nohook file exists"; 17 | return 0; 18 | } 19 | 20 | note "1 - Trimming spaces"; 21 | trim_spaces(); 22 | note "done"; 23 | note ""; 24 | 25 | note "2 - tidy code"; 26 | tidyall_do(); 27 | note "done"; 28 | note ""; 29 | 30 | note "3 - tidy/perlcritic check"; 31 | tidyall_check(); 32 | note "done"; 33 | 34 | } 35 | 36 | # rules 37 | sub trim_spaces { 38 | my $files = list_txt_files(); 39 | 40 | my $mksum; 41 | foreach (qw{ md5sum shasum }) { 42 | $mksum = qx{which $_ 2>/dev/null}; 43 | if ( $? == 0 ) { 44 | chomp $mksum if $mksum; 45 | last; 46 | } 47 | } 48 | 49 | do { note "skipping trim spaces... no mksum"; return } 50 | unless $mksum && -x $mksum; 51 | 52 | foreach my $file (@$files) { 53 | my $md5a = qx[$mksum $file]; 54 | qx[$^X -pi -e 's{ +\$}{}' $file]; 55 | my $md5b = qx[$mksum $file]; 56 | if ( $md5a ne $md5b ) { 57 | note "Removed trailing spaces from '$file'"; 58 | qx{git update-index --add $file}; 59 | } 60 | } 61 | } 62 | 63 | sub tidyall_do { 64 | my $tidyall = qx{which tidyall}; 65 | if ( $? != 0 && !$tidyall && !-x $tidyall ) { 66 | warn "Missing tidyall binary... skipping tidyall_do"; 67 | } 68 | 69 | my $files = list_perl_files(); 70 | push @$files, '.gitignore'; # need to sort it 71 | foreach my $file (@$files) { 72 | my $out = qx{tidyall $file}; 73 | note $out; 74 | if ( $out && $out =~ qr{tidied} ) { 75 | qx{git update-index --add $file}; 76 | } 77 | } 78 | 79 | } 80 | 81 | sub tidyall_check { # this is only a check 82 | eval { require Code::TidyAll::Git::Precommit; } or do { 83 | warn 84 | "Missing module Code::TidyAll::Git::Precommit - cannot run tidyall_check\n"; 85 | return 1; 86 | }; 87 | 88 | note "starting Git::Precommit"; 89 | Code::TidyAll::Git::Precommit->check(); 90 | 91 | return; 92 | } 93 | 94 | # helper 95 | sub list_perl_files { 96 | return list_txt_files('perl'); 97 | } 98 | 99 | sub list_txt_files { 100 | my ($filter) = @_; 101 | 102 | my @list; 103 | 104 | my @files = qx[ git diff --cached --name-status]; 105 | chomp @files; 106 | my $ok; 107 | foreach my $file ( sort @files ) { 108 | next unless $file =~ s{^[AM]\s+}{}; 109 | 110 | $ok = 0; 111 | if ( $file =~ qr{\.( t | pm | pl | psgi )$}xi ) { 112 | $ok = 1; 113 | next; 114 | } 115 | next if $filter && $filter eq 'perl'; # only perl files for perl 116 | my $type = qx{file $file}; 117 | next if $? != 0; 118 | $ok = 1 if $type =~ qr{text}; 119 | } 120 | continue { 121 | push @list, $file if $ok; 122 | } 123 | 124 | #note explain \@list; 125 | 126 | return \@list; 127 | } 128 | -------------------------------------------------------------------------------- /tools/update-assets.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use v5.036; 4 | 5 | use FindBin; 6 | use Git::Repository (); 7 | use Pod::Usage; 8 | use Test::More; 9 | 10 | =head1 NAME 11 | 12 | update-assets.pl - Asset versioning tool for the MetaCPAN Grep Frontend 13 | 14 | =head1 SYNOPSIS 15 | 16 | # Run the script to update and timestamp all assets 17 | ./tools/update-assets.pl 18 | 19 | =head1 DESCRIPTION 20 | 21 | This script implements a cache-busting strategy for web assets by: 22 | 23 | 1. Finding all CSS/JS assets referenced in HTML and view files 24 | 2. Creating new copies with timestamp-based filenames (YYYYMMDDHHMMSS-filename.js) 25 | 3. Updating all references in source files to point to the new timestamped versions 26 | 4. Removing the old asset files 27 | 5. Committing all changes to Git 28 | 29 | The script helps ensure that users always receive the latest version of assets 30 | when changes are deployed, preventing browsers from using cached outdated versions. 31 | 32 | =head1 PROCESS 33 | 34 | The script: 35 | 36 | 1. Uses Git to find all references to assets in /_assets/ directory 37 | 2. For each asset found: 38 | - Creates a new copy with a timestamp prefix 39 | - Uses sed to replace all references in source files 40 | - Adds new files to Git and removes old ones 41 | 3. Commits all changes with a message "Bump assets to TIMESTAMP" 42 | 43 | =head1 REQUIREMENTS 44 | 45 | - Git::Repository Perl module 46 | - Command-line access to Git repository 47 | - Unix-like environment (uses sed) 48 | 49 | =head1 AUTHOR 50 | 51 | MetaCPAN Team 52 | 53 | =cut 54 | 55 | exit( run(@ARGV) // 0 ) unless caller(); 56 | 57 | sub run(@args) { 58 | 59 | if ( grep { $_ eq '--help' || $_ eq '-h' } @args ) { 60 | return pod2usage( -verbose => 2, -exitval => 0 ); 61 | } 62 | 63 | my $root = $FindBin::Bin . q{/..}; 64 | 65 | my $git = Git::Repository->new( work_tree => $root ); 66 | 67 | my @out = $git->run( 'grep', q{/_assets/}, map {"src/$_"} 'views', 68 | 'public/*.html' ); 69 | 70 | my %assets; 71 | 72 | foreach my $line (@out) { 73 | my ( $file, $line ) = split( q{:}, $line, 2 ); 74 | if ( $line =~ qr{/_assets/([a-zA-Z0-9-]+\.(css|js))} ) { 75 | my $asset = $1; 76 | if ( !exists $assets{$asset} ) { 77 | $assets{$asset} 78 | = -e qq{$root/src/public/_assets/$asset} ? {} : 0; 79 | } 80 | next if !$assets{$asset}; 81 | $assets{$asset}->{$file} = 1; # only tag the file once 82 | } 83 | } 84 | 85 | chdir($root) or die; 86 | 87 | my $ts = qx{date "+%Y%m%d%H%M%S"}; 88 | chomp $ts; 89 | 90 | die unless $ts; 91 | my $ok; 92 | 93 | foreach my $asset ( sort keys %assets ) { 94 | next unless ref $assets{$asset}; 95 | my ( $prefix, $base ) = split( '-', $asset, 2 ); 96 | $base = $prefix if !defined $base; 97 | my $new = qq{/_assets/$ts-$base}; 98 | my $new_asset_file = qq{$root/src/public/$new}; 99 | my $old_asset = "$root/src/public/_assets/$asset"; 100 | system( 'cp', $old_asset, $new_asset_file ) == 0 101 | or die; 102 | 103 | my $cmd = qq{sed -i -e "s|/_assets/$asset|$new|g" } 104 | . join( ' ', sort keys %{ $assets{$asset} } ); 105 | qx{$cmd}; 106 | warn "Error: $cmd - $!" if $? != 0; 107 | 108 | $git->run( 'add', $new_asset_file, sort keys %{ $assets{$asset} } ); 109 | $git->run( 'rm', $old_asset ); 110 | 111 | foreach my $f ( sort keys %{ $assets{$asset} } ) { 112 | my $_e = $f . q{-e}; 113 | unlink $_e if -e $_e; 114 | } 115 | $ok = 1; 116 | } 117 | 118 | if ($ok) { 119 | $git->run( 'commit', '-m', "Bump assets to $ts" ) 120 | or die "Error while committing"; 121 | note qq{Assets updated to: $ts}; 122 | note scalar $git->run( 'show', '--stat', '-n1' ); 123 | } 124 | else { 125 | note q{Nothing to do}; 126 | } 127 | 128 | return; 129 | } 130 | 131 | --------------------------------------------------------------------------------