Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
IAmKale
Jun 7, 2007

やらないか

Fun Shoe
I'm working on my first API right now (using Django Rest Framework) and I have a general question about crafting a usable API. First off, I'm trying to make this API for a webapp that could potentially be used by employees from multiple companies. Obviously I need to set up permissions to prevent employees from Company A from modifying entries for Company B.

Right now I've been working with verbose routes like /companies/1/locations/2/requests. However, I realized this morning I could simplify things and just make a basic /requests/ route and then use the employee's token (that they're submitting for authentication) to look up the employee's company and/or location. The simpler route would also make it easier for SPA's to interact with the API as no one would have to know what company or location an employee is when CRUD'ing requests. Is this a good design decision?

IAmKale fucked around with this message at 18:50 on Apr 16, 2015

Adbot
ADBOT LOVES YOU

Data Graham
Dec 28, 2009

📈📊🍪😋



Certainly. Having a less verbose URL path

a) makes it harder to guess the structure of your internal data, which is better for security
b) makes it impossible for anyone to even try to access data they're not supposed to
c) makes the URL way more concise and usable and less prone to errors
d) reduces your testing workload

Simply put, I don't know if I can think of any upsides to having any explicit constraints in your URL that you can't infer from the request.

v1nce
Sep 19, 2004

Plant your brassicas in may and cover them in mulch.

Data Graham posted:

Anybody know how the CSS class/ID name style standard managed to settle on "object-name" rather than "object_name" or "objectName" like in every other context?
Use Hyphens in CSS article goes into some detail on why camelCase fell by the wayside compared to hyphenated-case.
The main argument is readability, however the ability to use partial CSS selectors (class*='col-') is quite useful, too.

The only argument I've seen for uderscore_case vs hyphenated-case is that using an underscore requires the use of the shift key. Hyphenated is equally readable and easier to type.

Data Graham posted:

Hyphenated names make me itchy, because some languages (including JS) always want to try to subtract poo poo.
E: I mean I assume it's because CSS properties follow the hyphenated style, but that annoys me for the same reason (having to expose them in JS with alternative camelcased versions like backgroundColor).
I really don't understand how this is a problem. In what manner are you interacting with your CSS identifiers where JS has to manipulate them as strings?
We've been moving more and more of our code to using "[data-something='whatever']" selectors for use by our JavaScript to identify elements, and for storing data relevant to that javascript (data-id="1"). This way we never have the problem of a designer "tweaking" the CSS and blowing up our application.

v1nce fucked around with this message at 00:31 on Apr 17, 2015

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
So, I've been thinking about a thing. I was experimenting with AppCache so that I can create a little talk about it soon, and I feel like there's a part of the spec which closes off a range of web applications unnecessarily.

When you load a page with a manifest the page that referenced it is implicitly cached. For single page apps where index.html is a specific base with no updating data this is good behaviour, however implicit caching of the master page ruins any benefit you could get from using application cache, push state paths, and server side rendering.

Ideally the spec would be able to support this in a completely backwards compatible way, just adding a flag that prevents caching the master page, coupled with a fallback path to a html page, something like:

code:
# manifest version

CACHE:
# files to explicitly cache

SETTINGS:
no-master-cache=/offline-index.html
So when you visit a page, you get the server side rendered page unless the connection fails, otherwise it pulls index.html and uses that to do the render, coupled with all the application code you would list within CACHE. So you end up with a small offline tradeoff by requiring an initial request, but then you are guaranteed an up to date prerender if the server can provide it.

Now, I guess, I feel like I'm a little late to the party on the discussion of it within the HTML specification, but I feel like this change is a really important one to actually make it a reliable option for a range of applications.

Where do I go from here? Do I bitch and moan and complain? Do I create a community group?

I've never done this sort of thing, but working with offline stuff is something I'm very interested in using and improving through libraries and resources, making use of LocalStorage, IndexedDb, WebSQL and so on. What should I be doing to further this?

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION

v1nce posted:

We've been moving more and more of our code to using "[data-something='whatever']" selectors for use by our JavaScript to identify elements, and for storing data relevant to that javascript (data-id="1"). This way we never have the problem of a designer "tweaking" the CSS and blowing up our application.

This is a Good and Cool way to do things and you are right for doing it that way.

me your dad
Jul 25, 2006

