-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bootstrap3 Based UI (Implement #103) #129
Conversation
This and the following commits should be PR ready, and should not break existing routes. This means refactored code that affect more than one route will be duplicated and renamed. We can easily cleanup extra code after implementing the entire refactor.
Abstract some code/templates from scriptPage. Emulated app.route('/').VERB(callback).VERB(callback) from ExpressJS 4
Broke userPage up into userProfilePage (description) and userScriptListPage. Broke userEditPage up into userEditProfilePage and userEditPreferencesPage (auth strategies). Todo: Go through other route controllers and rename user -> authedUser. Then change the header nav template.
This is so we can eventually allow mods to edit this page.
Styled like Discourse.
Broke commenting when I removed the form action. Style the reply snippet, and also pad the comment contents.
…es up to "passport-github" to run in development (you don't need all the other passport packages).
You can only lower your role. And by delete, do you mean the delete in the user panel? or the mod remove user (which prevents you from removing yourself soooo I guessing the admin one)?
I'll delete the delete button, and disable the admin user list route as it's redundant now (unless you want to batch delete) =.=' Not sure if you saw this @sizzlemctwizzle as you replied right after I edited it in.
|
While that's a cool fix, it's not backwards compatible. We could migrate the db, but I've avoided that for this PR. |
So you want to let people step down?
Sounds good.
Yeah that makes sense.
Won't be able to thin the herd as easily without my completely random mass user deletion sprees haha
Yeah do that. It's much too high right now and basically makes it useless, but at least we'll be ready for potential future abuse. |
Okay. I'm going to add this to #130 since fixing that issue already entails changes to the database. |
We can remove the parsing code later on, instead validating images when a script is uploaded.
Apparently model.flagging wasn't working for me, even with the lower threshold. Had to check
More like quickly test lower roles, but meh. PR is ready. |
Have been following and reading your progress silently from the beginning and it look GREAT! +1 on merging! Any other new changes can go into new issues/PR. |
Can they return to their original role without assistance? This seems like more of a dev thing.
Reviewing and testing it (locally in the production environment) one last time before I merge and deploy. |
One last question for this pr... |
Use singular, as the intent is to only make a single script. The batch options are on different routes anyways. |
Should probably also be consistent when talking about a specific item. Either
OR
I prefer singluar, but a fair number of sites use plural. GitHub users plural with a single item. Discourse uses singluar on a single item. |
I prefer the first way you mentioned but we'll figure this out with #135. |
…pages... useful for user-content arrows without having to build a user.js to do this for anyone. Mentioned in OpenUserJS#129 (comment)
…**last value** only This is from GM standards... GM always picks last value if there is a conflict... not the first. If we want a 45px size icon we're going to have to implement one and probably put in the prefix portion from CI. Refs: * OpenUserJS#129 (comment)
PR is ready.
I'm still writing it up and doing a few last commits. There's just a fuck ton to document and I'm a savvy Ctrl+S kinda guy.This is a Pull Request for Issue #103.
Demo
http://nameless-hollows-5487.herokuapp.com/
Screenshots
Imgur Album: https://imgur.com/a/HKqhs
In order to view the authenticated pages.
Changes
Probably should start with what I didn't change. I tried to stay keep routes the same. Though I made a helper function called
app_route
that emulatesapp.route('/').get(controller).post(controller)
from Express 4.x. I didn't touch the models at all. Graveyard, Flagged Users/Scripts and the AdminUserList page are still using the old UI.All CSS/JS libraries are linked from http://cdnjs.com. Javascript is in the footer. CSS is in the header.
Templating
View: https://github.com/Zren/OpenUserJS.org/blob/css/views/pages/_templatePage.html
Controller: https://github.com/Zren/OpenUserJS.org/blob/css/controllers/_template.js
Template Options (
options.*
)Eg:
options.authedUser
authedUser
The authed user.isMod
==authedUser.isMod
isAdmin
==authedUser.isAdmin
isYou
script.author == authedUser on scriptPageuserTools
,authorTools
,modTools
,adminTools
are{}
orundefined
depending on if the user can use those panels. Use the style overisYou
etc so we can have admin's have access to script editing tools in the future.pageMetaDescription
string for<meta name="description">
or null.pageMetaKeywords
Comma seperated list of keywords for<meta name="keywords">
or null.Models: Generated fields from Serialized Data
Use
libs/modelParser
likeauthedUser = modelParser,parseUser(authedUser)
to generate urls likeauthedUser.userPageUrl
. modelParser will strip all model functions like.save()
as it does aobj.toObject()
. I did this as I wasn't 100% sure if modifying fields not specified in the model's schema would get serialized. I also used toObject as the controllers before my edits were not sending the models into the template (like:options: {username: user.name}
), so I followed that pattern.Controllers
Use
libs/modelQuery
to build Model.find() queries. It has a bunch of function to apply on a query (eg:scriptListQuery = Script.find()
like:modelQuery.parseScriptSearchQuery(scriptListQuery, req.query.q)
modelQuery.parseModelListSort(scriptListQuery, req.query.orderBy, req.query.orderDir, defaultSortCallback)
There's also
modelQuery.applyScriptListQueryDefaults(scriptListQuery, options, req)
which deals with the parsing of default querystring parameters for you (q, orderBy, orderDir, p, limit
), and sets up an object for pagination (url?p=1
for page 1) inoptions.pagination
. To complete the pagination, you have to count the total number of items your query conditions match. When using theapply___ListQueryDefaults
functions, it's as easy as usingtasks.push(pagination.getCountTask(scriptListQuery));
. Lastly, you have to render the paginationTemplate withoptions.paginationRendered = pagination.renderDefault(req);
after the count task has completed (usually right before you dores.render
). All that was probably very confusing, so learn by example by reading theindex.home
,group.list
, or any of the other listPage controllers.All my query building function apply onto an existing query. Have the query get defined in the controller. This way you can do fine tuning on the query on top of using the default query building functions.
var github = require('../libs/githubClient');
will import a pre-setup github client which you can find the docs for here.Envionment Variables
Since I wanted to setup a demo to live test my changes, I needed to add make a few urls configurable. Namely:
AUTH_CALLBACK_BASE_URL
To allow users to login. Though we might want to fetch the hostname from the request? Using env variables was simpler at the time of writing.DEV_AWS_URL
defaulting tolocalhost:10001
. I port forwarded my FakeS3 server for my demo.Views
Root views that are
res.render
ed are put inviews/pages/
. Templates that are included in pages are put inviews/includes/
. Inline scripts that you reuse, but don't feel worthy of an extra request, are put inviews/includes/scripts/
.Paragraphs of text, while readable on the body bg color, are easier to read inside a panel (with a white bg). Headings are fine to be placed in the gutter. Here's the bootstrap html for a simple panel. You learn more bootstrap here: http://getbootstrap.com/components/#panels
FontAwesome
All icons are from http://fontawesome.io/icons/
Inspiration
All the Discussion/Forum pages are based off Discourse's UI.
Vocab
I preferred the verbose ___List rather than pluralization.