Skip to content

Commit

Permalink
Merge branch 'release/v1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnymillergh committed Feb 11, 2020
2 parents 0b7f41e + caca69e commit db28537
Show file tree
Hide file tree
Showing 21 changed files with 585 additions and 100 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
VUE_APP_PACKAGE_JSON=''

# TAG must be corresponding with the version tag in package.json, need to modify it when new version releases
TAG=1.0.2
TAG=1.1.0
4 changes: 2 additions & 2 deletions .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ VUE_APP_RUN_ON_DOCKER = 'true'
# Left blank if the environment is not development.
VUE_APP_BASE_URL = ''
# Base api
VUE_APP_BASE_API = 'http://106.13.32.85:8081/jm-spring-boot-template-prod'
VUE_APP_BASE_API = 'http://172.11.239.12:8080/exrx-net-crawler-server-prod'
# Resource base api for picture, video ect.
VUE_APP_RESOURCE_BASE_API = 'http://106.13.32.85:8081/jm-spring-boot-template-prod'
VUE_APP_RESOURCE_BASE_API = 'http://172.11.239.12:8080/exrx-net-crawler-server-prod'
50 changes: 50 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,53 @@
# [1.1.0](https://github.com/johnnymillergh/exrx-net-crawler/compare/v1.0.2...v1.1.0) (2020-02-11)


### Bug Fixes

