Website building/coding?

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

User avatar
Quantum Potatoid
Posts: 141
Joined: Mon Aug 06, 2007 1:15 am UTC
Location: May only be known if velocity isn't. Same rules apply with taste and texture.

Website building/coding?

Postby Quantum Potatoid » Mon Apr 09, 2012 1:46 am UTC

Hey xkcd fora.
I am a second year computer science major, and to branch out a bit, I decided to give creating a website a go.
I managed to learn how to use HTML, CSS, and Javascript, but how would I go about learning more about website building and the conventions themselves?
Like, I had to go searching around in order to figure out that one needs to name a file index.html or index.php to replace the directory tree display with an actual web page.
Another example: How would I be able to template a page, so that I wouldn't need to use copypasta to put the main website interface on every page? It would be inconvenient to have to go through every page to edit in changes to the main interface. Randall for example, with >1000 pages of xkcd. (I'm working on the PHP.)
And other examples you could probably imagine.

Most searches only yield pages about the programming and markup languages themselves, or ads for web design software.

I'm using a text-editor, Text Wrangler, by the way.
Here is the embryonic website thus far. I'm holding off development a little 'till I know more, so I don't make any design flaws that carry over later. You know how software development can be. :B
http://alexandstein.com/
Thanks for any help!
"There's nothing wrong with having voices in your head, it's when they leave you out of the conversation you have to worry"
Spoiler:
iThis Cheese is Burning Me!

BombSite_A
Posts: 5
Joined: Sun Apr 01, 2012 10:08 pm UTC

Re: Website building/coding?

Postby BombSite_A » Mon Apr 09, 2012 2:31 am UTC

I like ASP .net. You can put bits of C# code inside the HTML using CSHTML; this, however, is not required and you can build a site fine without knowing any C#. The tool to build the site, WebMatrix, is really useful for setting up and running your site. It's not a very good IDE for debugging purposes though: it doesn't catch errors that will stop it from compiling. It's free though. :)
Here's a link if you're interested: http://www.microsoft.com/web/webmatrix/
Last edited by BombSite_A on Mon Apr 09, 2012 10:24 pm UTC, edited 1 time in total.

User avatar
Xanthir
My HERO!!!
Posts: 5426
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: Website building/coding?

Postby Xanthir » Mon Apr 09, 2012 3:12 am UTC

Unfortunately, I don't really know where to go to learn about general web-mastering. All of my knowledge came from random articles and blogs.

Quantum Potatoid wrote:Another example: How would I be able to template a page, so that I wouldn't need to use copypasta to put the main website interface on every page? It would be inconvenient to have to go through every page to edit in changes to the main interface. Randall for example, with >1000 pages of xkcd. (I'm working on the PHP.)

You need to learn a server-side language. The simplest to use is probably PHP.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

Sagekilla
Posts: 382
Joined: Fri Aug 21, 2009 1:02 am UTC
Location: Long Island, NY

Re: Website building/coding?

Postby Sagekilla » Mon Apr 09, 2012 3:42 am UTC

BombSite_A wrote:I like ASP .net. You can put bits of C# code inside the HTML using CSHTML; this, however, is not required and you can build a site fine without knowing and C#. The tool to build the site, WebMatrix, is really useful for setting up and running your site. It's not a very good IDE for debugging purposes though: it doesn't catch errors that will stop it from compiling. It's free though. :)
Here's a link if you're interested: http://www.microsoft.com/web/webmatrix/


I'm writing a web app in ASP.NET MVC right now. God do I love how nice it is. Razor syntax makes it actually
really easy to create dynamic pages. And you get 1-click site deployment via Web Deploy.

I'd have to disagree about the debugging though -- if you build using Visual Studio 2010 Web Express, the debugger
built in is very nice. Don't bother with WebMatrix. It's nice for simple things, but the Web Express version of VS is
much nicer and gives you full control. You can step through page generation and if you're willing to put up with using
Internet Explorer, you can debug the client side code as well.

Better yet, since you're a CS student sign up for Microsoft DreamSpark (which is free for students). Then you can use
VS 2010 Ultimate edition. Strictly speaking, it might not be different from the Web Express edition for you. But once
you get into it, the extra features come in handy.

Quantum Potatoid wrote:Another example: How would I be able to template a page, so that I wouldn't need to use copypasta to put the main website interface on every page? It would be inconvenient to have to go through every page to edit in changes to the main interface. Randall for example, with >1000 pages of xkcd. (I'm working on the PHP.)


