Skip to content

Commit

Permalink
[update] refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
imthaghost committed Feb 25, 2021
1 parent 0264b72 commit 8fa193f
Show file tree
Hide file tree
Showing 32 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.DS_Store
.vscode
.env
parser/domains.csv
pkg/parser/domains.csv
dist
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p align="center">
<a href="https://goclone.herokuapp.com/">
<img alt="jedi" src="docs/media/logo.png">
<img alt="jedi" src="pkg/docs/media/logo.png">
</a>
</p>
<p align="center">
Expand All @@ -16,7 +16,7 @@ Copy websites to your computer! Goclone is a utility that allows you to download
</p>
<br>

![Example](/docs/media/colab.gif)
![Example](/pkg/docs/media/colab.gif)

## Table of Contents
- [Installation](#installation)
Expand Down Expand Up @@ -59,7 +59,7 @@ go install

Visit the <b>Notion</b> link [here](https://www.notion.so/0f3cb918168b48ffa5072c6ee39281ee?v=5330c26bd2d747dfac07882347b4a1df) to view Goclone's feature/bug progress.

![Notion](/docs/media/progress.png)
![Notion](/pkg/docs/media/progress.png)

<a name="examples"></a>

Expand All @@ -70,7 +70,7 @@ Visit the <b>Notion</b> link [here](https://www.notion.so/0f3cb918168b48ffa5072c
goclone https://dribbble.com
```

![Dribbble](/docs/media/dribbble.gif)
![Dribbble](/pkg/docs/media/dribbble.gif)

<a name="license"></a>

Expand Down
45 changes: 23 additions & 22 deletions cmd/clone.go → cmd/goclone/clone.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package cmd
package goclone

import (
"fmt"

"os/exec"

"github.com/imthaghost/goclone/crawler"
"github.com/imthaghost/goclone/file"
"github.com/imthaghost/goclone/html"
"github.com/imthaghost/goclone/parser"
"github.com/imthaghost/goclone/server"
"github.com/imthaghost/goclone/pkg/crawler"
"github.com/imthaghost/goclone/pkg/file"
"github.com/imthaghost/goclone/pkg/html"
"github.com/imthaghost/goclone/pkg/parser"
"github.com/imthaghost/goclone/pkg/server"
)

// Clone the given site :)
Expand All @@ -23,33 +24,33 @@ func cloneSite(args []string) {
// use the domain as the project name
name := url
// CreateProject
projectpath := file.CreateProject(name)
projectPath := file.CreateProject(name)
// create the url
validURL := parser.CreateURL(name)
// Crawler
crawler.Crawl(validURL, projectpath)
crawler.Crawl(validURL, projectPath)
// Restructure html
html.LinkRestructure(projectpath)
html.LinkRestructure(projectPath)
err := exec.Command("open", "http://localhost:5000").Start()
if err != nil {
panic(err)
}
server.Serve(projectpath)
server.Serve(projectPath)

} else if parser.ValidateURL(url) {
// get the hostname
name := parser.GetDomain(url)
// create project
projectpath := file.CreateProject(name)
projectPath := file.CreateProject(name)
// Crawler
crawler.Crawl(url, projectpath)
crawler.Crawl(url, projectPath)
// Restructure html
html.LinkRestructure(projectpath)
html.LinkRestructure(projectPath)
err := exec.Command("open", "http://localhost:5000").Start()
if err != nil {
panic(err)
}
server.Serve(projectpath)
server.Serve(projectPath)
} else {
fmt.Print(url)
}
Expand All @@ -61,16 +62,16 @@ func cloneSite(args []string) {
// use the domain as the project name
name := url
// CreateProject
projectpath := file.CreateProject(name)
projectPath := file.CreateProject(name)
// create the url
validURL := parser.CreateURL(name)
// Crawler
crawler.Crawl(validURL, projectpath)
crawler.Crawl(validURL, projectPath)
// Restructure html
html.LinkRestructure(projectpath)
html.LinkRestructure(projectPath)
if Open {
// automatically open project
err := exec.Command("open", projectpath+"/index.html").Start()
err := exec.Command("open", projectPath+"/index.html").Start()
if err != nil {
panic(err)
}
Expand All @@ -80,13 +81,13 @@ func cloneSite(args []string) {
// get the hostname
name := parser.GetDomain(url)
// create project
projectpath := file.CreateProject(name)
projectPath := file.CreateProject(name)
// Crawler
crawler.Crawl(url, projectpath)
crawler.Crawl(url, projectPath)
// Restructure html
html.LinkRestructure(projectpath)
html.LinkRestructure(projectPath)
if Open {
err := exec.Command("open", projectpath+"/index.html").Start()
err := exec.Command("open", projectPath+"/index.html").Start()
if err != nil {
panic(err)
}
Expand Down
7 changes: 2 additions & 5 deletions cmd/root.go → cmd/goclone/root.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package cmd
package goclone

import (
"log"
"os"

"github.com/spf13/cobra"
"log"
)

var (
Expand Down Expand Up @@ -45,6 +43,5 @@ func Execute() {
// Execute the command :)
if err := rootCmd.Execute(); err != nil {
log.Fatal(err)
os.Exit(1)
}
}
9 changes: 9 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package main

import (
"github.com/imthaghost/goclone/cmd/goclone"
)

func main() {
goclone.Execute()
}
7 changes: 0 additions & 7 deletions main.go

This file was deleted.

File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion crawler/extractor.go → pkg/crawler/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"os"
"path/filepath"

"github.com/imthaghost/goclone/parser"
"github.com/imthaghost/goclone/pkg/parser"
)

// file extension map for directing files to their proper directory in O(1) time
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 8fa193f

Please sign in to comment.