Skip to content

Commit ddb7ff0

Browse files
committed
docs: insert code sponsor snippet and add rollbar logo as a sponsor
1 parent 0143f9d commit ddb7ff0

File tree

10 files changed

+160
-238
lines changed

10 files changed

+160
-238
lines changed

build/docs/webpack.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import webpack from 'webpack'
22
import path from 'path'
3-
import fs from 'fs'
43
import autoprefixer from 'autoprefixer'
54
import ExtractTextPlugin from 'extract-text-webpack-plugin'
65
import CopyWebpackPlugin from 'copy-webpack-plugin'
@@ -16,12 +15,6 @@ import { config, resolvePath, getRandomInt } from '../config'
1615
import banner from '../lib/banner'
1716
import { mapRoutes } from '../../docs/app/routes'
1817

19-
function postProcessHtml (context) {
20-
const adsHTML = fs.readFileSync(resolvePath('docs/ads.html'))
21-
22-
return context.html.replace('<!-- AD OUTLET -->', adsHTML.toString())
23-
}
24-
2518
const cacheUpdateTime = process.env.CACHE_UPDATE_MINUTES || 10
2619
const cssLoader = ExtractTextPlugin.extract({
2720
use: 'css-loader',
@@ -200,8 +193,7 @@ const webpackConfig = {
200193
captureAfterElementExists: '.main-container',
201194
captureAfterTime: 7000,
202195
navigationLocked: true,
203-
ignoreJSErrors: true,
204-
postProcessHtml
196+
ignoreJSErrors: true
205197
}),
206198
new OfflinePlugin({
207199
autoUpdate: +cacheUpdateTime * 60 * 1000

build/lib/webpack.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ export default entry => {
287287
analyzerPort: getRandomInt(8000, 8999)
288288
}))
289289
}
290+
290291
if (entry.components) {
291292
webpackConfig.plugins.push(new CopyWebpackPlugin(getCopyPaths()))
292293
}

