Saturday, May 9th, 2009 02:32 am
my smug is a great and powerful smug
So, while going about my documenting of core2 the other day, I realized abruptly I had an obsession, and it was to write a function forcing the username under the userpic so I could stop having to write out the three div classes the latest one takes.
Okay, see, this has been a week of documentation adventures.
Hi, welcome to my geek! You may see a lot of this.
The thing is, I like organizing things. That's why I like coding. It's soothing and zen-inducing and it relaxes me. So I said I'd start working on the hierarchy tables for core2 and break down the layout pages so they didn't look like a special dark hell.
So that was like, early this week. I got Core 2 source, opened it, and started top to bottom taking it apart to organize it in a way that made it easier for the user (ie, me) to see a property in a simple function that's stuffed into a method of a class that's tossed into a layout with divs everywhere. I thought it would take a day or two to take everything apart, a day or two to put it in order, then I'd put it up and start adding explanations and documentation.
I greatly underestimated core2.
I made a folder, then started changing file names thematically, because I ran into two problems.
1.) The way I wanted to organize it was utterly, completely impossible.
2.) Hey, did you see how long that thing is? Weirdly, I did too and I still thought it would only take a day or two.
To give a bit more context, I currently have about eighty separate txt files for this split by class, function, and relationships. Yeah. I have no idea what I was thinking.
After a couple of days of thinking, I started just putting up things to see how they looked, and that's when I figured out how I wanted to organize it. The problem came up, however, when I realized that while I could understand what was going on, explaining it would be--unusual.
So this is going interestingly. It's incredibly fun, but it's also something I can't start working on unless I don't want to do anything else for the night, because once I start, I don't really--stop. For like, the bathroom.
We'll call this documentation farr.
Anyway, the current format is pretty much thus:
Hierarchy
First, a breakdown of Page:print() by function--this is the layout of your page. It's the one with HTML at the top. Then a breakdown of Page::print_entry(), which are the basis all the page entries. I was going to add the one that does the layout of comments--yes, that is separate, go figure--but I'm not entirely convinced these two should be on the same page yet, and there are several variations of the comments that probably need to go together.
This is where I came upon the problem I'd thought I could put off or give to someone else--that every function is made up of smaller functions, and those smaller functions are made up of properties and if statements. I can read them fine. But--example.
print_time function--that seems easy, right? It prints date and time on your DW. I thought, okay, lets follow thsi one back to its source.
Print Time Functions
You see how I was mildly disturbed. And I still need someone to explain how to use properties to set the type of time you want--short, medium, or long. I know it can be done. But even using the set function, I cannot figure out how. Which is why I coded mine directly onto the function.
Anyway, this isn't--let me repeat--isn't complete, nor does it explain anything really yet. Mostly, right now I'm organizing the information and trying to find the best way to introduce whoever reads it to what is going on. I learn by doing, literally, which means before I explain what anything does, I have to feel comfortable using it. And that means not only breaking it down, but being able to take it apart and write my own functions using it. I've found in general if I can't use it, there is no way I can make sense of it.
I have to admit, it's a lot easier to learn something like this. Granted, it's confusing, but I feel my sense of accomplishment when I work out how to set print_time from attributes and not go near the function at all will be spectacular.
Now my evening triumph--writing a function that works! You would think this wouldn't have taken as long as it did, but well, there you go.
First off, in my defense, I didn't know to prefix the function name with lay_ and two, I really didn't get the complex relationship between classes and functions until I was pulling apart core2 and realized that print_time appeared in three separate classes. Why, I wondered, would you do that? As it turns out, because print_time in User class and print_time in EntryLite are totally different.
I'd go into the horror that was realizing I couldn't easily mix and match functions from different classes, but we'll save that for another day when I'm not still flushed with triumph.
After a couple of days of frustration, I contacted
avelah and isabeau, both of whom gave me clues to what was wrong--the class problem above, one, and two, the lay thing. And then, finally, after hours of frustration, I realized I'd declared incorrectly and then, boom.
So if anyone can use it, a quick and easy way to stack userpic on top of username, even with short names, which let me tell you, was kind of driving me nuts.
This can only be added to layout layers. I put my functions just below the layerinfo.
Function:
This goes in Page::print_entry():
The CSS:
For context, this is what I'm using on my flist with this:
To the left is subject, then date beneath it, and the far right is the userpic and username. Basically, I'm remaking my LJ flist style, as it is easy for me to read and follow along. Slowly.
Okay, see, this has been a week of documentation adventures.
Hi, welcome to my geek! You may see a lot of this.
The thing is, I like organizing things. That's why I like coding. It's soothing and zen-inducing and it relaxes me. So I said I'd start working on the hierarchy tables for core2 and break down the layout pages so they didn't look like a special dark hell.
So that was like, early this week. I got Core 2 source, opened it, and started top to bottom taking it apart to organize it in a way that made it easier for the user (ie, me) to see a property in a simple function that's stuffed into a method of a class that's tossed into a layout with divs everywhere. I thought it would take a day or two to take everything apart, a day or two to put it in order, then I'd put it up and start adding explanations and documentation.
I greatly underestimated core2.
I made a folder, then started changing file names thematically, because I ran into two problems.
1.) The way I wanted to organize it was utterly, completely impossible.
2.) Hey, did you see how long that thing is? Weirdly, I did too and I still thought it would only take a day or two.
To give a bit more context, I currently have about eighty separate txt files for this split by class, function, and relationships. Yeah. I have no idea what I was thinking.
After a couple of days of thinking, I started just putting up things to see how they looked, and that's when I figured out how I wanted to organize it. The problem came up, however, when I realized that while I could understand what was going on, explaining it would be--unusual.
So this is going interestingly. It's incredibly fun, but it's also something I can't start working on unless I don't want to do anything else for the night, because once I start, I don't really--stop. For like, the bathroom.
We'll call this documentation farr.
Anyway, the current format is pretty much thus:
Hierarchy
First, a breakdown of Page:print() by function--this is the layout of your page. It's the one with HTML at the top. Then a breakdown of Page::print_entry(), which are the basis all the page entries. I was going to add the one that does the layout of comments--yes, that is separate, go figure--but I'm not entirely convinced these two should be on the same page yet, and there are several variations of the comments that probably need to go together.
This is where I came upon the problem I'd thought I could put off or give to someone else--that every function is made up of smaller functions, and those smaller functions are made up of properties and if statements. I can read them fine. But--example.
print_time function--that seems easy, right? It prints date and time on your DW. I thought, okay, lets follow thsi one back to its source.
Print Time Functions
You see how I was mildly disturbed. And I still need someone to explain how to use properties to set the type of time you want--short, medium, or long. I know it can be done. But even using the set function, I cannot figure out how. Which is why I coded mine directly onto the function.
Anyway, this isn't--let me repeat--isn't complete, nor does it explain anything really yet. Mostly, right now I'm organizing the information and trying to find the best way to introduce whoever reads it to what is going on. I learn by doing, literally, which means before I explain what anything does, I have to feel comfortable using it. And that means not only breaking it down, but being able to take it apart and write my own functions using it. I've found in general if I can't use it, there is no way I can make sense of it.
I have to admit, it's a lot easier to learn something like this. Granted, it's confusing, but I feel my sense of accomplishment when I work out how to set print_time from attributes and not go near the function at all will be spectacular.
Now my evening triumph--writing a function that works! You would think this wouldn't have taken as long as it did, but well, there you go.
First off, in my defense, I didn't know to prefix the function name with lay_ and two, I really didn't get the complex relationship between classes and functions until I was pulling apart core2 and realized that print_time appeared in three separate classes. Why, I wondered, would you do that? As it turns out, because print_time in User class and print_time in EntryLite are totally different.
I'd go into the horror that was realizing I couldn't easily mix and match functions from different classes, but we'll save that for another day when I'm not still flushed with triumph.
After a couple of days of frustration, I contacted
![[profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
So if anyone can use it, a quick and easy way to stack userpic on top of username, even with short names, which let me tell you, was kind of driving me nuts.
This can only be added to layout layers. I put my functions just below the layerinfo.
Function:
function Entry::lay_print_name_stack()
{
"""
<div class=eidentity>""";
"""<div class="rightid">""";
$this->print_userpic();
"""</div>""";
"""<div class="rightid">""";
$this->print_poster();
"""</div>""";
"""</div>""";
}
This goes in Page::print_entry():
$e->lay_print_name_stack();
The CSS:
.eidentity {
float:right;
text-align:right;
width: 150px;
}
.rightid{
float:right;
text-align:right;
width:150px;
}
For context, this is what I'm using on my flist with this:
"""<div class="eheader">""";
$e->lay_print_name_stack();
"""<div class="subject">""";
$e->print_metatypes();
$e->print_subject();
"""</div>""";
"""<div class="datetime">""";
$e->print_time("long", "short");
"""</div>""";
"""</div>""";
To the left is subject, then date beneath it, and the far right is the userpic and username. Basically, I'm remaking my LJ flist style, as it is easy for me to read and follow along. Slowly.
no subject
From:(- reply to this
- thread
- link
)
no subject
From:(- reply to this
- parent
- top thread
- link
)
no subject
From:Seriously, I now grasp perl 200% better.
I mean, my knowledge of perl is pretty miniscule, but you have expanded it!
(- reply to this
- thread
- link
)
no subject
From:The challenge is to not panic every time I see a variable where I could swear a variable should not be. *g* It's pretty neat. Though granted, I'm still not sure why for the love of God we really need to chain function to class. It makes it so much more complicated to combine them. I mean, I know there's a reason not to just let the functions be Free and Wild Like the Bears of the North or whatever, but I'm not seeing it yet, so it's--frustrating.
(- reply to this
- parent
- thread
- top thread
- link
)
no subject
From:But python does this with classes, too, sort of. You should try python. It's so lovely, really. It's like learning Spanish after trying to learn French. Suddenly everything's easy.
(- reply to this
- parent
- thread
- top thread
- link
)
no subject
From:I have like a list of languages I want to at least know enough to read the code correctly. Though granted, LOLCode is the one I am saving for a day I want to giggle hysterically during.
(- reply to this
- parent
- thread
- top thread
- link
)
no subject
From:(- reply to this
- parent
- thread
- top thread
- link
)
no subject
From:(- reply to this
- parent
- top thread
- link
)
no subject
From:(- reply to this
- parent
- top thread
- link
)