Skip to content

Commit

Permalink
[google-adsense] init (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
Big-Cake-jpg authored Jan 28, 2022
1 parent 7723618 commit 9f1ef5b
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 0 deletions.
21 changes: 21 additions & 0 deletions plugins/google-adsense/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Big_Cake

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
35 changes: 35 additions & 0 deletions plugins/google-adsense/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# google-adsense

A plugin for Blessing Skin Server that can let you display Google Ads with Google AdSense in the website.

## Usage

Enable this plugin.

Copy your client-id (ca-pub-xxxxxxxxxxxxxx) and save it in the settings of the plugin.

## License

MIT License

Copyright ©️ Big_Cake, All Rights Reserved.

[Google AdSense](https://www.google.com/adsense) is a registered trademark of Google LLC.

# Google AdSense(谷歌广告)

这个插件能让你在你的皮肤站内投放谷歌广告。

## 用法

启用该插件,并将你在 AdSense 页面获取的 client-id 填入配置页面。

保存,这时查看页面源代码,就可以看到谷歌广告的 script 标签了。

## 开源协议

MIT License

Copyright ©️ Big_Cake, All Rights Reserved.

[Google AdSense](https://www.google.com/adsense) 是 Google LLC 的注册商标。
13 changes: 13 additions & 0 deletions plugins/google-adsense/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

use App\Events\RenderingHeader;
use Illuminate\Contracts\Events\Dispatcher;

return function (Dispatcher $events) {
$events->listen(RenderingHeader::class, function ($event) {
$html = view('BigCake\googleadsense::snippet', [
'client_id' => option('client_id'),
])->render();
$event->addContent($html);
});
};
1 change: 1 addition & 0 deletions plugins/google-adsense/lang/en/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
client_id: ID of the Google AdSense
1 change: 1 addition & 0 deletions plugins/google-adsense/lang/en/general.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
description: Insert your Google AdSense ID to the site.
1 change: 1 addition & 0 deletions plugins/google-adsense/lang/zh_CN/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
client_id: Google Adsense ID(ca-pub-xxxxxxxxxx)
1 change: 1 addition & 0 deletions plugins/google-adsense/lang/zh_CN/general.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
description: 为站点加入 Google Adsense 代码来投放广告。
20 changes: 20 additions & 0 deletions plugins/google-adsense/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "google-adsense",
"title": "Google Adsense",
"version": "0.0.1",
"description": "BigCake\\googleadsense::general.description",
"author": "Big_Cake",
"url": "https://bigcake.cakemc.top/",
"namespace": "BigCake\\googleadsense",
"require": {
"blessing-skin-server": "^5|^6"
},
"enchants": {
"config": "Configuration",
"icon": {
"fa": "google",
"faType": "fab",
"bg": "success"
}
}
}
18 changes: 18 additions & 0 deletions plugins/google-adsense/src/Configuration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace BigCake\googleadsense;

use App\Services\OptionForm;
use Option;

class Configuration
{
public function render()
{
$form = Option::form('Google Adsense', 'client_id', function (OptionForm $form) {
$form->text('client_id', trans('BigCake\googleadsense::config.client_id'));
})->handle();

return view('BigCake\googleadsense::config', ['form' => $form]);
}
}
11 changes: 11 additions & 0 deletions plugins/google-adsense/views/config.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% extends 'admin.base' %}

{% block title %}Google Adsense{% endblock %}

{% block content %}
<div class="row">
<div class="col-md-6">
{{ form|raw }}
</div>
</div>
{% endblock %}
1 change: 1 addition & 0 deletions plugins/google-adsense/views/snippet.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<script data-ad-client="{{ client_id }}" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

0 comments on commit 9f1ef5b

Please sign in to comment.