|
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 |
# ? Apr 16, 2015 18:45 |
|
|
# ? May 11, 2024 23:11 |
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.
|
|
# ? Apr 16, 2015 19:17 |
|
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? 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. 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 |
# ? Apr 17, 2015 00:05 |
|
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:
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?
|
# ? Apr 17, 2015 01:42 |
|
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.
|
# ? Apr 17, 2015 03:44 |
|
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.
|
# ? Apr 17, 2015 16:59 |
|
CSS only unfortunately doesn't have the best support but here it is. https://developer.mozilla.org/en-US/docs/Web/CSS/word-break
|
# ? Apr 17, 2015 19:36 |
|
Thanks. To make matters worse, it's for an email 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.
|
# ? Apr 17, 2015 19:39 |
|
me your dad posted:Thanks. To make matters worse, it's for an email 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.
|
# ? Apr 17, 2015 20:02 |
|
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.
|
# ? Apr 18, 2015 07:51 |
|
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/
|
# ? Apr 18, 2015 16:38 |
|
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 |
# ? Apr 18, 2015 17:00 |
|
haha so that's what flexbox means. That's awesome, thanks.
|
# ? Apr 18, 2015 17:02 |
|
fuf posted:haha so that's what flexbox means. That's awesome, thanks. Universal support for flexbox can't come soon enough.
|
# ? Apr 18, 2015 17:55 |
|
chami posted:Universal support for flexbox can't come soon enough. When does IE10 end of life?
|
# ? Apr 18, 2015 20:13 |
|
Lumpy posted:When does IE10 end of life? January 12th 2016
|
# ? Apr 18, 2015 22:32 |
|
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? While we're waiting for solid Flexbox support, try this - scroll down to where it says "UPDATE: Using inline-block and justified text"
|
# ? Apr 20, 2015 12:46 |
|
IE10 supports flexbox. It just uses the inbetween syntax. Unless you need to support IE9, you can use flexbox now
|
# ? Apr 20, 2015 17:17 |
|
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.
|
# ? Apr 20, 2015 17:35 |
|
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. 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.
|
# ? Apr 21, 2015 04:18 |
|
And luckily with conditional comments, you can force in some pretty reasonable fallbacks if you can't do it with a single stylesheet.
|
# ? Apr 21, 2015 04:52 |
|
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?
|
# ? Apr 21, 2015 15:36 |
|
caiman posted:Deployment woes. I'm currently using grunt-ftp-deploy, but there are two things I'd like to be different: 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 |
# ? Apr 21, 2015 16:28 |
|
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?
|
# ? Apr 21, 2015 22:40 |
|
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?
|
# ? Apr 22, 2015 14:06 |
|
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.
|
# ? Apr 22, 2015 14:09 |
|
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.
|
# ? Apr 22, 2015 15:14 |
|
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.
|
# ? Apr 22, 2015 20:26 |
|
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. 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.
|
# ? Apr 22, 2015 23:53 |
|
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.
|
# ? Apr 23, 2015 00:56 |
|
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.
|
# ? Apr 23, 2015 10:56 |
|
http://www.sansbullshitsans.com/
|
# ? Apr 23, 2015 15:07 |
|
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?
|
# ? Apr 23, 2015 15:52 |
|
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.
|
# ? Apr 23, 2015 16:34 |
|
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.
|
# ? Apr 23, 2015 16:42 |
|
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.
|
# ? Apr 23, 2015 17:31 |
|
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.
|
# ? Apr 23, 2015 19:08 |
|
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?
|
# ? Apr 23, 2015 20:11 |
|
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.
|
# ? Apr 23, 2015 20:35 |
|
|
# ? May 11, 2024 23:11 |
|
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." Ah, so you place the entire process in their hands, including account setup and everything. That's pretty cool, I might do this.
|
# ? Apr 23, 2015 20:45 |