What CSS property would I use to prevent words from breaking and hyphenating in different display sizes? Basically, if a word is too long, it should break to a new line.

I'm seeing instances where a period at the end of a sentence is breaking into its own line, which leaves things looking pretty bad. Longer words at the end of a line are breaking with a hyphen, where I would rather the whole word simply shift down a line.

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
CSS only unfortunately doesn't have the best support but here it is. https://developer.mozilla.org/en-US/docs/Web/CSS/word-break

me your dad
Jul 25, 2006

Thanks. To make matters worse, it's for an email :negative:

I fixed part of it but some clients, like Apple Mail and Outlook 2011 are hyphenating a word which in other clients is just moved entirely to its own line.

Dr. Poz
Sep 8, 2003

Dr. Poz just diagnosed you with a serious case of being a pussy. Now get back out there and hit them till you can't remember your kid's name.

Pillbug

me your dad posted:

Thanks. To make matters worse, it's for an email :negative:

I fixed part of it but some clients, like Apple Mail and Outlook 2011 are hyphenating a word which in other clients is just moved entirely to its own line.

Oh, you poor soul. This is the best possible resource I have found for dealing with the world of poo poo that is CSS rendering in email clients. I hope it gives you some measure of peace. It won't. :(

Heskie
Aug 10, 2002

me your dad posted:

What CSS property would I use to prevent words from breaking and hyphenating in different display sizes? Basically, if a word is too long, it should break to a new line.

Whenever I've had to do this I've put a nbsp between the two words instead of a space. They'll then wrap together as a single word.

Its not the most elegant solution, sure, but its simple and works.

fuf
Sep 12, 2004

haha
Is there a way to calculate an even gap between inline list items but with the first and last items flush with the edges of the container? Like this but with even gaps?
http://jsfiddle.net/qx4wde29/

Leshy
Jun 21, 2004

Yes, that is exactly what the flexbox layout system is for. See http://jsfiddle.net/ujrk8Lcj/.

Edit: VV No problem! See https://css-tricks.com/snippets/css/a-guide-to-flexbox/ for some more info on flexbox and its properties.

Leshy fucked around with this message at 17:10 on Apr 18, 2015

fuf
Sep 12, 2004

haha
haha so that's what flexbox means. That's awesome, thanks.

chami
Mar 28, 2011

Keep it classy, boys~
Fun Shoe

fuf posted:

haha so that's what flexbox means. That's awesome, thanks.

Universal support for flexbox can't come soon enough.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

chami posted:

Universal support for flexbox can't come soon enough.

When does IE10 end of life?

The Merkinman
Apr 22, 2007

I sell only quality merkins. What is a merkin you ask? Why, it's a wig for your genitals!

Lumpy posted:

When does IE10 end of life?

January 12th 2016

-JS-
Jun 1, 2004

fuf posted:

Is there a way to calculate an even gap between inline list items but with the first and last items flush with the edges of the container? Like this but with even gaps?
http://jsfiddle.net/qx4wde29/

While we're waiting for solid Flexbox support, try this - scroll down to where it says "UPDATE: Using inline-block and justified text"

Spatulater bro!
Aug 19, 2003

Punch! Punch! Punch!

IE10 supports flexbox. It just uses the inbetween syntax. Unless you need to support IE9, you can use flexbox now

kedo
Nov 27, 2007

caiman posted:

IE10 supports flexbox. It just uses the inbetween syntax. Unless you need to support IE9, you can use flexbox now

Hmmm. This may be reason enough for me to drop IE 9 support. The use rate is already low enough as it is for the type of sites I'm working on.

v1nce
Sep 19, 2004

Plant your brassicas in may and cover them in mulch.

kedo posted:

Hmmm. This may be reason enough for me to drop IE 9 support. The use rate is already low enough as it is for the type of sites I'm working on.
Speaking as someone who still has to work with IE8, I would say you should feel free to drop IE9 support, but it's preferable if a site is still compatible.
The big difference being that when you support a browser it should look correct in that browser. When your site is merely compatible, it should look like it's not on fire, and you can use your next-best-guess for anything that the browser doesn't support.

Obviously that's up to you, based on your site and your audience stats, but this is something I would encourage people to learn to do, while crappy versions of IE still have an annoyingly high market share.

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
And luckily with conditional comments, you can force in some pretty reasonable fallbacks if you can't do it with a single stylesheet.