* **$Axios:** check nullity before validation ([ac6a2a6](https://github.com/johnnymillergh/exrx-net-crawler/commit/ac6a2a6dfd26c1f906b26cbd9a58c85126c27dd9))
* **$Exercise:** correct parsing the last part of exercises ([4528734](https://github.com/johnnymillergh/exrx-net-crawler/commit/452873420ca844ed7e2f468be76cb99325612341))


### Features

* **$Exercise:** add loading animation ([d6ad4e3](https://github.com/johnnymillergh/exrx-net-crawler/commit/d6ad4e3c34c74de80f3a83b282cc42aea5785be3))
* **$Exercise:** add UI components for parsing and saving specific exercise ([a87d357](https://github.com/johnnymillergh/exrx-net-crawler/commit/a87d35780ac3e2dbca214c5c7f90801061a5e473))
* **$Exercise:** parse and save one single specific exercise ([9141543](https://github.com/johnnymillergh/exrx-net-crawler/commit/91415437862351581aa26f0c18a692ba9c2c587e))
* **$Exercise:** support parsing exercise by body part ([50c0d15](https://github.com/johnnymillergh/exrx-net-crawler/commit/50c0d150f7a17e2cf80252a50cb033bf7426dffb))
* **$HelloWorld:** retrieve backend app info ([62bb630](https://github.com/johnnymillergh/exrx-net-crawler/commit/62bb630221c07464a65e774fa97696a89239bf27))
* **$MultiWindow:** beautify UI ([13fae23](https://github.com/johnnymillergh/exrx-net-crawler/commit/13fae239ebd823d515c378ca25a7c3ec41652b0d))
* **$MultiWindow:** delay 0.6s to open new window ([4318b3a](https://github.com/johnnymillergh/exrx-net-crawler/commit/4318b3a37ce75501be3f3aff39362e2e3de07431))
* **$MultiWindow:** support multi window communication ([34e6927](https://github.com/johnnymillergh/exrx-net-crawler/commit/34e69270cc985843c21472f0b83819d4f9912483))
* **$MultiWindow:** support opening a unique window ([3aa0c9a](https://github.com/johnnymillergh/exrx-net-crawler/commit/3aa0c9a62bcd4e476cb2c6c98cfad64323f7bb32))


### Performance Improvements

* **$Axios:** disable request cancellation ([f992025](https://github.com/johnnymillergh/exrx-net-crawler/commit/f9920258964973c8466dd9cdb3a489418f1bee42))
* **$Axios:** refine generating request token ([4d8c3a0](https://github.com/johnnymillergh/exrx-net-crawler/commit/4d8c3a031bb44b030576003d3e4992276c84c3e2))
* **$Axios:** refine param validation ([9469af7](https://github.com/johnnymillergh/exrx-net-crawler/commit/9469af778d56f15571dae5d511e65cd88c52830a))
* **$Exercise:** add constraint for concurrency ([5a38ab2](https://github.com/johnnymillergh/exrx-net-crawler/commit/5a38ab276449975d866ca764dc70863a0f251634))
* **$Exercise:** capture error when restoring path to URL ([354c6dd](https://github.com/johnnymillergh/exrx-net-crawler/commit/354c6dddd570506358132d4a9a8be19764e2fd27))
* **$Exercise:** refine parsing other exercise ([0457d2e](https://github.com/johnnymillergh/exrx-net-crawler/commit/0457d2e4e833b387f156e895cf5a4c17b5a02d34))
* **$Exercise:** refine parsing stretching exercise ([6005128](https://github.com/johnnymillergh/exrx-net-crawler/commit/60051287ddfc02f42a7f89ee8ffb4823029b49ac))
* **$MultiWindow:** abstract code ([66ab76c](https://github.com/johnnymillergh/exrx-net-crawler/commit/66ab76c4fbd57fa01c06a3177bbb0566574cc563))
* **$MultiWindow:** throw an error when failing to going back to last page ([8dc320e](https://github.com/johnnymillergh/exrx-net-crawler/commit/8dc320e292838527b0ea20eb3752e8c872fb4a6e))
* **$MultiWindow:** use optional chain to avoid error ([fb54364](https://github.com/johnnymillergh/exrx-net-crawler/commit/fb54364051787e3a4a49843bfd6fb4c50ac03d4e))
* **$MultiWindow:** use optional chain to avoid query error ([a82f028](https://github.com/johnnymillergh/exrx-net-crawler/commit/a82f028dce16aca2d3872593b1aa6a882b812b57))
* **$MultiWindow:** use toast to display error info instead of window.alert() ([8f7576e](https://github.com/johnnymillergh/exrx-net-crawler/commit/8f7576eb4d184a08b250ee53b502156a706a7aac))
* **$Muscle:** support sending concurrent requests ([d9cae3e](https://github.com/johnnymillergh/exrx-net-crawler/commit/d9cae3e4d3feb1bf3630c81d9b88aefb651a2192))
* **$package.json:** upgrade dependencies ([beea982](https://github.com/johnnymillergh/exrx-net-crawler/commit/beea982179106ada5833eb0cff6682434ec80078))


### BREAKING CHANGES

* **$Exercise:** refine parsing stretching exercise
* **$Exercise:** parse and save one single specific exercise
* **$Exercise:** support parsing exercise by body part
* **$Muscle:** support sending concurrent requests
* **$MultiWindow:** support multi window communication



## [1.0.2](https://github.com/johnnymillergh/exrx-net-crawler/compare/v1.0.1...v1.0.2) (2020-01-30)


Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ Here is the highlights of **ExRx.net Crawler**:

## Roadmap

- [ ] Correct parsing stretch exercises. Such as: [Neck Retraction Stretch](https://exrx.net/Stretches/Sternocleidomastoid/NeckRetraction), [Neck Rotation Stretch](https://exrx.net/Stretches/Sternocleidomastoid/NeckRotation), etc.
- [ ] Support inputting or specifying exercise section to parse.
- [ ] Concurrency requesting and parsing DOMs.
- [x] Correct parsing stretch exercises. Such as: [Neck Retraction Stretch](https://exrx.net/Stretches/Sternocleidomastoid/NeckRetraction), [Neck Rotation Stretch](https://exrx.net/Stretches/Sternocleidomastoid/NeckRotation), etc.
- [x] Support inputting or specifying exercise section to parse.
- [x] Concurrency requesting and parsing DOMs.

## Usage

Expand Down
62 changes: 30 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "exrx-net-crawler",
"version": "1.0.2",
"version": "1.1.0",
"license": "Apache-2.0",
"description": "The Crawler for ExRx.net",
"author": {
Expand Down Expand Up @@ -35,55 +35,53 @@
"go:travis": "npm run lint && npm run test:unit && npm run build:prod"
},
"dependencies": {
"@mdi/font": "4.7.95",
"@mdi/js": "4.7.95",
"@types/cheerio": "0.22.15",
"@mdi/font": "4.9.95",
"@mdi/js": "4.9.95",
"@types/cheerio": "0.22.16",
"@types/lodash": "4.14.149",
"axios": "0.19.0",
"axios": "0.19.2",
"axios-mock-adapter": "1.17.0",
"cheerio": "1.0.0-rc.3",
"class-validator": "0.11.0",
"core-js": "3.6.1",
"core-js": "3.6.4",
"lodash": "4.17.15",
"mysql": "2.17.1",
"reflect-metadata": "0.1.13",
"roboto-fontface": "*",
"vue": "2.6.11",
"vue-class-component": "7.1.0",
"vue-property-decorator": "8.3.0",
"vue-router": "3.1.3",
"vuetify": "2.2.1",
"vue-class-component": "7.2.2",
"vue-property-decorator": "8.4.0",
"vue-router": "3.1.5",
"vuetify": "2.2.11",
"vuex": "3.1.2"
},
"devDependencies": {
"@babel/plugin-proposal-optional-chaining": "7.7.5",
"@types/jest": "^24.0.19",
"@typescript-eslint/eslint-plugin": "2.14.0",
"@typescript-eslint/parser": "2.14.0",
"@vue/cli-plugin-babel": "4.1.2",
"@vue/cli-plugin-eslint": "4.1.2",
"@vue/cli-plugin-router": "4.1.2",
"@vue/cli-plugin-typescript": "4.1.2",
"@vue/cli-plugin-unit-jest": "4.1.2",
"@vue/cli-plugin-vuex": "4.1.2",
"@vue/cli-service": "4.1.2",
"@vue/eslint-config-standard": "5.0.1",
"@babel/plugin-proposal-optional-chaining": "7.8.3",
"@types/jest": "24.9.1",
"@typescript-eslint/eslint-plugin": "2.19.0",
"@typescript-eslint/parser": "2.19.0",
"@vue/cli-plugin-babel": "4.2.2",
"@vue/cli-plugin-eslint": "4.2.2",
"@vue/cli-plugin-router": "4.2.2",
"@vue/cli-plugin-typescript": "4.2.2",
"@vue/cli-plugin-unit-jest": "4.2.2",
"@vue/cli-plugin-vuex": "4.2.2",
"@vue/cli-service": "4.2.2",
"@vue/eslint-config-standard": "5.1.1",
"@vue/eslint-config-typescript": "5.0.1",
"@vue/test-utils": "1.0.0-beta.29",
"@vue/test-utils": "1.0.0-beta.31",
"babel-eslint": "10.0.3",
"eslint": "6.8.0",
"eslint-plugin-import": "2.19.1",
"eslint-plugin-import": "2.20.1",
"eslint-plugin-node": "11.0.0",
"eslint-plugin-promise": "4.2.1",
"eslint-plugin-standard": "4.0.1",
"eslint-plugin-vue": "6.1.2",
"eslint-plugin-vue-libs": "4.0.0",
"lint-staged": "9.5.0",
"node-sass": "4.13.0",
"sass": "1.24.0",
"sass-loader": "8.0.0",
"typescript": "3.7.4",
"vue-cli-plugin-vuetify": "2.0.3",
"lint-staged": "10.0.7",
"node-sass": "4.13.1",
"sass": "1.25.0",
"sass-loader": "8.0.2",
"typescript": "3.7.5",
"vue-cli-plugin-vuetify": "2.0.4",
"vue-template-compiler": "2.6.11",
"vuetify-loader": "1.4.3"
},
Expand Down
7 changes: 7 additions & 0 deletions proxy.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
module.exports = {
'/common': {
target: `${process.env.VUE_APP_BASE_URL}`,
changeOrigin: true,
pathRewrite: {
'^/common': `/${process.env.VUE_APP_BASE_API}/common`
}
},
'/test-table': {
target: `${process.env.VUE_APP_BASE_URL}`,
changeOrigin: true,
Expand Down
25 changes: 19 additions & 6 deletions src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,53 @@
<v-divider style="margin-bottom: 24px"/>
<v-row>
<v-btn v-debounced-click="handelClickTest" block color="primary">Test Back-end Service</v-btn>
<v-btn @click="handleClickOpenNewPage" block>Open New Page</v-btn>
</v-row>
<v-row>{{ response }}</v-row>
<v-row>Response: {{ response }}</v-row>
<v-row>Value from sub window: {{ JSON.stringify(valueFromSubWindow) }}</v-row>
</v-container>
</template>

<!--suppress JSUnusedLocalSymbols, JSUnusedGlobalSymbols -->
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator'
import { AppUtil } from '@/utils/app-util'
import { GetByIdPayload } from '@/domain/test-table/get-by-id-payload'
import { testTableApi } from '@/requests/test-table-api'
import { commonApi } from '@/requests/common-api'
@Component
export default class HelloWorld extends Vue {
@Prop() private msg!: string
private version = ''
private environment = ''
private response = null as any
private valueFromSubWindow = null as any
async mounted () {
this.version = AppUtil.getVersionInfo()
this.environment = `${process.env.NODE_ENV} (${process.env.VUE_APP_ENV})`
}
async handelClickTest (): Promise<void> {
const getByIdPayload = new GetByIdPayload()
getByIdPayload.id = 1
try {
this.response = await testTableApi.getById(getByIdPayload)
this.response = await commonApi.appInfo()
this.$toast.success('Succeed to interact with back-end server `exrx-net-crawler-server`')
} catch (error) {
console.error('Error occurred when sending request `getById`!', error)
this.$toast.error(error.message)
}
}
handleClickOpenNewPage () {
this.openWindow(this, '/second-page', {
callback: 'logCallback',
windowTarget: 'secondPage',
version: this.version
})
}
logCallback (value: any) {
console.info('logCallback', value)
this.valueFromSubWindow = value
}
}
</script>
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import '@/directives/throttled-click'
import '@/directives/debounced-click'
import { listenToColorScheme } from '@/plugins/adaptive-color-scheme'
// import '@/plugins/axios-mock-adapter'
import { MultiWindow } from '@/mixins/multi-window'

Vue.config.productionTip = false
Vue.mixin(MultiWindow)

const vueInstance = new Vue({
router,
Expand Down
80 changes: 80 additions & 0 deletions src/mixins/multi-window/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { Component, Vue } from 'vue-property-decorator'
// eslint-disable-next-line no-unused-vars
import { MultiWindowOptions } from '@/mixins/multi-window/multi-window-options'

/**
* Multi window mixin
*
* Can i use mixins global in vue? i am use typescript with vue
* @see <a href='https://github.com/kaorun343/vue-property-decorator/issues/226#issuecomment-515568960'>GitHub</a>
*/
@Component
export class MultiWindow extends Vue {
private $multiWindowOptions: MultiWindowOptions = {
delayClosingWindow: true,
callback: ''
}

mounted () {
this.$data.$multiWindowOptions.delayClosingWindow = this.$route?.query?.delayClosingWindow === 'true'
this.$data.$multiWindowOptions.callback = this.$route?.query?.callback
}

openWindow (context: Vue, url: string, multiWindowOptions?: MultiWindowOptions): void {
// Set default delayClosingWindow as true
if (multiWindowOptions?.delayClosingWindow === undefined) {
// @ts-ignore
multiWindowOptions.delayClosingWindow = true
}
const path = /\/$/.test(url) ? url : `${url}/`
// the value of process.env.BASE_URL is equal to the `publicPath` configured in vue.config.js
const baseUrl = process.env.BASE_URL
const target = /^(http|https):\/\//.test(path) ? url : `${baseUrl}#${url}`
// Passing information to opened window by query string
let queryString = ''
for (const key in multiWindowOptions) {
// Determines whether an object has a property with the specified name.
// eslint-disable-next-line no-prototype-builtins
if (!multiWindowOptions.hasOwnProperty(key)) {
break
}
const val = ((multiWindowOptions[key] === null) || (multiWindowOptions[key] === undefined) ? '' : multiWindowOptions[key])
queryString += queryString === '' ? `?${key}=${val}` : `&${key}=${val}`
}
setTimeout(() => {
const newWindow = window.open(`${target}${queryString}`, multiWindowOptions?.windowTarget)
if (!newWindow) {
window.alert('Please give us permission to open a new page!')
throw new Error('Failed to gain permission to open a new page!')
} else {
newWindow.opener.$vue = context
}
}, 600)
}

windowBack (argument?: any): void {
const context = window?.opener?.$vue
const callback = this.$data.$multiWindowOptions.callback
const delayClosingWindow = this.$data.$multiWindowOptions.delayClosingWindow
if (!context) {
this.$toast.error('ERROR: Cannot find context!')
// window.alert('ERROR: Cannot find context!')
throw new Error('Cannot find context!')
}
// Check whether opener's callback is valid
if (callback && typeof context[callback] === 'function') {
context[callback](argument)
} else {
this.$toast.error('ERROR: Cannot find callback!')
// window.alert('ERROR: Cannot find callback!')
throw new Error('Cannot find callback!')
}
if (delayClosingWindow) {
setTimeout(() => {
window.close()
}, 300)
} else {
window.close()
}
}
}
25 changes: 25 additions & 0 deletions src/mixins/multi-window/multi-window-options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Multi Window Options
*/
export interface MultiWindowOptions {
/**
* A DOMString specifying the name of the browsing context (window, <iframe> or tab) into which to load the specified resource;
* if the name doesn't indicate an existing context, a new window is created and is given the name specified by windowName.
*/
windowTarget?: string

/**
* Whether delay closing opened window for 300 ms. Default: true
*/
delayClosingWindow?: boolean

/**
* Vue instance of opener callback function name
*/
callback?: string

/**
* Other data
*/
[key: string]: any
}
17 changes: 9 additions & 8 deletions src/plugins/axios/axios-for-inter-communication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
* @date 1/2/20 9:15 AM
*/
// eslint-disable-next-line no-unused-vars
import Axios, { AxiosRequestConfig, AxiosResponse, Canceler, ResponseType } from 'axios'
import * as Cancellation from '@/plugins/axios/cancellation'
import Axios, { AxiosRequestConfig, AxiosResponse, ResponseType } from 'axios'
// import * as Cancellation from '@/plugins/axios/cancellation'
import { HttpStatus } from '@/constants/http-status'
// import { AxiosUtil } from '@/utils/axios-util'

/**
CORS Anywhere is a NodeJS reverse proxy which adds CORS headers to the proxied request.
Expand Down Expand Up @@ -65,13 +66,13 @@ export const service = Axios.create({
service.interceptors.request.use(
async (axiosRequestConfig: AxiosRequestConfig) => {
// Cancel and remove same request before sending upcoming request.
Cancellation.cancelAndRemoveSamePendingRequest(axiosRequestConfig)
// Cancellation.cancelAndRemoveSamePendingRequest(axiosRequestConfig)
// Configure cancelToken for request
axiosRequestConfig.cancelToken = new Cancellation.CancelToken((cancel: Canceler) => {
const requestToken = `${axiosRequestConfig?.url?.split('?')[0]}::${axiosRequestConfig.method}::${JSON.stringify(axiosRequestConfig.params)}`
const pendingRequest = new Cancellation.PendingRequest(requestToken, cancel)
Cancellation.pendingRequestList.push(pendingRequest)
})
// axiosRequestConfig.cancelToken = new Cancellation.CancelToken((cancel: Canceler) => {
// const requestToken = AxiosUtil.getRequestToken(axiosRequestConfig)
// const pendingRequest = new Cancellation.PendingRequest(requestToken, cancel)
// Cancellation.pendingRequestList.push(pendingRequest)
// })
return axiosRequestConfig
},
(error: any) => {
Expand Down
Loading

0 comments on commit db28537

Please sign in to comment.