Skip to content

Commit

Permalink
release: v2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
surunzi committed Aug 6, 2024
1 parent 5c4ced7 commit b295e75
Show file tree
Hide file tree
Showing 18 changed files with 240 additions and 256 deletions.
35 changes: 16 additions & 19 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
{
"env": {
"browser": true,
"es6": true,
"commonjs": true
},
"extends": "eslint:recommended",
"rules": {
"quotes": [
"error",
"single"
]
},
"parserOptions": {
"sourceType": "module"
},
"globals": {
"L": true
}
}
"env": {
"browser": true,
"es6": true,
"amd": true,
"commonjs": true
},
"extends": "eslint:recommended",
"rules": {
"indent": ["error", 2],
"quotes": ["error", "single"],
"no-extra-semi": "off"
},
"globals": {
"L": true
}
}
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ko_fi: surunzi
open_collective: eruda
27 changes: 27 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI

on:
workflow_dispatch:
push:
branches:
- 'master'
paths:
- 'src/**/*'

jobs:
ci:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm i
- run: npm run ci
28 changes: 28 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Publish to NPM

on:
workflow_dispatch:
release:
types: [created]

jobs:
publish:

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- name: Build eruda-geolocation
run: |
npm i
npm run build
- name: Publish package on NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
11 changes: 0 additions & 11 deletions .npmignore

This file was deleted.

3 changes: 0 additions & 3 deletions .prettierignore

This file was deleted.

5 changes: 5 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"tabWidth": 2,
"semi": false
}
5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v2.1.0 (6 Aug 2024)

* fix: obsolete api

## v2.0.0 (6 Jan 2020)

* feat: theme support
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# eruda-geolocation

[![NPM version][npm-image]][npm-url]
[![Build status][travis-image]][travis-url]
[![Build status][ci-image]][ci-url]
[![License][license-image]][npm-url]

[npm-image]: https://img.shields.io/npm/v/eruda-geolocation.svg
[npm-url]: https://npmjs.org/package/eruda-geolocation
[travis-image]: https://img.shields.io/travis/liriliri/eruda-geolocation.svg
[travis-url]: https://travis-ci.org/liriliri/eruda-geolocation
[ci-image]: https://img.shields.io/github/actions/workflow/status/liriliri/eruda-geolocation/main.yml?branch=master&style=flat-square
[ci-url]: https://github.com/liriliri/eruda-geolocation/actions/workflows/main.yml
[license-image]: https://img.shields.io/npm/l/eruda-geolocation.svg

Eruda plugin for testing geolocation.

## Demo

