mirror of
https://github.com/thebaer/tildes.git
synced 2018-07-20 07:15:21 +00:00
Indicate directories and executable files
Directories get slash appended and color coding Other-executable files get color coding
This commit is contained in:
parent
968dcb54da
commit
b745d5c627
19
code.go
19
code.go
@ -38,6 +38,7 @@ type User struct {
|
||||
type Project struct {
|
||||
Name string
|
||||
Path string
|
||||
CssClass string
|
||||
}
|
||||
|
||||
func findProjects() map[string]User {
|
||||
@ -72,11 +73,25 @@ func mapFiles(files *[]string, users map[string]User) {
|
||||
// Ensure file is other-readable
|
||||
// TODO: just detect if we can actually read this, instead
|
||||
info, _ := os.Stat(path)
|
||||
if info.Mode() & 0004 == 0 {
|
||||
mode := info.Mode()
|
||||
if mode & 0004 == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
proj := &Project{Name: fname, Path: strings.Replace(path, "/home/", "~", -1)}
|
||||
// Mark directories vs. regular files
|
||||
cssClass := "file"
|
||||
if mode.IsDir() {
|
||||
path = path + "/"
|
||||
fname = fname + "/"
|
||||
cssClass = "dir"
|
||||
}
|
||||
|
||||
// Check if files are executable by all
|
||||
if mode & 0001 != 0 {
|
||||
cssClass = cssClass + " exec"
|
||||
}
|
||||
|
||||
proj := &Project{Name: fname, Path: strings.Replace(path, "/home/", "~", -1), CssClass: cssClass}
|
||||
u, exists := users[uname]
|
||||
if !exists {
|
||||
fmt.Printf("Found %s for ~%s.\n", pparts[3], uname)
|
||||
|
@ -5,6 +5,20 @@
|
||||
<title>{{.FolderName}} on {{.Host}}</title>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="tilde.css" />
|
||||
<style type="text/css">
|
||||
.dir {
|
||||
font-weight: bold;
|
||||
color: #00BFFF;
|
||||
}
|
||||
.file.exec {
|
||||
font-weight: bold;
|
||||
color: #FFD700;
|
||||
}
|
||||
.fullDir {
|
||||
color: #aaa;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body id="hello">
|
||||
@ -17,7 +31,7 @@
|
||||
<div class="links">
|
||||
<ul class="links">
|
||||
{{range .Projects}}
|
||||
<li><strong>{{.Name}}</strong> · {{.Path}}</li>
|
||||
<li><span class="{{.CssClass}}">{{.Name}}</span> <span class="fullDir">· {{.Path}}</span></li>
|
||||
{{end}}
|
||||
</ul>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user