Spatulater bro!
Aug 19, 2003

Punch! Punch! Punch!

Deployment woes. I'm currently using grunt-ftp-deploy, but there are two things I'd like to be different:

1. When I make a change to only 1 file, I'd like ONLY that 1 file to get pushed to the server.
2. When I deploy the entire site, I want any files/folders I've deleted locally to automatically be deleted on the server.

Is something like Beanstalk the solution I'm looking for?

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

caiman posted:

Deployment woes. I'm currently using grunt-ftp-deploy, but there are two things I'd like to be different:

1. When I make a change to only 1 file, I'd like ONLY that 1 file to get pushed to the server.
2. When I deploy the entire site, I want any files/folders I've deleted locally to automatically be deleted on the server.

Is something like Beanstalk the solution I'm looking for?

use rsync. It does exactly that thing you just said.

Something like rsync -a --delete my_dir user@some.server.com:/path/to/put/things


EDIT: or the more obvious, correct answer: use version control and just hg pull (or whatever the git version is) on the server.

Lumpy fucked around with this message at 16:42 on Apr 21, 2015

Spatulater bro!
Aug 19, 2003

Punch! Punch! Punch!

Lumpy posted:

EDIT: or the more obvious, correct answer: use version control and just hg pull (or whatever the git version is) on the server.

This is essentially what services like Beanstalk do for me, right?

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

caiman posted:

This is essentially what services like Beanstalk do for me, right?

I have no idea. Is there a reason you need a service to do it for you versus just using version control?

mpaarating
May 6, 2011

The Baddest Boi

caiman posted:

This is essentially what services like Beanstalk do for me, right?

Things like Beanstalk do a whole lot more than that. They typically have a lot of configuration that needs setup up front but then doesn't need to be touched for similar environments.

Spatulater bro!
Aug 19, 2003

Punch! Punch! Punch!

Lumpy posted:

I have no idea. Is there a reason you need a service to do it for you versus just using version control?

No. Beanstalk, if I understand it correctly, is all about version control. It hosts your git repo and takes care of deployment for you.

Vintersorg
Mar 3, 2004

President of
the Brendan Fraser
Fan Club



After learning Wordpress inside out and loving it we've inherited a site built in Drupal and I want to tear my hair out. This system seems super unintuitive and support outside the Drupal forums is hardly there (compared to Wordpress).

Or maybe im going mental.

