From: Ralph D. <ra...@ma...> - 2003-10-11 01:49:33
|
I'm an experienced programmer, fairly adept with PHP, moderately so with MySQL, but I have done very little with Perl, and had never touched mod_perl or CPAN until a few days ago. Nevertheless, I installed Slash earlier this week on FreeBSD 4.7 and it seems to be working very nicely! My compliments to the team for making it amazingly easy to get started. The installation was essentially painless. I fiddled around a bit with the Apache configuration and with getting the daemon started, but I never felt confused or overwhelmed. I still can't quite believe the code that runs Slashdot is working on my computer. Anyway... I've modified a few templates, with the expected results and no problems. Now, however, I want to make another modest layout change but can't seem to figure out how to do it. It sounds so easy that I'm embarrassed to admit I'm stumped. I just want to move the "Read More" link. Instead of having the user click on a text link, (Read More... | 10 of 22 comments) I would prefer an icon right in the body of the story. The templates involved are 121, 169, and 88. (Aside: where do the numbers come from?) The "Read More" link is generated in template 169 by [% links.join(' | ') %] and I understand that the vertical bar is being specified as a separator between the generated links. Yet I can't seem to get any deeper than this to find the code for a simple link to the story page. I tried to follow the call to links.join by grepping for "sub links" in the templates directory, but did not find anything. Is it a method call? I do see links = arrayref of links but that does not illuminate anything for me right now. I know I will figure this out eventually but I'm wimping out and asking for help. I do intend to learn my way around the system and I just want a little hint. If I've missed some relevant and maybe obvious piece of documentation, let me know and I will go away and happily study it. I bought the O'Reilly Slash book and it's been quite useful. Thank you in advance. Regards, Ralph |
From: shane <sh...@lo...> - 2003-10-11 11:39:24
|
On Friday 10 October 2003 21:48, Ralph Dratman wrote: >[...] >My compliments to the team for > making it amazingly easy to get started >[...] Glad it went well for ya. It's funny how I rarely see people saying this. Because if you've got the correct perl stuff installed (I guess I should say the requrements installed and setup) Slash'll install easily, which in a way is dumbfounding, you'd think it woudln't be this easy. >[...] > I just want to move the "Read More" link. Instead of having the user > click on a text link, > > (Read More... | 10 of 22 comments) > > I would prefer an icon right in the body of the story. > > The templates involved are 121, 169, and 88. (Aside: where do the > numbers come from?) Don't refer to templates via the #'s. The numbers are different for every installation - they are from the auto_increment field. Refer to them by name;page;section ie mysql> select tpid,name,page,section from templates where tpid=121 or tpid=169 or tpid=88; +------+-----------+---------+---------+ | tpid | name | page | section | +------+-----------+---------+---------+ | 88 | subEdUser | submit | default | | 121 | list | faqster | default | | 169 | calculate | stats | default | +------+-----------+---------+---------+ 3 rows in set (0.00 sec) so you'd want to say subEdUser;submit;default because you may also have in your db (depending on what theme you chose when you installed your site) subEdUser;submit;light , etc etc. > The "Read More" link is generated in template 169 by > > [% links.join(' | ') %] > > and I understand that the vertical bar is being specified as a > separator between the generated links. Yet I can't seem to get any > deeper than this to find the code for a simple link to the story page. > I tried to follow the call to links.join by grepping for "sub links" > in the templates directory, but did not find anything. Is it a method > call? I do see > > links = arrayref of links > > but that does not illuminate anything for me right now. snippets from slash/themes/slashshcode/htdocs/index.pl while ($story = shift @$stories) { my($tmpreturn, $other, @links); push @links, linkStory({ 'link' => $msg->{readmore}, sid => $story->{sid}, tid => $story->{tid}, section => $story->{section} }, "", $ls_other); So it's the template linkStory\;misc\;default that you need to look at first off. Then at the end of index.pl it's calling storylink\;index\;default that has in it: [% FOREACH storylinks = links; IF storylinks.ref == 'ARRAY' %] <A HREF="[% storylinks.0 | strip_attribute %]"[% IF storylinks.2 %] TI TLE="[% storylinks.2 | strip_attribute %]"[% END %]>[% storylinks.1 %] </A> [% ELSE; storylinks; END %] [% UNLESS loop.last %] | [% END %] [% END %] So I think you'll want to become familiar with those two templates. > I know I will figure this out eventually but I'm wimping out and > asking for help. I do intend to learn my way around the system and I > just want a little hint. Nah. There's tons of people wondering how to do the same thing. They just never send anything to the list. Excellent question. > If I've missed some relevant and maybe obvious piece of > documentation, let me know and I will go away and happily study it. I > bought the O'Reilly Slash book and it's been quite useful. Nah, good job. The best part is that you started grepping for it. Many times that is the *easiest* way to find something. Shane |
From: Alessio B. <al...@se...> - 2003-10-12 16:33:31
|
On Sat, 2003-10-11 at 04:48, Ralph Dratman wrote: > I just want to move the "Read More" link. > The templates involved are 121, 169, and 88. (Aside: where do the > numbers come from?) More or less "random", actually the internal auto-increment serial number used in the MySQL database. If you insert all templates in the same order you should have predictable numbers, but that's not guaranteed. > I tried to follow the call to links.join by grepping for "sub links" > in the templates directory, but did not find anything. Is it a method > call? Yes, it's in htdocs/index.pl around line 250, at least in the 2.2.6 codebase I still use. I routinely comment the link that says "xxx bytes in body". -- Alessio Bragadini <al...@se...> Sevenseas.org -- Cyprus chapter |
From: Ralph D. <ra...@ma...> - 2003-10-18 04:50:42
|
Thanks to all who helped me out with the "Read More..." link a few days ago. I can now navigate most references in and out of the template system. The full methodology (essentially, the template bracket-reference semantics) is still not totally obvious to me, but I can manage. Moving forward with another adaptation, I would like to associate a COLOR with each TOPIC. I want this color to be used for the title bar of each story for that topic. Leaving aside the various implementation details, the obvious way to accomplish this is to add a color field to the topic table. However, the Slash book cautions me against such a course of action, lest my version become incompatible with future upgrades. The topic table is unlikely to acquire more than a few hundred rows. To me, simply adding one or a few new fields to such a table doesn't sound like it would be very much of a handicap in upgrades. Maybe I would need to do a few extra manual steps to add the field(s) and their data back in after the upgrade - something along those lines. On the other hand, maybe someone can suggest a reasonable way to provide an easily configurable color for each topic -- without adding any fields to the topic table. Any comments? Thanks in advance. Regards, Ralph |
From: shane <sh...@lo...> - 2003-10-18 12:33:36
|
On Saturday 18 October 2003 00:46, Ralph Dratman wrote: >[...] >I would like to associate a > COLOR with each TOPIC. I want this color to be used for the title bar > of each story for that topic. > > Leaving aside the various implementation details, the obvious way to > accomplish this is to add a color field to the topic table. I think that's how I'd do it to. However, how would you handle it when a story has multiple-topics associated with it? |
From: Cliff <cl...@sl...> - 2003-10-18 15:46:27
|
On Saturday 18 October 2003 07:15, shane wrote: > On Saturday 18 October 2003 00:46, Ralph Dratman wrote: > >[...] > >I would like to associate a > > COLOR with each TOPIC. I want this color to be used for the > > title bar of each story for that topic. > > > > Leaving aside the various implementation details, the obvious > > way to accomplish this is to add a color field to the topic > > table. > > I think that's how I'd do it to. However, how would you handle it > when a story has multiple-topics associated with it? That's easy. Just use the topic associated with the story, as that is the official one. Here's something that will really bake your noodle: What if topic colors can vary by section. I think a better idea would be to use a separate table, that way this functionality can be limited to a plugin and not stomped on by the changes you'd need to implement it in core Slash. - Cliff |
From: Ralph D. <ra...@ma...> - 2003-10-19 09:04:30
|
Thanks to Cliff and Shane for comments about the color changes by Topic. Unfortunately, I don't have any funding for a plugin at the moment. Maybe later, if things work out with the site. As I think about this color requirement, I realize that I may have been wrong to assume that I need Topic colors. Although Topics seem logical for what I have in mind, I guess I should consider using Sections since they already can have colors associated with them. Why do Section colors currently show up only when one is actually browsing within a particular section, rather than when sections are mixed into the main area? The key point - and I apologize for not making this clear before - is that I need to mix colors on the main page. Each Story must be assigned to a grouping which has its own color. What would it take to mix colors on the main page, with different story colors right there, depending on each story's Section - or Topic - or something? Regards, Ralph |
From: shane <sh...@lo...> - 2003-10-20 11:33:41
|
On Saturday 18 October 2003 21:57, Ralph Dratman wrote: > Thanks to Cliff and Shane for comments about the color changes by Topic. > > Unfortunately, I don't have any funding for a plugin at the moment. > Maybe later, if things work out with the site. > > As I think about this color requirement, I realize that I may have > been wrong to assume that I need Topic colors. Although Topics seem > logical for what I have in mind, I guess I should consider using > Sections since they already can have colors associated with them. > > Why do Section colors currently show up only when one is actually > browsing within a particular section, rather than when sections are > mixed into the main area? They're not mixed. When you look at the index page of most slash-based websites, it shows stories and slashboxes. The stories it shows are the latested N (depending on users_index.maxstories), and depending on whether or not the latest stories are marked as 'show in section only'. So when the index page is generated, that is actually generating the page for 'section=index'. When you click on a story that's in a 'stories' section, then you're viewing any templates that are marked as section=stories, and that's where you get your cosmetic changes. > The key point - and I apologize for not making this clear before - is > that I need to mix colors on the main page. Each Story must be > assigned to a grouping which has its own color. Are the colors random? Do they need to always be the same given topic __n___? Are they shown by story # {1..n}? Need more info here. > What would it take to mix colors on the main page, with different > story colors right there, depending on each story's Section - or > Topic - or something? That's the question - what do you want it to depend on? That affects what/where you'd have to change in the src and/or templates. Shane |
From: Ralph D. <ra...@ma...> - 2003-10-20 17:28:48
|
Shane, I want each story on the index page to be colored by either its Topic (best solution) or by its Section (okay solution). The colors are not supposed to be random or anything like that. It's like having topic icons. I just want topic colors instead. Or else section colors, but on the index page. Regards, Ralph |
From: Cliff <cl...@sl...> - 2003-10-20 20:11:28
|
On Monday 20 October 2003 07:17, shane wrote: > > The key point - and I apologize for not making this clear before > > - is that I need to mix colors on the main page. Each Story must > > be assigned to a grouping which has its own color. > > Are the colors random? Do they need to always be the same given > topic __n___? Are they shown by story # {1..n}? Need more info > here. > > > What would it take to mix colors on the main page, with > > different story colors right there, depending on each story's > > Section - or Topic - or something? > > That's the question - what do you want it to depend on? That > affects what/where you'd have to change in the src and/or > templates. Another question is how many topics you are planning on having. To be honest, I don't think using sections to do this would be the right way to go, since you'll have to pull the section colors for *each story* for any container sections you'll be displaying, not to mention that the section colors are loaded into the $user object auto-magically by Slash, so to use sections, you'd have to fight the existing code to make it work (means more chance for unexpected bugs). Sections are another thing that I'm not so sure people have a good grasp on yet. Sections recently changed around to formalize some of those features that had rapidly evolved in Slash. A section can be a 'container' type or it can be a "collection" (type == 'collected'). The index page is an example of a "collection" section, as it "collects" stories from other specified secitons. 'container' types are sections like Slashdot's YRO, and Ask Slashdot. They only "contain" stories of a specific genre. So your color changes really need only apply to the "collected" type of section. I honestly see a real easy way to do what is necessary, but I'm not sure how well it would affect performance. If I can code something up that looks like it will work, during my spare time, I'll send what I have out to the list. - Cliff |
From: Ralph D. <ra...@ma...> - 2003-10-22 03:40:53
|
>Another question is how many topics you are planning on >having. Cliff, I need around fifty topics in the early stages, I think. Obviously, distinguishable colors run out at some point, so there are diminishing returns in the purely visual realm. If the number of topics grows beyond a hundred or so, the distinguisable colors start repeating. But I would really like to be able to handle even more topics... and I must admit I'm unclear how that number could affect the performance, given that database access must be nearly constant up to a much larger number than that, no? (Obviously I don't know enough to know!) >...I honestly see a real easy way to do what is >necessary, but I'm not sure how well it would affect performance. With sections or with topics? To me, topics would be more logical, and I also have a very good use for sections that is (as the book suggests) orthogonal to the topics. >If I can code something up that looks like it will work, during my >spare time, I'll send what I have out to the list. Thank you. That's very generous, even to consider doing so. In case you don't get that far, please give me a preview of your concept. I'm furiously studying the template documentation, and I guess I'll have to bite the bullet and become a real Perl person, too. Sigh... But it's all worth it, I think, to be able to use this impressive system. And if I have to (mildly) fork my version by adding a field or another table, I'm really not all that concerned right now. Based on past experience, I'll probably want to "start over" at some point down the road anyway (if this whole thing works out) and at that time I could incorporate the latest SlashCode revs. Regards, Ralph |