Skip to content

Commit 06e0000

Browse files
committed
wip
1 parent c9474f2 commit 06e0000

22 files changed

+184
-262
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
All notable changes to `:package_name` will be documented in this file
3+
All notable changes to `github-view-counter` will be documented in this file
44

55
## 1.0.0 - 202X-XX-XX
66

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) Spatie bvba <[email protected]>
3+
Copyright (c) Caneco bvba <[email protected]>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+21-38
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,39 @@
1-
# :package_description
1+
# Laravel GitHub Profile Visit Counter
22

3-
[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/:package_name.svg?style=flat-square)](https://packagist.org/packages/spatie/:package_name)
4-
[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/spatie/:package_name/run-tests?label=tests)](https://github.com/spatie/:package_name/actions?query=workflow%3Arun-tests+branch%3Amaster)
5-
[![Total Downloads](https://img.shields.io/packagist/dt/spatie/:package_name.svg?style=flat-square)](https://packagist.org/packages/spatie/:package_name)
3+
<p align="center">
4+
<img src="/art/socialcard.png" width="1280" title="Social Card Laravel GitHub Profile View Counter">
5+
<p align="center">
6+
<a href="https://packagist.org/packages/caneco/laravel-github-profile-view-counter"><img alt="Total Downloads" src="https://img.shields.io/packagist/dt/caneco/laravel-github-profile-view-counter"></a>
7+
<a href="https://packagist.org/packages/caneco/laravel-github-profile-view-counter"><img alt="License" src="https://img.shields.io/packagist/l/caneco/laravel-github-profile-view-counter"></a>
8+
</p>
9+
</p>
610

7-
**Note:** Replace ```:author_name``` ```:author_username``` ```:author_email``` ```:package_name``` ```:package_description``` with their correct values in [README.md](README.md), [CHANGELOG.md](CHANGELOG.md), [CONTRIBUTING.md](CONTRIBUTING.md), [LICENSE.md](LICENSE.md) and [composer.json](composer.json) files, then delete this line. You can also run `configure-skeleton.sh` to do this automatically.
11+
This package will allows you to track Github profile views and display them in your profile readme, for free.
812

9-
This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
10-
11-
## Support us
12-
13-
Learn how to create a package like this one, by watching our premium video course:
14-
15-
[![Laravel Package training](https://spatie.be/github/package-training.jpg)](https://laravelpackage.training)
16-
17-
We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).
18-
19-
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).
13+
This package was inspired Artem Golubin's post [**How to track and display profile views on GitHub**](https://rushter.com/blog/github-profile-markdown/).
2014

2115
## Installation
2216

2317
You can install the package via composer:
2418

2519
```bash
26-
composer require spatie/package-skeleton-laravel
20+
composer require caneco/laravel-github-profile-view-counter
2721
```
2822

2923
You can publish and run the migrations with:
3024

3125
```bash
32-
php artisan vendor:publish --provider="Spatie\Skeleton\SkeletonServiceProvider" --tag="migrations"
26+
php artisan vendor:publish --provider="Caneco\GithubProfileViewCounter\GithubProfileViewCounterServiceProvider" --tag="migrations"
3327
php artisan migrate
3428
```
3529

36-
You can publish the config file with:
37-
```bash
38-
php artisan vendor:publish --provider="Spatie\Skeleton\SkeletonServiceProvider" --tag="config"
39-
```
40-
41-
This is the contents of the published config file:
30+
## Usage
4231

43-
```php
44-
return [
45-
];
46-
```
32+
Just visit `yourdomain.com/github-profile-view-counter.svg`, you should see your badge with `visits++`.
4733

48-
## Usage
34+
## Cheating
4935

50-
``` php
51-
$skeleton = new Spatie\Skeleton();
52-
echo $skeleton->echoPhrase('Hello, Spatie!');
53-
```
36+
You can always fill your table with a lot of rows to make yourself famous! **But, play nice** 😉.
5437

5538
## Testing
5639

@@ -66,15 +49,15 @@ Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed re
6649

6750
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
6851

69-
## Security
70-
71-
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
72-
7352
## Credits
7453

75-
- [:author_name](https://github.com/:author_username)
54+
- [Caneco](https://github.com/caneco)
7655
- [All Contributors](../../contributors)
7756

7857
## License
7958

8059
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
60+
61+
## Thanks
62+
63+
Thanks to Spatie to make damn easy to create a new package. Please do check their [`spatie/package-skeleton-laravel`](https://github.com/spatie/package-skeleton-laravel).

art/socialcard.png

92.3 KB
Loading

composer.json

+11-18
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
{
2-
"name": "spatie/:package_name",
3-
"description": ":package_description",
4-
"keywords": [
5-
"spatie",
6-
":package_name"
7-
],
8-
"homepage": "https://github.com/spatie/:package_name",
2+
"name": "caneco/laravel-github-profile-view-counter",
3+
"description": "Track and display profile views on your GitHub profile.",
4+
"keywords": ["laravel", "github", "readme", "track", "webcounter"],
5+
"homepage": "https://github.com/caneco/laravel-github-profile-view-counter",
96
"license": "MIT",
107
"authors": [
118
{
12-
"name": ":author_name",
13-
"email": ":author_email",
14-
"homepage": "https://spatie.be",
9+
"name": "Caneco",
10+
"homepage": "https://caneco.dev",
1511
"role": "Developer"
1612
}
1713
],
@@ -27,12 +23,12 @@
2723
},
2824
"autoload": {
2925
"psr-4": {
30-
"Spatie\\Skeleton\\": "src"
26+
"Caneco\\GithubProfileViewCounter\\": "src"
3127
}
3228
},
3329
"autoload-dev": {
3430
"psr-4": {
35-
"Spatie\\Skeleton\\Tests\\": "tests"
31+
"Caneco\\GithubProfileViewCounter\\Tests\\": "tests"
3632
}
3733
},
3834
"scripts": {
@@ -47,13 +43,10 @@
4743
"extra": {
4844
"laravel": {
4945
"providers": [
50-
"Spatie\\Skeleton\\SkeletonServiceProvider"
51-
],
52-
"aliases": {
53-
"Skeleton": "Spatie\\Skeleton\\SkeletonFacade"
54-
}
46+
"Caneco\\GithubProfileViewCounter\\GithubProfileViewCounterServiceProvider"
47+
]
5548
}
5649
},
5750
"minimum-stability": "dev",
58-
"prefer-stable": true
51+
"prefer-stable": false
5952
}

config/skeleton.php

-5
This file was deleted.

configure-skeleton.sh

-85
This file was deleted.

database/migrations/create_skeleton_table.php.stub renamed to database/migrations/create_github_profile_view_counter_table.php.stub

+4-5
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ use Illuminate\Database\Migrations\Migration;
44
use Illuminate\Database\Schema\Blueprint;
55
use Illuminate\Support\Facades\Schema;
66

7-
class CreateSkeletonTable extends Migration
7+
class CreateGithubProfileViewCounterTable extends Migration
88
{
99
public function up()
1010
{
11-
Schema::create('skeleton_table', function (Blueprint $table) {
11+
Schema::create('x_github_profile_view_counter', function (Blueprint $table) {
1212
$table->bigIncrements('id');
13-
14-
// add fields
15-
13+
$table->string('ua', 512);
14+
$table->string('ip', 45);
1615
$table->timestamps();
1716
});
1817
}

phpunit.xml.dist

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
processIsolation="false"
1111
stopOnFailure="false">
1212
<testsuites>
13-
<testsuite name="Spatie Test Suite">
13+
<testsuite name="Caneco Test Suite">
1414
<directory>tests</directory>
1515
</testsuite>
1616
</testsuites>
@@ -25,4 +25,7 @@
2525
<log type="coverage-text" target="build/coverage.txt"/>
2626
<log type="coverage-clover" target="build/logs/clover.xml"/>
2727
</logging>
28+
<php>
29+
<env name="APP_ENV" value="testing"/>
30+
</php>
2831
</phpunit>

resources/views/badge.blade.php

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<svg aria-label="Profile views: {{ $count ?? 0 }}" xmlns="http://www.w3.org/2000/svg" height="20" width="140">
2+
<title>Profile views: {{ $count ?? 0 }}</title>
3+
<g shape-rendering="crispEdges">
4+
<rect height="20" fill="#555" width="140"/>
5+
<rect height="20" fill="#4c1" x="80" width="60"/>
6+
<rect rx="3" width="80" height="20" fill="transparent"/>
7+
</g>
8+
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
9+
<text y="14" x="38">Profile views</text>
10+
<text y="14" x="110">{{ $count ?? 0 }}</text>
11+
</g>
12+
</svg>

routes/web.php

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Route;
4+
use Caneco\GithubProfileViewCounter\Http\Controllers\GithubProfileViewCounterController;
5+
6+
Route::get('github-profile-view-counter.svg', GithubProfileViewCounterController::class);

src/Commands/SkeletonCommand.php

-17
This file was deleted.

src/Counter.php

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace Caneco\GithubProfileViewCounter;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class Counter extends Model
8+
{
9+
protected $fillable = ['ua', 'ip'];
10+
11+
protected $table = 'x_github_profile_view_counter';
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
namespace Caneco\GithubProfileViewCounter;
4+
5+
use Illuminate\Support\Facades\Route;
6+
use Illuminate\Support\ServiceProvider;
7+
8+
class GithubProfileViewCounterServiceProvider extends ServiceProvider
9+
{
10+
public function boot()
11+
{
12+
$this->registerRoutes();
13+
$this->registerResources();
14+
}
15+
16+
public function register()
17+
{
18+
$this->offerPublishing();
19+
}
20+
21+
protected function registerRoutes()
22+
{
23+
Route::group([
24+
'middleware' => 'web',
25+
], function () {
26+
$this->loadRoutesFrom(__DIR__.'/../routes/web.php');
27+
});
28+
}
29+
30+
protected function registerResources()
31+
{
32+
$this->loadViewsFrom(__DIR__.'/../resources/views', 'github-profile-view-counter');
33+
}
34+
35+
protected function offerPublishing()
36+
{
37+
if ($this->app->runningInConsole()) {
38+
$this->publishes([
39+
__DIR__ . '/../database/migrations/create_github_profile_view_counter_table.php.stub'
40+
=> database_path('migrations/' . date('Y_m_d_His', time()) . '_create_github_profile_view_counter_table.php'),
41+
], 'migrations');
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)