diff --git a/bin/_ttbp.py b/bin/_ttbp.py index ee6b92d..94684da 100644 --- a/bin/_ttbp.py +++ b/bin/_ttbp.py @@ -271,6 +271,7 @@ def main_menu(): redraw() today = time.strftime("%Y%m%d") write_entry(os.path.join(DATA, today+".txt")) + www_neighbors(find_ttbps()) elif choice == '1': redraw("here are your recorded feels, listed by date:\n\n") view_own() @@ -341,7 +342,6 @@ def view_neighbors(users): files = os.listdir(os.path.join("/home", user, ".ttbp", "entries")) files.sort() for filename in files: - #if os.path.splitext(filename)[1] == ".txt" and len(os.path.splitext(filename)[0]) == 8: if core.valid(filename): count += 1 lastfile = os.path.join("/home", user, ".ttbp", "entries", filename) @@ -532,6 +532,42 @@ def find_ttbps(): return users +def www_neighbors(users): + # takes a raw list of valid users and formats for www view + + userList = [] + + for user in users: + userRC = json.load(open(os.path.join("/home", user, ".ttbp", "config", "ttbprc"))) + url = LIVE+user+"/"+userRC["publish dir"] + count = 0 + lastfile = "" + files = os.listdir(os.path.join("/home", user, ".ttbp", "entries")) + files.sort() + for filename in files: + if core.valid(filename): + count += 1 + lastfile = os.path.join("/home", user, ".ttbp", "entries", filename) + + ago = "never" + if lastfile: + last = os.path.getctime(lastfile) + since = time.time()-last + ago = util.pretty_time(int(since)) + " ago" + else: + last = 0 + + userList.append(["~"+user+" ("+ago+")", last]) + + # sort user by most recent entry + userList.sort(key = lambda userdata:userdata[1]) + userList.reverse() + sortedUsers = [] + for user in userList: + sortedUsers.append(user[0]) + + core.write_global_feed(sortedUsers) + def list_select(options, prompt): # runs the prompt for the list until a valid index is imputted diff --git a/bin/core.py b/bin/core.py index 3909e23..04997c3 100644 --- a/bin/core.py +++ b/bin/core.py @@ -16,6 +16,7 @@ LIVE = "http://tilde.town/~" WWW = os.path.join(PATH, "www") CONFIG = os.path.join(PATH, "config") DATA = os.path.join(PATH, "entries") +FEED = os.path.join(SOURCE, "www", "index.html") HEADER = "" FOOTER = "" @@ -175,6 +176,52 @@ def valid(filename): return True +def write_global_feed(blogList): + # takes an array of the current global blog status and prints it to + # set www + + outfile = open(FEED, "w") + + ## header + outfile.write("""\ + + + + tilde.town global feels engine + + + +

tilde.town feels engine

+ +

github + repo | state + of the ttbp

+

curious? run ~endorphant/bin/ttbp while logged in to tilde.town.

+

it's still a little volatile. let me know if anything breaks.

+

 

+ +

live feels-sharing:

+
+ +
+ + +""") + + outfile.close() + ############# ############# diff --git a/bin/www b/bin/www new file mode 120000 index 0000000..61882c2 --- /dev/null +++ b/bin/www @@ -0,0 +1 @@ +/home/endorphant/public_html/ttbp/ \ No newline at end of file