Im having trouble with a few things like the Calendar (https://www.drupal.org/project/calendar) and breadcrumbs. I have no idea where I can set these (ideally it would be whatever page im declaring the top menu). Diving into the PHP seems fruitless too.

If there is anywhere someone can point me in regards of either learning this system a bit better or even helpers with the calendar thing I would appreciate it.

spacebard
Jan 1, 2007

Football~

Vintersorg posted:

Im having trouble with a few things like the Calendar (https://www.drupal.org/project/calendar) and breadcrumbs. I have no idea where I can set these (ideally it would be whatever page im declaring the top menu). Diving into the PHP seems fruitless too.

If there is anywhere someone can point me in regards of either learning this system a bit better or even helpers with the calendar thing I would appreciate it.

I'm not sure what you mean by "set these" with regard to Calendar or breadcrumbs. That means a lot of things to me. A breadcrumb-hating theme developer may have removed the code that renders breadcrumbs entirely in the theme. Setting breadcrumbs might mean changing what breadcrumbs map to from their routes (menu router).

That all said if the route or path to the calendar falls under a hierarchy, then breadcrumbs should be automagically generated (path_breadcrumbs, breadcrumb_manager, and menu_breadcrumbs is one option for changing breadcrumb behavior). But who knows what's going on under the covers in the theme, in views, or in custom modules.

My long term advice is to figure out how the site was "built" to see what practices/methodologies the previous site builder used as Drupal is an open ended site building tool/framework/CMS.

v1nce
Sep 19, 2004

Plant your brassicas in may and cover them in mulch.

Vintersorg posted:

Im having trouble with a few things like the Calendar (https://www.drupal.org/project/calendar) and breadcrumbs. I have no idea where I can set these (ideally it would be whatever page im declaring the top menu). Diving into the PHP seems fruitless too.

spacebard's advice is pretty on point.. but if you do end up having to figure it out yourself I'd suggest using xdebug, and putting a breakpoint inside whatever function is supposed to render the breadcrumbs. You can then stack/class trace where they're supposed to come from, and hopefully that'll reveal an event/class/container which should contain them, and from there you can figure out how to push them into that container.

This is what I had to do about 2 years ago when debugging the arse out of the tangled spaghetti mess that is/was PrestaShop, and it's a great skill to have when you encounter code that looks like a black box.

toadoftoadhall
Feb 27, 2015
I have an interview for a 'part time PHP developer' position mid next week, though the job posting suggests they want somebody familiar with both front and backend. It's not required but it's been suggested that it would be good if I could show something that demonstrates some level of ability in the skills needed for the position. Currently there's nothing suitable in my repository; there are some C and Java projects that, if I can't produce anything else, might show a degree of programming proficiency, but I was hoping that somebody could suggest a project that a) isn't absolutely derisory and b) could be completed by somebody with little hard experience in web development if blitzed for ~5 days.

kedo
Nov 27, 2007

http://www.sansbullshitsans.com/

fuf
Sep 12, 2004

haha
If I'm providing hosting for someone and that includes email services is it expected that I help them configure their local email clients? This is consistently the hardest and most frustrating part of offering hosting for me. A lot of people don't even know which client they use, and I have no experience with any of them so I have to look stuff up and then pass it on and hope it's right. I am endlessly tempted to just send the mailbox details and say "it's not my job to explain how Outlook works" but that is kinda bullshit right?

Spatulater bro!
Aug 19, 2003

Punch! Punch! Punch!

fuf posted:

If I'm providing hosting for someone and that includes email services is it expected that I help them configure their local email clients? This is consistently the hardest and most frustrating part of offering hosting for me. A lot of people don't even know which client they use, and I have no experience with any of them so I have to look stuff up and then pass it on and hope it's right. I am endlessly tempted to just send the mailbox details and say "it's not my job to explain how Outlook works" but that is kinda bullshit right?

I'm in a similar position. I've just begun freelancing and haven't gotten a client yet, but I'll be offering hosting (which means email too). One part of me says to just suck it up and help in whatever way I can. The more practical part of me knows what a potential clusterfuck email client configuration will likely be. It's tempting to just copy and paste some instructions and take the "not my problem" attitude, but it's bad customer service.

One option I have in back of my mind, if things get too hairy, is to set up a Google Apps account for my clients (on their dime), pointing the MX records to Google, and letting Google handle everything.

Chris!
Dec 2, 2004

E
I'm freelance, and I usually set everything up for my clients as part of the cost. It can be a pain, but I get most referrals from clients who're happy I've gone the extra mile, so I see it as a net win, even if it slightly cuts down the profit margin of a given job.

kedo
Nov 27, 2007

caiman posted:

One option I have in back of my mind, if things get too hairy, is to set up a Google Apps account for my clients (on their dime), pointing the MX records to Google, and letting Google handle everything.

I started doing this awhile back and would never manage mail for a client any other way. There's way too much secret voodoo involved with mail servers and at the end of the day I'm not someone's IT department.

fuf
Sep 12, 2004

haha
Isn't google apps like $9 per month per mailbox though? That's a lot for each client email address (at my current level). I use zoho which is $2.50 per mailbox then I charge the client like $5.

Spatulater bro!
Aug 19, 2003

Punch! Punch! Punch!

So let's say you do your email hosting through Google Apps or Zoho. Do your clients understand that even though you're hosting their site, that they need to contact Google/Zoho for email tech support? Are clients typically cool with this?

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

caiman posted:

So let's say you do your email hosting through Google Apps or Zoho. Do your clients understand that even though you're hosting their site, that they need to contact Google/Zoho for email tech support? Are clients typically cool with this?

"I will host your site. I don't do email hosting. I recommend Google Apps, here's a link to their getting started guide."

That's what I do.

Adbot
ADBOT LOVES YOU

Spatulater bro!
Aug 19, 2003

Punch! Punch! Punch!

Lumpy posted:

"I will host your site. I don't do email hosting. I recommend Google Apps, here's a link to their getting started guide."

That's what I do.

Ah, so you place the entire process in their hands, including account setup and everything. That's pretty cool, I might do this.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply