Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
caneco committed Jul 14, 2020
1 parent c9474f2 commit 06e0000
Show file tree
Hide file tree
Showing 22 changed files with 184 additions and 262 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

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

## 1.0.0 - 202X-XX-XX

Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) Spatie bvba <[email protected]>
Copyright (c) Caneco bvba <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
59 changes: 21 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,39 @@
# :package_description
# Laravel GitHub Profile Visit Counter

[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/:package_name.svg?style=flat-square)](https://packagist.org/packages/spatie/:package_name)
[![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)
[![Total Downloads](https://img.shields.io/packagist/dt/spatie/:package_name.svg?style=flat-square)](https://packagist.org/packages/spatie/:package_name)
<p align="center">
<img src="/art/socialcard.png" width="1280" title="Social Card Laravel GitHub Profile View Counter">
<p align="center">
<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>
<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>
</p>
</p>

**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.
This package will allows you to track Github profile views and display them in your profile readme, for free.

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.

## Support us

Learn how to create a package like this one, by watching our premium video course:

[![Laravel Package training](https://spatie.be/github/package-training.jpg)](https://laravelpackage.training)

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).

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).
This package was inspired Artem Golubin's post [**How to track and display profile views on GitHub**](https://rushter.com/blog/github-profile-markdown/).

## Installation

You can install the package via composer:

```bash
composer require spatie/package-skeleton-laravel
composer require caneco/laravel-github-profile-view-counter
```

You can publish and run the migrations with:

```bash
php artisan vendor:publish --provider="Spatie\Skeleton\SkeletonServiceProvider" --tag="migrations"
php artisan vendor:publish --provider="Caneco\GithubProfileViewCounter\GithubProfileViewCounterServiceProvider" --tag="migrations"
php artisan migrate
```

You can publish the config file with:
```bash
php artisan vendor:publish --provider="Spatie\Skeleton\SkeletonServiceProvider" --tag="config"
```

This is the contents of the published config file:
## Usage

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

## Usage
## Cheating

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

## Testing

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

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

## Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

## Credits

- [:author_name](https://github.com/:author_username)
- [Caneco](https://github.com/caneco)
- [All Contributors](../../contributors)

## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

## Thanks

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).
Binary file added art/socialcard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 11 additions & 18 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
{
"name": "spatie/:package_name",
"description": ":package_description",
"keywords": [
"spatie",
":package_name"
],
"homepage": "https://github.com/spatie/:package_name",
"name": "caneco/laravel-github-profile-view-counter",
"description": "Track and display profile views on your GitHub profile.",
"keywords": ["laravel", "github", "readme", "track", "webcounter"],
"homepage": "https://github.com/caneco/laravel-github-profile-view-counter",
"license": "MIT",
"authors": [
{
"name": ":author_name",
"email": ":author_email",
"homepage": "https://spatie.be",
"name": "Caneco",
"homepage": "https://caneco.dev",
"role": "Developer"
}
],
Expand All @@ -27,12 +23,12 @@
},
"autoload": {
"psr-4": {
"Spatie\\Skeleton\\": "src"
"Caneco\\GithubProfileViewCounter\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Spatie\\Skeleton\\Tests\\": "tests"
"Caneco\\GithubProfileViewCounter\\Tests\\": "tests"
}
},
"scripts": {
Expand All @@ -47,13 +43,10 @@
"extra": {
"laravel": {
"providers": [
"Spatie\\Skeleton\\SkeletonServiceProvider"
],
"aliases": {
"Skeleton": "Spatie\\Skeleton\\SkeletonFacade"
}
"Caneco\\GithubProfileViewCounter\\GithubProfileViewCounterServiceProvider"
]
}
},
"minimum-stability": "dev",
"prefer-stable": true
"prefer-stable": false
}
5 changes: 0 additions & 5 deletions config/skeleton.php

This file was deleted.

85 changes: 0 additions & 85 deletions configure-skeleton.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateSkeletonTable extends Migration
class CreateGithubProfileViewCounterTable extends Migration
{
public function up()
{
Schema::create('skeleton_table', function (Blueprint $table) {
Schema::create('x_github_profile_view_counter', function (Blueprint $table) {
$table->bigIncrements('id');

// add fields

$table->string('ua', 512);
$table->string('ip', 45);
$table->timestamps();
});
}
Expand Down
5 changes: 4 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Spatie Test Suite">
<testsuite name="Caneco Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
Expand All @@ -25,4 +25,7 @@
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
<php>
<env name="APP_ENV" value="testing"/>
</php>
</phpunit>
12 changes: 12 additions & 0 deletions resources/views/badge.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<svg aria-label="Profile views: {{ $count ?? 0 }}" xmlns="http://www.w3.org/2000/svg" height="20" width="140">
<title>Profile views: {{ $count ?? 0 }}</title>
<g shape-rendering="crispEdges">
<rect height="20" fill="#555" width="140"/>
<rect height="20" fill="#4c1" x="80" width="60"/>
<rect rx="3" width="80" height="20" fill="transparent"/>
</g>
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="11">
<text y="14" x="38">Profile views</text>
<text y="14" x="110">{{ $count ?? 0 }}</text>
</g>
</svg>
6 changes: 6 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

use Illuminate\Support\Facades\Route;
use Caneco\GithubProfileViewCounter\Http\Controllers\GithubProfileViewCounterController;

Route::get('github-profile-view-counter.svg', GithubProfileViewCounterController::class);
17 changes: 0 additions & 17 deletions src/Commands/SkeletonCommand.php

This file was deleted.

12 changes: 12 additions & 0 deletions src/Counter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Caneco\GithubProfileViewCounter;

use Illuminate\Database\Eloquent\Model;

class Counter extends Model
{
protected $fillable = ['ua', 'ip'];

protected $table = 'x_github_profile_view_counter';
}
44 changes: 44 additions & 0 deletions src/GithubProfileViewCounterServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace Caneco\GithubProfileViewCounter;

use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;

class GithubProfileViewCounterServiceProvider extends ServiceProvider
{
public function boot()
{
$this->registerRoutes();
$this->registerResources();
}

public function register()
{
$this->offerPublishing();
}

protected function registerRoutes()
{
Route::group([
'middleware' => 'web',
], function () {
$this->loadRoutesFrom(__DIR__.'/../routes/web.php');
});
}

protected function registerResources()
{
$this->loadViewsFrom(__DIR__.'/../resources/views', 'github-profile-view-counter');
}

protected function offerPublishing()
{
if ($this->app->runningInConsole()) {
$this->publishes([
__DIR__ . '/../database/migrations/create_github_profile_view_counter_table.php.stub'
=> database_path('migrations/' . date('Y_m_d_His', time()) . '_create_github_profile_view_counter_table.php'),
], 'migrations');
}
}
}
Loading

0 comments on commit 06e0000

Please sign in to comment.