2024-05-15 23:37:42 +00:00
|
|
|
package slowtwitch
|
|
|
|
|
2024-05-20 01:35:53 +00:00
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
)
|
2024-05-15 23:37:42 +00:00
|
|
|
|
|
|
|
func ConvertUrlToCategoryFormat(oldUrl string) string {
|
2024-05-17 18:49:55 +00:00
|
|
|
output := convert(oldUrl)
|
2024-05-15 23:37:42 +00:00
|
|
|
|
2024-05-16 18:50:53 +00:00
|
|
|
return "/" + output + "/index.html"
|
2024-05-15 23:37:42 +00:00
|
|
|
}
|
|
|
|
|
2024-05-17 18:49:55 +00:00
|
|
|
func ConvertPostTitleToPath(title string, id int) string {
|
|
|
|
output := convert(title)
|
2024-05-20 01:35:53 +00:00
|
|
|
return output + "_" + strconv.Itoa(id) + ".html"
|
2024-05-17 18:49:55 +00:00
|
|
|
}
|
|
|
|
|
2024-05-15 23:37:42 +00:00
|
|
|
func GetURL(path string) string {
|
2024-05-17 18:49:55 +00:00
|
|
|
return "https://www.slowtwitch.com" + path
|
|
|
|
}
|
|
|
|
|
|
|
|
func convert(path string) string {
|
|
|
|
output := strings.ReplaceAll(path, " ", "_")
|
|
|
|
output = strings.ReplaceAll(output, "$", "_")
|
|
|
|
output = strings.ReplaceAll(output, "(", "_")
|
|
|
|
output = strings.ReplaceAll(output, ")", "_")
|
2024-05-20 01:35:53 +00:00
|
|
|
output = strings.ReplaceAll(output, "?", "")
|
|
|
|
output = strings.ReplaceAll(output, ",", "")
|
2024-05-17 18:49:55 +00:00
|
|
|
return output
|
2024-05-15 23:37:42 +00:00
|
|
|
}
|