build/local/webpack.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,9 @@ export default {
6767
]
6868
},
6969
plugins: [
70-
new webpack.DefinePlugin({
71-
'process.env': {
72-
NODE_ENV: JSON.stringify('development')
73-
}
70+
new webpack.EnvironmentPlugin({
71+
NODE_ENV: 'development',
72+
DEBUG: false
7473
}),
7574
new webpack.WatchIgnorePlugin([resolvePath('node_modules')]),
7675
new webpack.HotModuleReplacementPlugin(),

docs/ads.html

Lines changed: 0 additions & 5 deletions
This file was deleted.

docs/app/components/AdManager.vue

Lines changed: 82 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,55 @@
11
<template>
2-
<md-content id="ad-manager" md-theme="default"></md-content>
2+
<md-content class="ad-manager" id="ad-manager" md-theme="default">
3+
<div id="code-sponsor" class="code-sponsor">
4+
<span class="code-sponsor-header">Vue Material is proudly sponsored by:</span>
5+
6+
<a :href="linkHref" class="code-sponsor-content" target="_blank" rel="noopener">
7+
<strong class="code-sponsor-name">Rollbar</strong>
8+
<span class="code-sponsor-description">Real-time error monitoring, alerting, and analytics for developers 🚀</span>
9+
</a>
10+
11+
<img class="code-sponsor-pixel" :src="pixelHref" />
12+
</div>
13+
</md-content>
314
</template>
415

516
<script>
17+
const isProd = process.env.NODE_ENV === 'production'
18+
const token = 'bb9dade0-0207-4ab0-8c86-d00502d952f5'
19+
620
export default {
721
name: 'AdManager',
8-
data: () => ({
9-
carbonEl: null
10-
}),
11-
render () {
12-
return null
13-
},
14-
methods: {
15-
saveAdsElements () {
16-
this.carbonEl = document.getElementById('carbonads')
17-
18-
if (!this.carbonEl) {
19-
this.$destroy()
22+
computed: {
23+
linkHref () {
24+
if (isProd) {
25+
return `https://cs.berry.sh/c/${token}`
2026
}
2127
},
22-
appendCarbonAds () {
23-
const interval = window.setInterval(() => {
24-
const carbonAds = document.getElementById('carbonads')
25-
const container = document.querySelector('.container')
26-
const pageContainer = document.querySelector('.page-container')
27-
const splashContainer = document.querySelector('.splash-container')
28-
const adManager = this.$el
29-
30-
if (carbonAds && container) {
31-
if (pageContainer) {
32-
pageContainer.insertBefore(carbonAds, pageContainer.firstChild)
33-
} else if (splashContainer && adManager) {
34-
adManager.appendChild(carbonAds)
35-
} else {
36-
container.insertBefore(carbonAds, container.firstChild)
37-
}
38-
39-
window.clearInterval(interval)
40-
}
41-
}, 50)
42-
},
43-
moveCarbonAdsToBody () {
44-
if (this.carbonEl) {
45-
document.body.appendChild(this.carbonEl)
28+
pixelHref () {
29+
if (isProd) {
30+
return `https://cs.berry.sh/l/${token}/pixel.png`
4631
}
4732
}
48-
},
49-
mounted () {
50-
this.saveAdsElements()
51-
this.appendCarbonAds()
52-
},
53-
beforeDestroy () {
54-
this.moveCarbonAdsToBody()
5533
}
5634
}
5735
</script>
5836

59-
<style lang="scss">
37+
<style lang="scss" scoped>
6038
@import "~vue-material/theme/engine";
6139
62-
$ad-responsive-big: 1670px;
63-
$ad-responsive-small: 600px;
40+
$ad-responsive-big: 1690px;
41+
$ad-responsive-small: 768px;
6442
6543
@mixin ad-theme ($hue, $color) {
66-
#carbonads {
44+
.code-sponsor {
6745
background: md-get-palette-color(grey, $hue);
6846
69-
.carbon-poweredby {
47+
.code-sponsor-header {
7048
color: rgba($color, .54);
71-
72-
&:hover {
73-
color: rgba($color, .87);
74-
}
7549
}
7650
}
7751
78-
.carbon-wrap a {
52+
.code-sponsor-content {
7953
color: rgba($color, .7);
8054
8155
&:hover {
@@ -84,29 +58,26 @@
8458
}
8559
}
8660
87-
.main-container {
88-
@include ad-theme(200, #000);
89-
}
61+
.ad-manager {
62+
width: calc(100% + 32px);
63+
margin: 0 -16px -16px;
9064
91-
.splash-container {
92-
@media (min-width: $ad-responsive-big) {
93-
@include ad-theme(800, #fff);
65+
@media (max-width: $ad-responsive-small) {
66+
display: flex;
9467
}
9568
}
9669
97-
#carbonads {
98-
max-width: 162px;
99-
margin: 1em 0 24px 16px;
100-
padding: 16px;
70+
.code-sponsor {
71+
max-width: 175px;
72+
margin: 7px 16px 24px 16px;
73+
padding: 8px;
74+
display: flex;
75+
flex-direction: column;
10176
float: right;
10277
position: relative;
10378
z-index: 10;
104-
105-
.splash-container & {
106-
@media (max-width: $ad-responsive-big) {
107-
background: #fff;
108-
}
109-
}
79+
font-size: 12px;
80+
line-height: 1.5em;
11081
11182
@media (min-width: $ad-responsive-big) {
11283
margin: 0;
@@ -117,86 +88,65 @@
11788
11889
@media (max-width: $ad-responsive-small) {
11990
max-width: none;
120-
min-height: 100px;
121-
margin-left: 0;
122-
padding: 0;
91+
margin-bottom: 16px;
12392
float: none;
12493
}
12594
12695
.splash-container & {
12796
@media (max-width: $ad-responsive-big) {
128-
max-width: none;
97+
max-width: 530px;
12998
min-height: 100px;
130-
margin-left: 0;
131-
padding: 0;
99+
margin: 8px auto;
132100
float: none;
101+
background: none !important;
133102
}
134103
}
104+
}
135105
136-
.carbon-wrap {
137-
display: flex;
138-
flex-direction: column;
139-
font-size: 12px;
140-
141-
@media (max-width: $ad-responsive-small) {
142-
display: block;
143-
}
144-
145-
.splash-container & {
146-
@media (max-width: $ad-responsive-big) {
147-
display: block;
148-
}
149-
}
150-
151-
.carbon-img {
152-
@media (max-width: $ad-responsive-small) {
153-
margin-right: 16px;
154-
float: left;
155-
}
156-
157-
.splash-container & {
158-
@media (max-width: $ad-responsive-big) {
159-
margin-right: 16px;
160-
float: left;
161-
}
162-
}
163-
}
164-
165-
.carbon-text {
166-
line-height: 1.5em;
167-
168-
@media (max-width: $ad-responsive-big) {
169-
padding-top: 1em;
170-
padding-right: 16px;
171-
display: block;
172-
}
106+
.code-sponsor-header {
107+
font-size: 11px;
108+
line-height: 1.3em;
109+
}
173110
174-
@media (min-width: $ad-responsive-big) {
175-
margin: 12px 0 8px;
176-
}
177-
}
111+
.code-sponsor-content {
112+
margin-top: 1em;
178113
179-
a {
180-
&:hover {
181-
text-decoration: none;
182-
}
183-
}
114+
&:hover {
115+
text-decoration: none;
184116
}
117+
}
185118
186-
.carbon-poweredby {
187-
font-size: 11px;
119+
.code-sponsor-name,
120+
.code-sponsor-description {
121+
&:hover {
122+
text-decoration: underline;
188123
}
189124
}
190125
191-
#ad-manager {
192-
width: calc(100% + 32px);
193-
margin: 0 -16px -16px;
126+
.code-sponsor-name {
127+
margin-bottom: .5em;
128+
display: block;
129+
font-weight: 600;
130+
}
194131
195-
#carbonads {
196-
@media (max-width: $ad-responsive-big) {
197-
max-width: 530px;
198-
margin: 24px auto;
199-
}
132+
.code-sponsor-pixel {
133+
width: 1px;
134+
height: 1px;
135+
margin: -1px;
136+
padding: 0;
137+
position: absolute;
138+
overflow: hidden;
139+
clip: rect(0 0 0 0);
140+
border: 0;
141+
}
142+
143+
.main-container {
144+
@include ad-theme(200, #000);
145+
}
146+
147+
.splash-container {
148+
@media (min-width: $ad-responsive-big) {
149+
@include ad-theme(800, #fff);
200150
}
201151
}
202152
</style>

0 commit comments

Comments
 (0)