Thought system

Nao

  • Dadman with a boy
  • Posts: 16,082
Thought system
« on October 31st, 2011, 11:08 PM »
Okay, I'll be opening this topic to discuss the upcoming thought system...

For those of you who aren't in our Friends group, you can't access thoughts in here, so I'll redirect you to noisen.com where you can see a list of thoughts on the homepage.

Basically, it's a chatbox, only it doesn't have all that Ajax stuff that makes it look like it's real time and mostly puts a lot more load on your server.

I'm about halfway through my implementation for Wedge. I rewrote a lot of it, and added some features which may or may not work.

- Privacy: determine whether you want your thoughts to be visible to everyone, just members, just your friends, or just you (e.g. a to-do...)
- Edit ANY of your thoughts, including older 'latest thought' or your replies to others' thoughts.
- The latest thought is now in the sidebar. You can either edit it, or write a new one (there are links for that.)
- If you edit a current thought, if the new version has less than 10% differing from the old thought, the original publishing date will be kept. Otherwise, the thought's publishing date is set to now. (This is different from the current implementation where a 20% difference will generate a new timestamp, also it allows you to edit anything.)
- I've removed the 'Default Personal Text' option which means nothing to me... And to anyone else, I'd venture into saying. (Hey, Pete isn't the only one entitled to deleting SMF crap :P)
- Users can no longer set their Personal Text in their profile, if only because they can now set it from any page in the sidebar...

The privacy stuff only has the UI implemented. The 'edit everything' code is barely started, so it doesn't work.
The JavaScript adds an extra couple of kilobytes to script.js, which bothers me a bit (though it'll probably be more like 500 bytes once minified an gzipped), but OTOH it's a pretty neat feature so I think it's best to have it as default...

I'm a bit stumped with storing the latest thought though. Right now I'm storing something like "1500|My thought" in the members table where 1500 is the thought's ID, so that I can easily tell Wedge whether we're currently editing the latest thought (by putting its ID into an invisible part of the form) or simply writing a new thought that looks a lot like an earlier one (in which case the ID is set to 0 at this point.)
I don't want (too much) to get rid of personal_text because some people may not want to use the thought system and still have their old SMF-imported personal text below their avatar and stuff. But I think that storing the thought ID as a 'hack' inside the personal_text itself is not exactly pretty.

Open to any suggestions... I'm off to bed, this weekend was hectic.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Thought system
« Reply #1, on October 31st, 2011, 11:11 PM »
I should add, it's a touch more than a chat box, it's actually closer to FB or Twitter - but only on your site for your members.

We have a surprising number of discussions that don't really warrant a topic of their own, and it's one of the reasons I post so little on FB or Twitter, is because mostly it has a relevance and context that it wouldn't have elsewhere.
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Thought system
« Reply #2, on October 31st, 2011, 11:25 PM »
I'm considering adding an option to send any of your public thoughts to twitter as well. If you are willing to enter your twitter password because I'm not willing to start playing with their API anyway :P
It's just that I never use twitter so it's no priority to me.

Did you understand my question on the field stuff? :^^;:

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Thought system
« Reply #3, on October 31st, 2011, 11:27 PM »
Quote
I'm considering adding an option to send any of your public thoughts to twitter as well. If you are willing to enter your twitter password because I'm not willing to start playing with their API anyway
Um, I don't think you can do that any more, any time I've had a third party app of any description attempt it, it's taken me to Twitter to approve the application, which means it needs an auth key. If you're allowing user integration you must already have one anyway ;)

I did notice the implied question but I don't have a better answer short of storing the two details separately in the members table.

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Thought system
« Reply #4, on October 31st, 2011, 11:32 PM »
- you mean a website can't connect to them using a regular username and pw? You mean they willfully broke many sites?

- it's just that it's only a cache of sorts. If I store the Id I might as well loafd the thought from the thoughts table... Ah well.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Thought system
« Reply #5, on October 31st, 2011, 11:34 PM »
Quote
- you mean a website can't connect to them using a regular username and pw? You mean they willfully broke many sites?
Oh yes. It's amazing what happens you say 'XSS vulnerability' and 'account abuse' enough times. Every app that connects to Twitter does so using OAuth now.
Quote
- it's just that it's only a cache of sorts. If I store the Id I might as well loafd the thought from the thoughts table... Ah well.
Saves time, and it means another table not joined, thus another table not locked, less I/O, faster queries etc.

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Thought system
« Reply #6, on November 1st, 2011, 05:17 AM »
Xss like sniffing the pw over the network?
Anyway that makes it unlikely I'll work on twitter support. Although we should maybe add hooks to enable a tweet plugin to catch thoughts and tweet them.

Hmm as for personal text I'm still not sure what's best. Storing Id in a new field without a key, or having the hack thing and doing an explode on member load...

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Thought system
« Reply #7, on November 1st, 2011, 09:00 AM »
XSS like abusing the crap out of you sending your username and password to spam Twitter. Which would be ironic if it weren't for the fact it was spamming malware links.

It would probably be better to have it as two separate columns for performance.

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Thought system
« Reply #8, on November 1st, 2011, 10:08 AM »
Kay then.

The member table is so huge, I'd just rather not add fields that aren't gonna be used by everyone.

Didnt we have plans for a generic joined sister table to remove weight from it btw?

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Thought system
« Reply #9, on November 1st, 2011, 10:25 AM »
There's several fields in the members table already that you could argue about, e.g. pm prefs, notify prefs.

Splitting those off into a separate table might not be a bad idea, they're not required that often in reality.

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Thought system
« Reply #10, on November 1st, 2011, 10:43 AM »
The question would only be-- would it hurt performance if we joined that table on every member lookup?

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Thought system
« Reply #11, on November 1st, 2011, 10:49 AM »
Yes, yes it would.

That's why it's important to figure out whether it's truly needed on every member lookup - or if it's not, when it is actually used.

For example, the pm prefs and notify prefs are only called for when handling PMs and notifications respectively, and putting them in a separate table probably isn't going to make a lot of difference (though, it gets complicated when figuring out the whole 'default setting' vs 'user setting' thing in that case without having an explicit row per user)

Whereas I can see the thought being pulled more often (like personal text is)

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Thought system
« Reply #12, on November 2nd, 2011, 11:15 PM »
WTF... The thought system is so complicated now ;)