If you wanted to do "template" pages, ASP.NET MVC supports that via their "layout" pages. You can define the general
layout and programatically define where to render sections of a page. You can use this to compose the various parts of
the pages if you want.
http://en.wikipedia.org/wiki/DSV_Alvin#Sinking wrote:Researchers found a cheese sandwich which exhibited no visible signs of decomposition, and was in fact eaten.

Ankit1010
Posts: 135
Joined: Fri Feb 11, 2011 11:32 am UTC

Re: Website building/coding?

Postby Ankit1010 » Mon Apr 09, 2012 4:08 am UTC

I'd highly recommend learning Ruby-on-Rails. For a simple website, you don't have to worry about the details of administering a server, you can just focus on making the web application itself. It's also becoming increasingly popular in the community because of how easy it is to pick up. I picked it up in about a week from this tutorial - http://ruby.railstutorial.org/ruby-on-r ... orial-book (its free to read online, and you can order a hardcopy if you like). It's a very good tutorial, it'll teach you everything you need to know about how the framework and the Ruby language works.

RoR is very similar to ASP.NET - they both use the MVC paradigm, you put C# inside HTML with ASP.NET, Ruby code inside HTML with RoR (templating engines), and there many other similarities. Personally, I'd recommend RoR over ASP.NET just because you can use it with a unix stack, so its bound to come in handy with internships, jobs etc. later. I'm a junior at college too, and since I made a few apps in RoR, I've gotten a LOT more opportunities, from recruiters, researching grad students/professors and in projects in classes. Unix based servers are more prevalent in the industry, and you'll also pick up the basics of unix commands, shell scripting etc., which IMHO is invaluable if you don't already know that stuff.

User avatar
Rium
Posts: 70
Joined: Sat Feb 04, 2012 12:57 am UTC

Re: Website building/coding?

Postby Rium » Mon Apr 09, 2012 12:53 pm UTC

You sound a lot like me. I had the same question regarding templates; Google led me to this, which is really simple but probably not suitable for templates beyond header and footer. I think I’ll have to learn PHP for this, or maybe either Ruby on Rails or ASP.net (thanks for the links).

Oh, and is there a better way to put your files on a webserver than one by one with FileZilla?

User avatar
freakish777
Posts: 354
Joined: Wed Jul 13, 2011 2:14 pm UTC

Re: Website building/coding?

Postby freakish777 » Mon Apr 09, 2012 6:34 pm UTC

The first question to ask, is what type of servers are you using (or planning on using/have access to)? *nix or Windows?

After that, you have have a potentially a myriad of choices (in Unix/Linux) or only a couple (in Windows) as to your "stack."

