-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added translation visualization by showing pictures ffrom urls
- Loading branch information
Showing
15 changed files
with
443 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package player | ||
|
||
import ( | ||
"os/exec" | ||
"strings" | ||
) | ||
|
||
const ( | ||
separator = " " | ||
) | ||
|
||
type Player struct { | ||
player string | ||
params []string | ||
} | ||
|
||
func New(player string) Player { | ||
parts := strings.Split(player, separator) | ||
playerExec := parts[0] | ||
params := parts[1:] | ||
return Player{ | ||
params: params, | ||
player: playerExec, | ||
} | ||
} | ||
|
||
func (p Player) Play(url string) error { | ||
params := append(p.params[:len(p.params):len(p.params)], url) | ||
cmd := exec.Command(p.player, params...) | ||
if err := cmd.Start(); err != nil { | ||
return err | ||
} | ||
if err := cmd.Wait(); err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package browser | ||
|
||
import ( | ||
"net/url" | ||
"os/exec" | ||
"runtime" | ||
) | ||
|
||
func open(u *url.URL) error { | ||
var cmd string | ||
var args []string | ||
switch runtime.GOOS { | ||
case "windows": | ||
cmd = "cmd" | ||
args = []string{"/c", "start"} | ||
case "darwin": | ||
cmd = "open" | ||
default: // "linux", "freebsd", "openbsd", "netbsd" | ||
cmd = "xdg-open" | ||
} | ||
args = append(args, u.String()) | ||
return exec.Command(cmd, args...).Start() | ||
} | ||
|
||
type Visualizer func(u *url.URL) error | ||
|
||
func (v Visualizer) Show(u *url.URL) error { | ||
return v(u) | ||
} | ||
|
||
func New() Visualizer { | ||
return Visualizer(open) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.