├── favicon.png ├── verdana.ttf ├── .htaccess ├── nginx-shields.conf ├── README.md ├── api.php ├── index.html └── 404.html /favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hustcc/simple-shields/HEAD/favicon.png -------------------------------------------------------------------------------- /verdana.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hustcc/simple-shields/HEAD/verdana.ttf -------------------------------------------------------------------------------- /.htaccess: -------------------------------------------------------------------------------- 1 | ErrorDocument 404 /404.html 2 | 3 | RewriteEngine On 4 | 5 | RewriteRule ^(.*)-(.*)-([a-zA-Z]{1,20}|[a-f0-9]{3}|[a-f0-9]{6}).svg$ api.php?subject=$1&status=$2&color=$3 -------------------------------------------------------------------------------- /nginx-shields.conf: -------------------------------------------------------------------------------- 1 | server 2 | { 3 | listen 80; 4 | server_name shields.hust.cc; 5 | index index.html index.php; 6 | root /home/wwwroot/simple-shields/; 7 | 8 | include enable-php.conf; 9 | 10 | location / { 11 | root /home/wwwroot/simple-shields/; 12 | index index.html index.php; 13 | } 14 | 15 | location ~* "^/(.*)-(.*)-([a-zA-Z]{1,20}|[a-f0-9]{3}|[a-f0-9]{6}).svg$" { 16 | try_files $uri $uri/ /api.php?subject=$1&status=$2&color=$3; 17 | } 18 | 19 | error_page 404 /404.html; 20 | access_log /home/wwwlogs/access.log access; 21 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Simple Shields 2 | 3 | > A very simple, stable, easy deploy `Shields badge service` with PHP & SVG. Inspired by Shields IO. 4 | 5 | ![http://shields.hust.cc/](http://shields.hust.cc/Badge-Shields-orange.svg) 6 | ![http://shields.hust.cc/](http://shields.hust.cc/Shields-Perfect-green.svg) 7 | ![http://shields.hust.cc/](http://shields.hust.cc/Shields-Simple-yellow.svg) 8 | ![http://shields.hust.cc/](http://shields.hust.cc/Shields-Stable-blue.svg) 9 | ![http://shields.hust.cc/](http://shields.hust.cc/Shields-EasyDeploy-ff69b4.svg) 10 | 11 | 12 | ![http://shields.hust.cc/](http://shields.hust.cc/亲爱的-么么哒-orange.svg) 13 | ![http://shields.hust.cc/](http://shields.hust.cc/Hustcc-( ˘ ³˘)♥-ff69b4.svg) 14 | 15 | - **Shields.IO style**. Pixel-perfect, Retina-ready, Fast, Consistent, Hackable, No tracking. 16 | - Really **Simple**, only one PHP file with 60 rows, no dependence. 17 | - **Easy deploy** and **Stable**, Apache or nginx. 18 | 19 | 20 | ## 1. How to Use ? 21 | 22 | > The url format: **http://shields.hust.cc/SUBJECT-STATUS-COLOR.svg** 23 | 24 | - **subject**: the left part TEXT of shields. 25 | - **status**: the right part TEXT of shields. 26 | - **color**: the right part COLOR of shields. `red`, `orange`, `yellow`, `brightgreen`, `green`, `yellowgreen`, `blue`, `grey`, `lightgrey` are optional color name, or you can use `RGB` color, e.g. ff69b4. 27 | 28 | 29 | ## 2. Deploy your Own service 30 | 31 | 1. Download the code, put it into the `apache` or `nginx` website dir. 32 | 2. Add vhost on apache or nginx. 33 | 3. **optional step**: Config the url rewrite. use `.htaccess` on apache([here is the file](.htaccess)), use `location config` on nginx([here is the file](nginx-shields.conf)). 34 | 4. Binding you domain. 35 | 36 | **MEMO**: if you don't rewrite url, you can use **http://you-domain/api.php?subject=SUBJECT&status=STATUS&color=COLOR** 37 | 38 | 39 | ## 3. Contribution 40 | 41 | - Fork the repo. 42 | - Add your code, and pull a request. 43 | - Or add a issue. 44 | 45 | Thanks for Shields IO, inspired by it. The 404 page from internet. 46 | 47 | 48 | ## LICENSE 49 | 50 | MIT@hustcc 51 | -------------------------------------------------------------------------------- /api.php: -------------------------------------------------------------------------------- 1 | 'e05d44', 15 | 'orange' => 'fe7d37', 16 | 'yellow' => 'dfb317', 17 | 'brightgreen' => '4c1', 18 | 'green' => '97ca00', 19 | 'yellowgreen' => 'a4a61d', 20 | 'blue' => '007ec6', 21 | 'grey' => '555', 22 | 'lightgrey' => '9f9f9f' 23 | ); 24 | return isset($colors[$color_name]) ? $colors[$color_name] : null; 25 | } 26 | 27 | // get the GET paramters 28 | $subject = isset($_GET['subject']) ? $_GET['subject']: 'shields'; 29 | $status = isset($_GET['status']) ? $_GET['status']: 'passing'; 30 | $color = isset($_GET['color']) ? $_GET['color']: 'lightgrey'; 31 | // chang color name to rgb 32 | $color_tmp = textColor($color); 33 | if ($color_tmp) { 34 | $color = $color_tmp; 35 | } 36 | 37 | // measure the text width 38 | $subject_width = measureTextWidth($subject); 39 | $status_width = measureTextWidth($status); 40 | 41 | $margin = 0; // left right 42 | $gap = 0; // center 43 | 44 | $left_width = $subject_width + $margin + $gap; // margin(4) + gap(2) 45 | $right_width = $status_width + $margin + $gap; // margin(4) + gap(2) 46 | 47 | $subject_x = $subject_width / 2 + $margin; // margin(4) 48 | $status_x = $subject_width + $status_width / 2 + $margin + $gap * 2; // margin(4) + gap(2) * 2 49 | 50 | $width = $left_width + $right_width; 51 | 52 | echo 53 | ' 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | ' . $subject . ' 68 | ' . $subject . ' 69 | ' . $status . ' 70 | ' . $status . ' 71 | 72 | '; 73 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Shield Badges Service: Quality metadata badges for open source projects 6 | 7 | 8 | 9 | 10 | 11 | 32 | 33 | 34 | 35 |
36 |

Shields Service

37 |

38 | simple-shields: a simple shields badge service. 39 |

40 |

41 | Stable   Easy Deploy   Fast   Simple   Retina-ready   No tracking 42 |

43 | 44 |

Your Badges

45 |
46 | 47 | 48 | 49 | 50 | 59 | 60 |
61 | 62 |

63 | http://shields.hust.cc/<SUBJECT>-<STATUS>-<COLOR>.svg 64 |

65 | 66 |
67 |

Color Style

68 |

69 | brightgreen 70 | green 71 | yellowgreen 72 | yellow 73 | orange 74 | red 75 | lightgrey 76 | blue 77 | ff69b4 78 |

79 |
80 |

81 | ff69b4 82 | green 83 | yellowgreen 84 | yellow 85 | orange 86 | brightgreen 87 | lightgrey 88 | blue 89 |

90 |
91 |

Like This?

92 |

93 | Tell your favorite badge service to use it!
94 | And tell us, we might be able to bring it to you anyway! Code is here 95 |

96 |
97 | 111 | 112 | -------------------------------------------------------------------------------- /404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Badge-Shields 404 ! 6 | 7 | 8 | 27 | 28 | 29 |
30 | 31 |
32 | 33 | --------------------------------------------------------------------------------