Let's say I'm writing a new thought, and set it with a privacy value > 0, meaning 'not public'.
Wedge will record the ID and text in the member table, so that I can quickly get back my latest thought on each page load.

However, when it comes to showing the latest thought under your avatar in topic pages... How exactly is Wedge supposed to know whether it CAN show it to everyone? Does it mean storing the privacy value in the member table as well...? Or use some hack, like storing a negative value of the id_thought, meaning 'the absolute value of this is the actual id_thought, and I don't want anyone to see this thought in a post'?
Heck, I should probably have a potential privacy value saying 'public, but don't show under my avatar'... :^^;:

PS: id_thought is now stored in the member table as implied above. It's mainly because it's really used on every page...

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Thought system
« Reply #13, on November 2nd, 2011, 11:37 PM »
Quote
However, when it comes to showing the latest thought under your avatar in topic pages... How exactly is Wedge supposed to know whether it CAN show it to everyone?
That's actually really easy, IMO.

Store the most recent, publicly visible one in the members table, and store the master record of everything in the table. You only need to retrieve the public one in topics, main profile etc., as everywhere else that uses thoughts will be doing so querying for privacy and thus will be using the main table anyway.

I like the idea of public/not under my profile. I'd probably use that all the time, actually - I personally find little or no benefit to having it in the post display as I have discussions etc. via the front page.

Nao

  • Dadman with a boy
  • Posts: 16,082
Re: Thought system
« Reply #14, on November 3rd, 2011, 07:47 AM »
It wouldn't work that way. Thoughts are shown: in topic pages, in profile pages (not done yet), and on the homepage (possibly later an SSI function as well). Only the topic pages will use the stuff we mentioned. However, the main use for that field, for me, is in the sidebar where your current thought is being shown. If we only store the latest public thought (which BTW may sound silly to members who then can't see your member thoughts under your avatar), this will disrupt the sidebar block.

That's why it's complicated.

As for 'not under my avatar', currently the options (public/members/friends/self, all written as of now) are shown in a select box, but if I want to enable users to say they don't want their stuff in the topic pages, I'd need to do one of these: either have a profile option to completely disable sharing on topic pages (this would also be the logical destination of a 'share public thoughts on Twitter' option), or replace the select box with an Ajax popup called through a 'privacy' icon, where you actually have a list of checkboxes: 'show in topic pages', 'show to everyone', 'show to members only', 'show to my friends only'. If you disable everything, it's the equivalent of 'self' in the select box. If you enable 'show to everyone' and 'show to my friends only', you're just a cunt :P

I can't tell you the number of times I rewrote the thought system since last week... :lol: And there's still a lot of work to do. I'm feeling like everytime I want to tackle a small task like thoughts, I end up spending ten times longer on it than I first expected. The exact same thing happened for the skeleton system which I originally thought would take only a couple of days to implement... :^^;: (Well, it DID take only a couple of days. To get it working. But it was very basic then.)

Ahh, midnight! The Cinderella effect has caught up with me, and I'm out of pumpkins.
Posted: November 3rd, 2011, 12:01 AM

(bump!)

Maybe I should commit my work in progress for now?
(It does not work well and I'd rather not.)