Browse it on your phone:
[http://eruda.liriliri.io/?plugin=geolocation](http://eruda.liriliri.io/?plugin=geolocation)
[https://eruda.liriliri.io/?plugin=geolocation](https://eruda.liriliri.io/?plugin=geolocation)

## Install

Expand Down
10 changes: 0 additions & 10 deletions eustia/loadCss.js

This file was deleted.

34 changes: 12 additions & 22 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
/>
<title>Eruda-geolocation</title>
</head>
<body>
<script src="node_modules/eruda/eruda.js"></script>
<script>
eruda.init({ tool: [] })
</script>
<script src="assets/eruda-geolocation.js"></script>
<script>
eruda
.add(erudaGeolocation)
.show('geolocation')
.show()
</script>
</body>
</html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Eruda-geolocation</title>
</head>
<body>
<script src="node_modules/eruda/eruda.js"></script>
<script>eruda.init({tool: []});</script>
<script src="assets/eruda-geolocation.js"></script>
<script>eruda.add(erudaGeolocation).show('geolocation').show();</script>
</body>
</html>
68 changes: 33 additions & 35 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,55 +1,53 @@
{
"name": "eruda-geolocation",
"version": "2.0.0",
"version": "2.1.0",
"description": "Eruda plugin for testing geolocation",
"main": "eruda-geolocation.js",
"browserslist": [
"since 2015",
"not dead"
],
"files": [
"eruda-geolocation.js",
"eruda-geolocation.js.map"
],
"scripts": {
"dev": "webpack-dev-server --host 0.0.0.0",
"build": "webpack && webpack -p",
"ci": "npm run format && npm run lint && npm run build",
"format": "prettier *.js eustia/*.js src/*.js src/style.scss index.html --write",
"lint": "eslint src/**/*.js"
"dev": "webpack-dev-server --host 0.0.0.0 --mode development",
"build": "webpack --mode production",
"ci": "npm run lint && npm run build && npm run es5",
"lint": "eslint src/**/*.js",
"format": "lsla prettier \"src/*.{js,scss}\" \"*.json\" --write",
"es5": "es-check es5 eruda-geolocation.js"
},
"keywords": [
"eruda",
"plugin",
"geolocation"
],
"eustia": {
"files": "src/**/*.js",
"output": "src/util.js",
"format": "commonjs"
},
"author": "redhoodsu",
"author": "surunzi",
"license": "MIT",
"bugs": {
"url": "https://github.com/liriliri/eruda-geolocation/issues"
},
"homepage": "https://github.com/liriliri/eruda-geolocation#readme",
"devDependencies": {
"autoprefixer": "^7.2.2",
"babel-core": "^6.26.3",
"babel-loader": "^7.1.5",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.7.0",
"css-loader": "^0.28.7",
"eruda": "^2.0.0",
"eslint": "^5.4.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-promise": "^4.0.0",
"eslint-plugin-standard": "^3.1.0",
"handlebars": "^4.0.11",
"handlebars-loader": "^1.6.0",
"node-sass": "^4.7.2",
"postcss": "^6.0.14",
"@babel/core": "^7.21.3",
"@babel/plugin-transform-runtime": "^7.21.0",
"@babel/preset-env": "^7.20.2",
"autoprefixer": "^10.4.14",
"babel-loader": "^9.1.2",
"css-loader": "^3.4.2",
"eruda": "^3.2.0",
"es-check": "^7.2.1",
"eslint": "^8.57.0",
"licia": "^1.41.1",
"postcss": "^8.4.21",
"postcss-class-prefix": "^0.3.0",
"postcss-loader": "^2.0.9",
"prettier": "^1.14.2",
"sass-loader": "^6.0.6",
"webpack": "^3.10.0",
"webpack-dev-server": "^2.9.7"
"postcss-loader": "^7.0.2",
"sass": "^1.77.8",
"sass-loader": "^14.2.1",
"webpack": "^5.93.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.12.0"
}
}
5 changes: 0 additions & 5 deletions prettier.config.js

This file was deleted.

47 changes: 27 additions & 20 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { loadCss, loadJs } from './util'
const loadJs = require('licia/loadJs')

module.exports = function(eruda) {
let { evalCss } = eruda.util
module.exports = function (eruda) {
const { evalCss } = eruda.util

class Geolocation extends eruda.Tool {
constructor() {
Expand All @@ -11,7 +11,9 @@ module.exports = function(eruda) {
}
init($el, container) {
super.init($el, container)
$el.html(require('./template.hbs')())
$el.html(
'<div id="eruda-map" class="eruda-map"></div><div class="eruda-info"></div>'
)

this._initMap()
this._$info = this._$el.find('.eruda-info')
Expand All @@ -25,14 +27,14 @@ module.exports = function(eruda) {
if (!navigator.geolocation) return

navigator.geolocation.getCurrentPosition(
position => {
(position) => {
var coords = position.coords,
longitude = coords.longitude,
latitude = coords.latitude

this.setView(latitude, longitude)
},
e => {
(e) => {
this.setInfo(e.message)
}
)
Expand All @@ -56,27 +58,21 @@ module.exports = function(eruda) {
}
_initMap() {
loadCss(
'https://unpkg.com/leaflet@1.3.1/dist/leaflet.css',
'https://unpkg.com/leaflet@1.9.4/dist/leaflet.css',
this._$el.get(0)
)
loadJs('https://unpkg.com/leaflet@1.3.1/dist/leaflet.js', isLoaded => {
loadJs('https://unpkg.com/leaflet@1.9.4/dist/leaflet.js', (isLoaded) => {
if (!isLoaded) return this.setInfo('Failed to init map')

this.setInfo('Map successfully initialized')

this._map = L.map(this._$el.find('#eruda-map').get(0)).setView(
[39.9, 116.39],
12
this._map = L.map(this._$el.find('#eruda-map').get(0), {
center: [39.9, 116.39],
zoom: 2,
})
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {}).addTo(
this._map
)
L.tileLayer(
'https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}',
{
maxZoom: 18,
id: 'mapbox.streets',
accessToken:
'pk.eyJ1Ijoic3VydW56aSIsImEiOiJjamVqbnk4c2gxN3JzMnltb3ByMXdkbDB5In0.Y6rCE361t15ATgiDb-o3Rw'
}
).addTo(this._map)

this.resetView()
})
Expand All @@ -85,3 +81,14 @@ module.exports = function(eruda) {

return new Geolocation()
}

function loadCss(src, container) {
const link = document.createElement('link')

link.rel = 'stylesheet'
link.type = 'text/css'
link.href = src

container = container || document.head
container.appendChild(link)
}
Loading

0 comments on commit b295e75

Please sign in to comment.