A common Linux stack is LAMP (Linux, Apache, MySql, PHP), because there are free versions of every piece of software you need. A lot of people see the front end of a website and go "oh I can see this is made with HTML, Javascript, and CSS, so that must be all there is to websites, right?" Nope. You need a server side language (PHP/C#/Java/etc), and if you're doing business of any kind, a database as well (MS SQL Server, MySQL, Oracle, Amazon SimpleDB... or :shudders: SAP).

A stack is basically what technologies are you stacking on top of each other for each layer/level (User Interface, Server, Database).

Good for you if you've learned some HTML, Javascript and CSS. The next thing you'll want to do is learn about a Server Side language that will run on the servers you're able to work with. The User Interface layer is great to learn about, but on it's own won't be very useful unless you're making a site that reads like a newspaper and provides no way for your users to interact outside of just consuming the content you display to them.

If you've got lots of money, you could completely go about creating websites with your stack being Windows Server 2012, MS SQL Server 2012, ASP.NET 4 all running on a SharePoint environment. Chances are you don't have a couple million sitting around to make that happen though.

Being a college student, I assume the LAMP stack is probably the more reasonable approach for you. If you have access to Windows Servers, and already know C++, then going to C#/ASP.NET should be fairly simple.

User avatar
Quantum Potatoid
Posts: 141
Joined: Mon Aug 06, 2007 1:15 am UTC
Location: May only be known if velocity isn't. Same rules apply with taste and texture.

Re: Website building/coding?

Postby Quantum Potatoid » Mon Apr 09, 2012 8:24 pm UTC

Thanks for all the suggestions, guys! Yeah, being a college student I don't have a lot to spend.
Oh, I forgot to add, here is the site that's running the servers I'm using: http://www.namecheap.com/web-hosting/web-hosting.aspx
I'm under the "Professional" plan.
Any suggested PHP resources, since you all have a lot to say on server-side script?
Currently, I'm learning PHP from http://www.w3schools.com/.
"There's nothing wrong with having voices in your head, it's when they leave you out of the conversation you have to worry"
Spoiler:
iThis Cheese is Burning Me!

Ankit1010
Posts: 135
Joined: Fri Feb 11, 2011 11:32 am UTC

Re: Website building/coding?

Postby Ankit1010 » Tue Apr 10, 2012 12:47 pm UTC

Quantum Potatoid wrote:Thanks for all the suggestions, guys! Yeah, being a college student I don't have a lot to spend.
Oh, I forgot to add, here is the site that's running the servers I'm using: http://www.namecheap.com/web-hosting/web-hosting.aspx
I'm under the "Professional" plan.
Any suggested PHP resources, since you all have a lot to say on server-side script?
Currently, I'm learning PHP from http://www.w3schools.com/.


http://www.w3schools.com is not a good site to learn from - it has a lot of mistakes and you might end up spending a lot of time clearing up misconceptions that the site gave you if you stick with this for a while. Check out http://w3fools.com/, it explains more about why it's a bad idea to learn from there. Personally, I think its useful for a quick reference if you already know PHP, but not while you're just starting out learning this stuff.

Also, you mentioned the trouble you had with conventions like the index.html page etc. You're having trouble with how to host your website, not how to make the site itself. It's helpful to know the difference because you'll have a much easier time figuring things out once you know what you're looking for. You should probably read more about the Apache webserver (which is probably what you're using to host the website).

gametaku
Posts: 148
Joined: Tue Dec 30, 2008 2:21 am UTC

Re: Website building/coding?

Postby gametaku » Tue Apr 10, 2012 3:36 pm UTC

freakish777 wrote:The first question to ask, is what type of servers are you using (or planning on using/have access to)? *nix or Windows?

After that, you have have a potentially a myriad of choices (in Unix/Linux) or only a couple (in Windows) as to your "stack."

A common Linux stack is LAMP (Linux, Apache, MySql, PHP), because there are free versions of every piece of software you need.


Um, there are free and cheap host for both Windows and Linux Stacks.


If you've got lots of money, you could completely go about creating websites with your stack being Windows Server 2012, MS SQL Server 2012, ASP.NET 4 all running on a SharePoint environment. Chances are you don't have a couple million sitting around to make that happen though.


Care to do a cost breakdown of that? oh and make sure to list an equivalent LAMP breakdown.



Being a college student, I assume the LAMP stack is probably the more reasonable approach for you. If you have access to Windows Servers, and already know C++, then going to C#/ASP.NET should be fairly simple.



On PHP:
http://me.veekun.com/blog/2012/04/09/ph ... ad-design/

From http://gcov.php.net/viewer.php?version=PHP_5_4
Build Status: OK
Last Build Time: 45 hours

Compile Warnings: 1105
Code Coverage: 70.2%
Test Failures: 97
Expected Test Failures: 44
Valgrind Reports: 58


Those results show PHP to be a sloppy, unprofessional product it is.

User avatar
Robert'); DROP TABLE *;
Posts: 730
Joined: Mon Sep 08, 2008 6:46 pm UTC
Location: in ur fieldz

Re: Website building/coding?

Postby Robert'); DROP TABLE *; » Tue Apr 10, 2012 5:07 pm UTC

gametaku wrote:Care to do a cost breakdown of that? oh and make sure to list an equivalent LAMP breakdown.

Windows Server 2008 (couldn't find 2012) on its own costs anywhere from $275 upwards. LAMP is free.
...And that is how we know the Earth to be banana-shaped.

User avatar
freakish777
Posts: 354
Joined: Wed Jul 13, 2011 2:14 pm UTC

Re: Website building/coding?

Postby freakish777 » Tue Apr 10, 2012 5:12 pm UTC

gametaku wrote:Um, there are free and cheap host for both Windows and Linux Stacks.


Wellllll... sorta. There isn't a free version of Windows Server. This is why Windows hosts tend to charge a little bit more than Linux hosts.


If you've got lots of money, you could completely go about creating websites with your stack being Windows Server 2012, MS SQL Server 2012, ASP.NET 4 all running on a SharePoint environment. Chances are you don't have a couple million sitting around to make that happen though.


Care to do a cost breakdown of that? oh and make sure to list an equivalent LAMP breakdown.




Sure:

SQL Server 2012 (Enterprise) licenses at $6,874 per core (you can replace this with MySQL and pay nothing, MySQL can be run on Windows Server and on Linux and is the M in LAMP).
C#/ASP.NET 4 are "free" (the analogs here since they aren't super similar are PHP which is free to C# and Apache which, I think, is free to ASP.NET, which is a very loose comparison, if you want a full version of Visual Studio instead of an Express version, then it's not free)
Server 2012 (Not 100% sure, I know that when Windows Server 2008 R2 came out, it ran about a $1000+ so I would guess it'll be about the same, typically you never pay for this yourself unless you're a company, and you let your host provide it for you, in the LAMP environment, this is Linux, the L, it's free).


SharePoint (this is the real expense in the Stack I mentioned, licensing agreement range from the "not so expensive", all internal intranet only options for companies, in the hundreds of thousands of dollars per environment, to the expensive with seat licensing agreements, where you need to record the number of visitors you have from the web that visit your Sharepoint environment, if you exceed the quota allowed to you in your seat licensing agreement, Microsoft is going to want to restructure that agreement and bump you up to the next threshold, this option can easily be above a million dollars).

There's a free version of Sharepoint, WSS3, however the EULA in it does not allow for any external visitors, it must be 100% internal users hitting your environment, there's decreased functionality in WSS3 and slightly different UIs, and there's basically no support for WSS3 anymore (all the MSDN articles have either been re-written to support Sharepoint instead, or have been removed entirely).



I should really point out, no one really "needs" Sharepoint in their stack, but if it were free, I wouldn't mind putting a lot of it's functionality is every site I made.

Oh, and there's no LAMP equivalent to Sharepoint, unless you want to write your own.

Sagekilla
Posts: 382
Joined: Fri Aug 21, 2009 1:02 am UTC
Location: Long Island, NY

Re: Website building/coding?

Postby Sagekilla » Tue Apr 10, 2012 7:20 pm UTC

freakish777 wrote:...



I'm a student, and I get free access to:
SQL Server 2005 - 2012 (every edition for each version)
Visual Studio 2005 - 2010 (again, same as above)
Just about every version of Windows

Most students can get the same exact thing. My university gives us free access to this software via a MSDN subscription,
but even if I didn't have that I can get nearly all of the same via DreamSpark.

Even if you didn't have access to this, there's no need to use enterprise level software. The project I'm working on now
could have been done just as easily within the Express edition of the software. Unless you're scaling up to massive traffic,
it really isn't necessary to have the expensive software.

Also, for the SharePoint -- From what I've heard interviewing at a number of .NET shops, it's not used as much as you'd think
for front-facing websites. Check on SO also, and you'll see that people try to avoid it as much as possible because it's a horrendous
piece of technology to work with.

tl;dr: Get all the software for web development free via Express editions which are still fully featured (I don't know why people don't
think they are) or via Microsoft DreamSpark as a student.
http://en.wikipedia.org/wiki/DSV_Alvin#Sinking wrote:Researchers found a cheese sandwich which exhibited no visible signs of decomposition, and was in fact eaten.

User avatar
freakish777
Posts: 354
Joined: Wed Jul 13, 2011 2:14 pm UTC

Re: Website building/coding?

Postby freakish777 » Tue Apr 10, 2012 8:44 pm UTC

Sagekilla wrote:I'm a student, and I get free access to:
SQL Server 2005 - 2012 (every edition for each version)
Visual Studio 2005 - 2010 (again, same as above)
Just about every version of Windows


Yes, Microsoft loves giving Universities free MSDN subscriptions. It's a good business practice and they reap the dividends (of the next generation of software engineers having grown up inside a Windows environment).


Even if you didn't have access to this, there's no need to use enterprise level software. The project I'm working on now
could have been done just as easily within the Express edition of the software. Unless you're scaling up to massive traffic,
it really isn't necessary to have the expensive software.


I concur.

That said, if money is your number one factor (as in, you have none), then going with Linux hosting (when you no longer have "free" perks due to being a university student) will decrease cost.

I'd like to point out here that I professionally work in a .NET environment, and have never worked (professionally or otherwise) in a LAMP environment (I've played with PHP once). I just know that if you were a start up company without a mega-star angel investor funding your first round of investment, you probably wouldn't be springing for a SQL Server server license and instead be thinking "How can I bring that cost down, oh MySQL is free, yes please."

Also, for the SharePoint -- From what I've heard interviewing at a number of .NET shops, it's not used as much as you'd think
for front-facing websites. Check on SO also, and you'll see that people try to avoid it as much as possible because it's a horrendous
piece of technology to work with.


It's not used a lot for public facing websites. Because doing so, Microsoft charges you through the nose.


If they didn't charge as much, it would be used a lot more. Using Sharepoint in place of current Content Management Systems would be ideal for a lot of businesses, if they're willing to undergo the growing pains of a migration.


Express editions which are still fully featured (I don't know why people don't
think they are)


Uhm... because they aren't fully featured? Only VS Ultimate has Intellitrace (not Intellisence, Intellitrace). Yes, Express gives you everything you need to get going and build and publish websites. Yes, Ultimate has a ton of stuff that the average, and even above average developer will never even touch because they don't know how to leverage it. But saying that Express is fully featured is simply not true.

User avatar
Rium
Posts: 70
Joined: Sat Feb 04, 2012 12:57 am UTC

Re: Website building/coding?

Postby Rium » Tue Apr 10, 2012 8:57 pm UTC


Are there any alternatives if I just want to do something like this?

User avatar
Yakk
Poster with most posts but no title.
Posts: 11129
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Website building/coding?

Postby Yakk » Tue Apr 10, 2012 10:48 pm UTC

Client Computer <-> Browser <-> HTTP <-> Server Port <-> Server <-> HTML

The server's job is to give a proper HTTP response to the Brower. How it does this is really arbitrary. A simple system involves a file system that mirrors the structure of the website, with files that it sends basically verbatim, and the type of the file (which the server sends in the HTTP headers) is determined by the extension of the file in the server's file system.

This is just a simple implementation. In theory, the Server can be running arbitrary code.

For the most part, you will want as much of the response that the Server generates to be "take this chunk of memory, and blit it out the port", because that requires the least amount of server power. And servers want to be able to serve as many clients as they can with as little power as possible. Other parts of the server will end up running code to determine what to send back to the client.

The simplest way to do this is known as CGI -- common gateway interface. It is a set of specs for the server to run shell scripts or executables when it gets an HTTP address formatted in a particular manner. This is also highly inefficient (as a new executable has to be launched each time, either to read the script or run the file), tends to be full of security holes (as random scripting languages and executables don't tend to have the worlds best sandboxing), and generally was a way to do cool stuff back in the 90s.

More advanced servers ended up including a scripting language in themselves. This saves the cost of launching a new executable for each request. In addition, by running a scripting language instead of an executable, we can constrain the kind of operations by the language itself, and avoid certain classes of security hole. In addition, these languages tend to be really good at "embedding" themselves within plain HTML output code. Some of them might optimize the fact that it can figure out that the next time, it will produce the same output, and avoid running the script again. There is also the HTTP headers themselves, which wraps both HTML and other data you are serving from your webpage.

Now, there is something else going on -- javascript. Way back in the paeleo era of the net, a simple scripting language was included. This is important, because it allows client webbrowsers to run code, instead of just running the code on the server. The features of javascript ended up being much more powerful than people initially thought -- javascript is what lets you asynchronously load part of a webpage, and have it update after the server finishes getting that data (google maps, for example, relied (and maybe still does?) on that technique to make it really responsive, with adaptive image updates. When it first game out, it was mind blowing that someone pulled that off in a browser!).

Finally, often webpages want to interact with data on the server. This often involves database access.

This means that when you build a webpage, you can easily be working in 5 languages at once -- declarative HTML, HTTP, Javascript, the server-side scripting language (be it perl, Ruby, PHP or C#), and some variant of SQL to be talking to the database back-end. And how these all interact ends up depending on how your server is set up. As it happens, HTML has this feature called CSS -- cascading style sheets -- that is a pretty good way to do layout. But it a lot like a different lingo than standard HTML. So I guess I should have said 6 languages at once?

Wait, you might use yet another language to generate some of the above (so you'd generate the script that generates the HTTP HTML and Javascript with embedded SQL calls). And you might have access to the source code of the SQL server, which is probably written in C or C++.
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.

User avatar
Quantum Potatoid
Posts: 141
Joined: Mon Aug 06, 2007 1:15 am UTC
Location: May only be known if velocity isn't. Same rules apply with taste and texture.

Re: Website building/coding?

Postby Quantum Potatoid » Sat Apr 21, 2012 7:14 am UTC

Thanks even more for the suggestions! I looked into thing more, and unfortunately it doesn't look like my host supports all of the listed languages. Here's what I've got from their site:

cPanel 11 (Stable build)
Apache 2.2.x
Perl 5.x.x
PHP 5 (PHP 5.x.x)
MySQL Ver 5 - standard for pc-linux-gnu on i686 (MySQL Community Edition — Standard (GPL))
Zend Optimizer ver. 3.x.x
They also have Python 2.6 installed, but looks like it's run using CGI, which I heard isn't too great.

And yeah, as a computer science major, I feel compelled to be against the idea of WYSIWYG editors, and much prefer text-based editing. I have TextWrangler for that. (http://www.barebones.com/products/textwrangler/)
I'm pretty excited about getting to expand my CS skills into web stuff, but it's all so overwhelming with all of these unfamiliar things! I've already gotten started in HTML and CSS, and will probably get going on PHP and Javascript soon.
Are there any more "first steps" suggested for me to take?
Also MySQL vs. PostgrSQL?
"There's nothing wrong with having voices in your head, it's when they leave you out of the conversation you have to worry"
Spoiler:
iThis Cheese is Burning Me!

sebwiers
Posts: 18
Joined: Sat Apr 21, 2012 3:12 pm UTC

Re: Website building/coding?

Postby sebwiers » Sat Apr 21, 2012 4:26 pm UTC

Quantum Potatoid wrote:I managed to learn how to use HTML, CSS, and Javascript, but how would I go about learning more about website building and the conventions themselves?


There's probably a billion books, you tube videos, and websites about that subject. As a CS student, you probably want to get into something with a bit more of a back end than just making static websites. That's all you get with HTML, CSS, and JS - no matter how interactive they are, the content for a given HTTP request never changes- there's no allowance for user-created content.

I learned PHP (and HTML / CSS / Javascript) on my own via a couple books, and now work as a web developer alongside some CSS guys and other auto-didacts. I still think the PHP Bible ( http://www.amazon.com/PHP-Bible-2nd-Edition-Converse/dp/0764549553 ) was one of the more valuable learning tools I used.

Also MySQL vs. PostgrSQL?


MySQL, just because its a (much) more widely popular system. For anything you'll need, its good enough. The main failing of mySQL tend to be related to the fact that its rather lightweight & freeform, so doesn't support some "best practice" enforcement and fails to optimize well for certain types of query.

If you do get into PHP, Codigniter might be worth a look. Its a small, fast, simple framework that will take care of a lot of the "how do I set things up" issues for you, and lets you work in (more of) a MVC paradigm than you'd get if you just started plunking down straight PHP. Having started out building web apps from scratch, I rather wish I'd know about (and how to use) such a framework.

Ben-oni
Posts: 278
Joined: Mon Sep 26, 2011 4:56 am UTC

Re: Website building/coding?

Postby Ben-oni » Sun Apr 22, 2012 8:41 am UTC

Xanthir wrote:Unfortunately, I don't really know where to go to learn about general web-mastering. All of my knowledge came from random articles and blogs.

Quantum Potatoid wrote:Another example: How would I be able to template a page, so that I wouldn't need to use copypasta to put the main website interface on every page? It would be inconvenient to have to go through every page to edit in changes to the main interface. Randall for example, with >1000 pages of xkcd. (I'm working on the PHP.)

You need to learn a server-side language. The simplest to use is probably PHP.


Actually, you don't. If you don't care about POST messages, that is. If your planned site will be nothing more than a series of static web pages, you can accomplish what you want with nothing more than the tools you already know.

Not that I recommend it, but if you just want to make things a little easier, you can do something like the following:

Code: Select all

# makefile

targets = index page1 page2 page3
header = header.html.part
footer = footer.html.part
www = /var/www

dests = $(patsubst %, $(www)/%.html, $(targets))

all: $(dests)
$(dests): $(header) $(footer)

$(www)/%.html: %.html.part
   cat $(header) $< $(footer) > $@


This sort of thing can relieve some of the burden of redundant html generation without overloading yourself with PHP, SQL, Perl, or any of that other stuff you'll learn eventually. And besides, it never hurts to understand makefiles a little better. In this example, a small change to the site format requires nothing more than editing "header.html.part", "footer.html.part", and a quick "make" to put everything together.

User avatar
Xanthir
My HERO!!!
Posts: 5426
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: Website building/coding?

Postby Xanthir » Sun Apr 22, 2012 4:32 pm UTC

Learning enough PHP to use the "include" command is easier than learning make files.

Code: Select all

<!DOCTYPE html>
<?php include("header.php"); ?>
<h1>My site!</h1>
<p>Stuff goes here.</p>
<?php include("footer.php") ?>


Where the header and footer files are ordinary HTML that just start with a "?>" to switch them into echo mode.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

Ben-oni
Posts: 278
Joined: Mon Sep 26, 2011 4:56 am UTC

Re: Website building/coding?

Postby Ben-oni » Mon Apr 23, 2012 8:26 pm UTC

Xanthir wrote:Learning enough PHP to use the "include" command is easier than learning make files.


While true, every programmer should know makefiles pretty well, whereas PHP is optional. And like I said, I'm really not recommending building a site like this. The only advantage it has is that it's not interpreted, so you can host it with a really lightweight http server. To that end, what I'm really suggesting is learning some principles of meta-programming: any language can be used to automate the generation of the final files, and I was just showing one way to do it using "cat". But please, don't. There are so many better tools available, or you can write your own.

User avatar
Steax
SecondTalon's Goon Squad
Posts: 3038
Joined: Sat Jan 12, 2008 12:18 pm UTC

Re: Website building/coding?

Postby Steax » Tue Apr 24, 2012 7:15 am UTC

As a PHP developer, I'll point at PHP. It has a lot of tutorials and libraries floating about, and it's a good place to learn the ropes as you get used to things. Once you learn the concepts behind server-side development, transitioning to other languages isn't very difficult. You'll spend the bulk of your time learning about security, how HTTP works, how to program for efficiency, how to store data, how to validate data, etc. Those are mostly portable between languages.

I personally run on the Flourish (models and utility), Moor (routing/controllers), and Twig (views/templating) libraries. They're not super-well-known, but they're pretty effective and I like them. Other favorites are CakePHP, or just building everything around Wordpress.

I will, as always, recommend the Coding Horror blog. It's great reading for web developers - even articles 8 years old. They give insight into simple matters that most people learn from experience but never document (this is, actually, the great thing about blogs in general). My routine dose of knowledge comes from Smashing Magazine.

Also, take look at LESS CSS, probably the most popular CSS sublanguage available. It lets you avoid repeating bits of CSS, which saves a lot of sanity. And of course, jQuery. Catch up to HTML 5 goodness at Dive Into HTML 5, though I think you've come across most of that already. Also worth noting are Node JS, which, to me, is a peek at the future, and the Twitter Bootstrap UI library, great for fast prototyping.

I apologize if I'm tossing too many links - these are just the pieces that make up my current workflow, and I really wish someone gave me all this when I started.

There are a lot of tiny tidbits that made me go "OOOOH so THAT'S how they did it" back then, but I can't remember most of them. The only one off the top of my head is that you can use (for apache) htaccess files for pretty URLs, like home/foo/bar/, instead of home-foo-bar.html. Also, look up "CSS media query" to learn how to adapt your site for mobile devices. I'll post more if I can think of them.

---------

Also, a note about the religious wars you'll inevitably run into: Don't worry about what you use, be it PHP, ASP.NET, RoR, Node or whatever. As long as you continuously learn your craft and surround yourself with allies and knowledge, you'll be perfectly fine. Programmers fighting about why X language is ugly are just bored or trying too hard. In fact, those articles are typically the most biased places to learn about why a language is bad. When in doubt, ask. xkcd is a great place for this.

(That last bit is in response to the link gametaku posted. Really, don't worry about this stuff. There are people everywhere trying to convince everyone that their language is horrible. PHP is very quirkly - something you'll notice early on. It's old and rusty. Yes. If you want something clean and organized, but more difficulty to find support for, there are many options. Like everything else in programming, there are quirks and oddities you'll struggle and pay for. Some more than others. But don't let this make you hesitate in making a decision. If you want to experiment and want widespread support, you probably want PHP for now. In the future, when you have your own server, you can pick up something else. Practically all web hosting services support PHP. I think that matters a lot.)
In Minecraft, I use the username Rirez.

User avatar
Rium
Posts: 70
Joined: Sat Feb 04, 2012 12:57 am UTC

Re: Website building/coding?

Postby Rium » Sat May 26, 2012 3:42 pm UTC

This thread has been very helpful for me. I have another question regarding PHP: Is it possible to edit a html file before including it? Say I have a html file that I want to include, but I need to add a few lines somewhere between <body> and </body>. I don’t want to alter the html file itself. Edit: After a few more minutes of googling, I learned that you can assign the output of include to a variable:

Code: Select all

$output = include './myinclude.php';
echo $output;

This looks like a solution to what I want. Sorry for not googling enough before posting!

Also, here’s what I found out regarding my earlier questions, maybe someone finds it useful:

Rium wrote:Oh, and is there a better way to put your files on a webserver than one by one with FileZilla?

Some IDEs allow you to publish files directly with a keyboard shortcut, or to sync files.

Rium wrote:Are there any alternatives [to PHP] if I just want to do something like this?

Not really. RoR and Django are probably overkill, and they appear to require root access, which you usually don’t have.

User avatar
Steax
SecondTalon's Goon Squad
Posts: 3038
Joined: Sat Jan 12, 2008 12:18 pm UTC

Re: Website building/coding?

Postby Steax » Sat May 26, 2012 4:04 pm UTC

You might (using some obscure function or library), but you probably shouldn't. You can either predefine a global variable before including, and the included file could read that, or just use 2 included files, before and after the optional bit (and optionally include a third file in between). Many websites, including thouse made by Wordpress, simply have a "header.php" file that includes everything before <body> (roughly), and "footer.php" that includes everything after.

The modern decision would be to use a templating engine, however.
In Minecraft, I use the username Rirez.

bittyx
Posts: 194
Joined: Tue Sep 25, 2007 9:10 pm UTC
Location: Belgrade, Serbia

Re: Website building/coding?

Postby bittyx » Sat May 26, 2012 11:22 pm UTC

Note that PHP itself already is a templating engine.

User avatar
Steax
SecondTalon's Goon Squad
Posts: 3038
Joined: Sat Jan 12, 2008 12:18 pm UTC

Re: Website building/coding?

Postby Steax » Sun May 27, 2012 12:55 am UTC

Yes. However, using a more fully-featured templating engine gives you more options to help in splitting views and content. They also tend to be more concise, they can usually compile anyway to native PHP, and often have features like sandboxing and injection protection built straight in.
In Minecraft, I use the username Rirez.

User avatar
Rium
Posts: 70
Joined: Sat Feb 04, 2012 12:57 am UTC

Re: Website building/coding?

Postby Rium » Tue Oct 09, 2012 10:00 pm UTC

Is it okay to ask more specific webdev-related questions here? I already posted to stackoverflow, but it got closed and I didn’t receive a helpful answer.

I encountered a problem that appears to be related to permissions (same as this one). When I looked at the permissions of various directories in FireFTP, they all were 0000, which is obviously nonsense, since all the other pages are served without any problems. I only have ftp access, and I think it’s a Windows server (The header says "Server: Microsoft-IIS/7.5").

I’ve tried a different ftp client, with the same result. Changing the permissions results in a "'SITE CHMOD 764 [directory]': command not understood" error. A search on Google and SO for "permissions windows 0000" and similar queries didn’t turn up anything. How can I view and change the actual permissions?

User avatar
WanderingLinguist
Posts: 237
Joined: Tue May 22, 2012 5:14 pm UTC
Location: Seoul
Contact:

Re: Website building/coding?

Postby WanderingLinguist » Wed Oct 10, 2012 9:57 am UTC

I won't go into detail, because a lot of folks already have, but:

1) jQuery has been mentioned, but I'll mention it again. Don't use vanilla Javascript; use jQuery. Must faster, easier, and it deals with cross-browser compatibility issues for you.

2) Keep it simple. I tend to prefer avoiding server-side stuff if I don't need it. It lets me use an offline copy without having to have the same stack locally. Depending on what you're doing, it may be simple enough to use CSS and jQuery for your templating. If you do, keep in mind that you should use a structure that still looks good if either jQuery or CSS are unavailable (this isn't just important for the user, but makes indexing by Google, etc. work better). I used to do a lot with ASP.NET and then with PHP, but these days I find that I'm doing almost everything in jQuery and just using PHP as a thin layer over content/database access, and for authentication. It makes it a whole lot easier to switch out the AJAX component for one that returns dummy data and deliver a totally self-contained local version of the site that others can play with. Of course, that can get out of hand quickly for a large-scale site, but I don't do large-scale sites any more (I'm still a software engineer, but I don't do web these days, except for fun).

3) Since you mentioned TextWrangler, I assume you're on a Mac. TextWrangler is good, but even better is Aptana Studio. You can download it for Mac directly, or if you happen to use Eclipse (you mentioned you are a CS major, so I guess you might have it), you can get it as an Eclipse plugin. It basically does what TextWrangler does (basic text editing, syntax highlighting, etc.) but it adds things like code completion, previewing HTML color codes, etc. Code completion is invaluable when you're trying to learn CSS, JavaScript, jQuery, HTML and PHP all at once. (I, too, hate WYSIWYG editors for web programming)


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 8 guests