Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update #19

Merged
merged 10 commits into from
Jan 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[**.js*]
indent_style = space
indent_size = 2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
.idea
npm-debug.log
dist
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Pornsearch.gifs()

| Site (Module name) | Videos | Gifs |
|:--------------------------------|:------:|:----:|
| [pornhub](http://pornhub.com/) | X | X |
| [pornhub](http://pornhub.com/) | X | X |
| [sex](http://sex.com/) | X | X |
| [redtube](https://redtube.com/) | X | |
| [xvideos](http://xvideos.com/) | X | |
Expand All @@ -54,7 +54,7 @@ What will return in video search

| Site (Module name) | Title | Url | Thumbnail | Duration |
|:--------------------------------|:-----:|:---:|:---------:|:--------:|
| [pornhub](http://pornhub.com/) | X | X | X | X |
| [pornhub](http://pornhub.com/) | X | X | X | X |
| [sex](http://sex.com/) | X | X | X | X |
| [redtube](https://redtube.com/) | X | X | X | X |
| [xvideos](http://xvideos.com/) | X | X | X | X |
Expand Down Expand Up @@ -115,7 +115,6 @@ To know the current driver
Pornsearch.current();
```


## Search

It's easy to search for porn content with Pornsearch =)
Expand Down Expand Up @@ -163,4 +162,3 @@ If has error in whenever search, will be throw an error:
```Markdown
No results for search related to *query* in page *page*
```

1 change: 0 additions & 1 deletion dist/pornsearch.min.js

This file was deleted.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
"version": "2.2.5",
"description": "Easy way to search for porn content on internet",
"main": "dist/pornsearch.min.js",
"files": [
"dist/pornsearch.min.js"
],
"scripts": {
"watch": "webpack --progress --watch",
"build": "webpack --progress",
"lint": "semistandard --fix | snazzy",
"test": "node ./example/example"
Expand Down
24 changes: 2 additions & 22 deletions src/Core/AbstractModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,8 @@ class AbstractModule {
throw new Error('This function must be overwrite');
}

videoUrl () {
throw new Error(`${this.name} doesn't support video search`);
}

gifUrl () {
throw new Error(`${this.name} doesn't support gif search`);
}

videoParser () {
throw new Error('This function must be overwrite');
}

gifParser () {
throw new Error('This function must be overwrite');
}

static extendsToMe (module) {
if (!(module instanceof this)) {
throw new Error(`Module should be an instance of Abstract module`);
}

return module;
static with (...mixins) {
return mixins.reduce((father, mixin) => mixin(father), this);
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/Core/GifMixin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default (Father) => class extends Father {
gifUrl () {
throw new Error('This function must be overwrite');
}

gifParser () {
throw new Error('This function must be overwrite');
}
};
10 changes: 5 additions & 5 deletions src/Core/Modules.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import pornhub from '../Modules/Pornhub';
import redtube from '../Modules/Redtube';
import sex from '../Modules/Sex';
import xvideos from '../Modules/Xvideos';
import sex from '@/Modules/Sex';
import pornhub from '@/Modules/Pornhub';
import redtube from '@/Modules/Redtube';
import xvideos from '@/Modules/Xvideos';

export default {
sex,
pornhub,
redtube,
sex,
xvideos
};
9 changes: 9 additions & 0 deletions src/Core/VideoMixin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default (Father) => class extends Father {
videoUrl () {
throw new Error('This function must be overwrite');
}

videoParser () {
throw new Error('This function must be overwrite');
}
};
6 changes: 4 additions & 2 deletions src/Modules/Pornhub.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import AbstractModule from '../Core/AbstractModule';
import Gif from '@/Core/GifMixin';
import Video from '@/Core/VideoMixin';
import AbstractModule from '@/Core/AbstractModule';

class Pornhub extends AbstractModule {
class Pornhub extends AbstractModule.with(Gif, Video) {
get name () {
return 'Pornhub';
}
Expand Down
5 changes: 3 additions & 2 deletions src/Modules/Redtube.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import AbstractModule from '../Core/AbstractModule';
import Video from '@/Core/VideoMixin';
import AbstractModule from '@/Core/AbstractModule';

class Redtube extends AbstractModule {
class Redtube extends AbstractModule.with(Video) {
get name () {
return 'Redtube';
}
Expand Down
6 changes: 4 additions & 2 deletions src/Modules/Sex.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import AbstractModule from '../Core/AbstractModule';
import Gif from '@/Core/GifMixin';
import Video from '@/Core/VideoMixin';
import AbstractModule from '@/Core/AbstractModule';

class Sex extends AbstractModule {
class Sex extends AbstractModule.with(Gif, Video) {
get name () {
return 'Sex';
}
Expand Down
5 changes: 3 additions & 2 deletions src/Modules/Xvideos.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import AbstractModule from '../Core/AbstractModule';
import Video from '@/Core/VideoMixin';
import AbstractModule from '@/Core/AbstractModule';

class Xvideos extends AbstractModule {
class Xvideos extends AbstractModule.with(Video) {
get name () {
return 'xVideos';
}
Expand Down
9 changes: 4 additions & 5 deletions src/Pornsearch.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Axios from 'axios';
import Cheerio from 'cheerio';

import Modules from './Core/Modules';
import Modules from '@/Core/Modules';

const GIF = 'gif';
const PARSER = 'Parser';
Expand Down Expand Up @@ -51,13 +50,13 @@ class Pornsearch {
}

driver (query, driver = 'pornhub') {
const SearchModule = this.modules[driver.toLowerCase()];
const PornModule = this.modules[driver.toLowerCase()];

if (!SearchModule) {
if (!PornModule) {
throw new Error(`We don't support ${driver} by now =/`);
}

this.module = new SearchModule(query);
this.module = new PornModule(query);

return this;
}
Expand Down
10 changes: 10 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ module.exports = {
entry: {
app: './src/Pornsearch.js'
},

resolve: {
alias: {
'@': path.resolve(__dirname, 'src')
}
},

target: 'node',

module: {
loaders: [
{
Expand All @@ -15,9 +23,11 @@ module.exports = {
}
]
},

plugins: [
new UglifyJsPlugin({ comments: false })
],

output: {
filename: 'pornsearch.min.js',
path: path.resolve(__dirname, './dist'),
Expand Down