Commit Graph

5274 Commits

Author SHA1 Message Date
Brian Simpson
eb0cdbf25c Make messages from user as subreddit more visually distinct.
Previously they looked like a regular message sent from the current
user. Now they indicate they are sent via a subreddit.
2014-12-30 19:18:33 -05:00
Brian Simpson
d2fa4b5364 Message.add_props: detangle logic. 2014-12-30 19:18:33 -05:00
Brian Simpson
7f84f427fc Message.add_props: Use mods_by_srid to find user moderated subreddits. 2014-12-30 19:18:33 -05:00
Brian Simpson
74815d273d Message.add_props: Run set_unread in batch. 2014-12-30 19:18:33 -05:00
Brian Simpson
eef29e4e09 Message.add_props: Batch lookups of override to and author. 2014-12-30 19:18:33 -05:00
Brian Simpson
d30f121f92 Message.add_props: Clean up batch lookups. 2014-12-30 19:18:32 -05:00
Brian Simpson
f55a8dcce5 Message.add_props: Don't use c.user.
Use `user` which is passed into the function.
2014-12-30 19:18:32 -05:00
Brian Simpson
701a292f7c Message: stop setting message_style attribute. 2014-12-30 19:18:32 -05:00
Brian Simpson
188bb28008 Message.add_props: Clean up variables. 2014-12-30 19:18:32 -05:00
Neil Williams
c01ac9eb9c Revert "Ratelimits: add strict enforcement mode."
This reverts commit 6b73de5dd5758d7a6df07ad85668af21afb510f8.
2014-12-30 15:43:03 -08:00
xiongchiamiov
1fb11a187c Profile page: enable comment editing
Giving users the ability to edit their own comments from their user page is
something that RES adds, but we didn't because the data wasn't available or
something.  Someone [brought it up again][0] recently, and it turns out it
*just works* now if we enable it.  And I don't see a good reason to prevent
users from doing it.

[0]: https://www.reddit.com/r/AutoModerator/comments/2olykv/automoderators_flair_and_karma_have_been_wiped/cmoiz4j?context=1
2014-12-29 14:19:03 -08:00
Ricky Ramirez
14a554d10b TransitionalCache: Correct return value for set ops. 2014-12-26 12:21:36 -08:00
Jordan Milne
29777e10f4 Switch to rel="noreferrer" instead of window.open() where possible
I've made a huge mistake
2014-12-22 17:45:49 -04:00
Brian Simpson
15c0a6344f Share: remove recent emails saving. 2014-12-19 21:41:55 -05:00
Brian Simpson
9f3456c485 ShareEmail: Don't link to comments page when promo comments disabled. 2014-12-19 21:41:55 -05:00
Brian Simpson
b6701c1d70 POST_share: explicitly restrict to Links. 2014-12-19 21:41:51 -05:00
Neil Williams
323b4da127 TransitionalCache: return properly from set_fn.
This is causing e.g. `incr`s that check the return value to fail as the
return value is always `None`.
2014-12-22 13:24:46 -08:00
Ricky Ramirez
6e6266563d cache: Add caches property to TransitionalCache.
This attribute is introspected by some hooks.
2014-12-22 13:24:04 -08:00
Ricky Ramirez
7c60b8b910 cache: Add a stats setter for TransitionalCache. 2014-12-22 13:23:54 -08:00
Ricky Ramirez
d93cf13994 Disallow direct use of g.memcache.
Caches should always go through the appropriate cache chain. Making the direct
CMemcache object a local var should prevent abuse in the future.
2014-12-22 13:23:31 -08:00
xiongchiamiov
3f6759d3af Compact: fix register page styling
The styling for the compact register page got messed up with our changes to the
login/register flow.  Eventually perhaps we'll restyle them, but for now leave
them be.

This is building on f752c15, which did the same for login.

[Reported by][0] /u/shamelessguy.

[0]: http://redd.it/2pwite
2014-12-22 11:31:14 -08:00
Jordan Milne
ba6cf12871 Fix ctrl-clicking to open a new tab in Firefox 2014-12-19 17:00:54 -04:00
Jordan Milne
1e660d07f7 Try to deal with non-W3C compliant popup blockers 2014-12-19 17:00:42 -04:00
Jordan Milne
95a2d12aab Work around IE Mobile's window.open nastiness 2014-12-19 17:00:32 -04:00
Matt Lee
6eec6f6681 markdown: Fix broken padding and margins.
Switching to unitless variables for all font-size, line-height, padding and margin
styles requires assigning those variables a unit when using (e.g. @var * 1px).  I
failed to do this in a couple spots, causing the selftext box to lose its padding and
look totally weird.

Also raises the left padding on lists.  Numbers on ordered lists were falling outside
of the comment's container, and getting clipped off.  This also looked totally weird.
2014-12-19 11:10:19 -08:00
Matt Lee
800d755633 Use react.js version with bundled addons.
This does _not_ bump the version number of react, it just uses the version
with addons bundled in.  These are mostly utility features, but the main
reason is for the animations addon.  Trying to add CSS transitions to elements
entering or exiting the DOM _without_ this addon would be a major pain.
2014-12-19 11:10:00 -08:00
Matt Lee
2b0add9a5f markdown: Fix font scaling for sidebar.
Commit 8f1ab15 addressed an issue we were seeing where some subreddit had
huge font sizes with the new markdown styles applied.  The solution was to
structure the styles such that <p> elements had a default font-size of 1em,
which worked well.  Unfortunately, because of the way that the sidebar styles
are structured (and because I kind of forgot about them in that solution),
this caused the opposite problem for some subreddits' sidebars: tiny text.
This applies the same solution to the sidebar text, and does a little bit
of refactoring along the way.

This replaces most references to absolute numbers with variable references.
A scale of font sizes, line heights, and margins used are defined at the top
of the file, and pretty much everything references those (except for small
stuff like borders.). I thought this was slightly easier to reason about than
doing `font-size: @base + 2;` kind of stuff, but it might be a little
overboard.
2014-12-19 11:09:59 -08:00
Matt Lee
0c43190abb markdown: Remove default background color for tables.
Some subreddits use tables for special layout purposes, and the new default
background colors for rows often needs to be overridden.  Since the effect is
pretty subtle anyways, its probably better to just remove it altogether.
2014-12-19 11:09:59 -08:00
Matt Lee
0199b7e77e markdown: Make headers inherit color.
If a subreddit wants to change the default text color (e.g. for a dark theme)
they'd need to override the color for the .md element and each header tag
(h1-h6) individually.  This makes it so the header tags inherit from the .md
element to make this less painful.
2014-12-19 11:09:59 -08:00
Robert Ditthardt
5fc5823230 Relation: Stop dual writing keys. 2014-12-18 17:40:39 -08:00
Robert Ditthardt
17ffe58de6 thing.py: Sanitize fast cache key for Relations.
This makes the fast cache key safe for the memcache ASCII protocol.

NOTE: This will need to be rolled out in a safe manner (usually a downtime) in order to avoid any data integrity issues.
2014-12-18 17:40:23 -08:00
Ricky Ramirez
244ac3bd55 Relation: Cut reads over to the new key name. 2014-12-18 17:40:14 -08:00
Robert Ditthardt
a3c3b45836 Relation: Start dual-writing new key names.
This is the first part of cleansing rel key names of spaces.
2014-12-18 17:38:43 -08:00
Robert Ditthardt
f4b60b59f5 thing.py: Fix name input to be ascii string
_query returns an ascii string for name no matter what. This was causing
an inconsistency in the cache key. u'subscriber' vs 'subscriber'.
2014-12-18 17:38:07 -08:00
Ricky Ramirez
c29c2d6c8d cache.py: Let TransitionalCache modify keys. 2014-12-18 17:37:56 -08:00
Robert Ditthardt
720048c989 thing.py: Create shared _fast_cache_key function
This function is meant to allow all of our Relation code to use the same
key, making it easier to change. It also required a refactor of the
_fast_cache code a bit to operate on cache keys instead of tuples.
2014-12-18 17:37:46 -08:00
Chad Birch
f4dcab845f Thing._byID: raise a useful error for non-int ID
Previously, passing a non-integer ID (usually happens with a string)
to _byID would give the "huge thing_id" error, which was confusing.
2014-12-18 18:10:44 -07:00
Chad Birch
d859ff427e DomainSR: force domain to lowercase
Even though the site generally normalizes domains to lowercase in most
other places, visiting /domain/EXAMPLE.COM (or any other capitalization)
would not show any results, the only working address would be
/domain/example.com. This forces to lowercase, regardless of how the
domain was capitalized in the url visited.
2014-12-18 18:10:39 -07:00
Brian Simpson
7d870e02e8 Allow language subreddits in multireddits. 2014-12-18 13:52:05 -05:00
Jordan Milne
a79d6c2ddd Only use window.open on http links 2014-12-18 02:08:16 -04:00
Matt Lee
826c445eec Fix collapsing in modmail.
Fixes a bug introduced in dd9e045 that prevents messages from collapsing
in modmail.  This was due to the markup change, combined with some overly
specific CSS.
2014-12-17 15:58:07 -08:00
Matt Lee
12d0d90670 markdown: Fix display of inbox messages.
Inbox messages display with a tiny font size when viewing with the new markdown
styles.  This is due to a change introduced in e8d0ce7.

<longwindedexplaination>
    The idea behind that change was to make the default font-size for `.md`
    elements `14px` while still using relative font sizes (using `ems` and
    keywords).  This lets us continue to respect browser preferences _and_
    makes the styles a _little_ harder to break via custom css (before this,
    increasing the font size of `.md` could drastically increase a subreddit's
    font size).

    In order to do this, you actually have to use two elements, because
    browsers only provide a limited set of absolute font sizes that respect
    user preferences (via keywords). The outer element uses a keyword font size
    to reset the base font size to the nearest keyword value `small (13px)`,
    and the inner `.md` element scales that up to the desired default font size
    using `ems`.  I thought that using `.wiki-page-content` for wiki pages and
    `usertext-body` for everything else covered it, but it turns out that
    message pages don't wrap message with `UserText`, so the `.md` text there
    is getting scaled up from the site default size of `x-small (10px)`.

    The end result is that we can use `p { font-size: 1em; }`, so if some
    stylesheet author decides they want to set
    `.md { font-size: <whatever>px }`, that's what they'll get.
</longwindedexplaination>

Rather than adding _another_ css rule trying to target the messages page (which
I don't think is possible without side effects anyway), I did two things:
first, I added an extra css class _specifically_ for this purpose
(`.md-container`) and applied to both the `wiki-page-content` and
`usertext-body` elements; and second, wrapped the offending markdown on the
inbox page with an element of that class.
2014-12-17 15:57:55 -08:00
Matt Lee
bbd76bd72f markdown: Update color palette. 2014-12-17 15:57:42 -08:00
Matt Lee
8f1ab1517b markdown: Change base font-size from 10px to 14px. 2014-12-17 15:57:32 -08:00
Matt Lee
9c101e03d7 selfserve: Fix rounding error on frontend.
make calc_impressions in sponsored.js behave the same as calc_impressions on the
backend, i.e. round down.
2014-12-17 15:57:21 -08:00
Jordan Milne
75f2413577 Make sure window.opener is null when opening tabs for users' links
Thanks to Hamid Ashraf (/u/hamihax) for the report! A lot of
user-agents allow windows and tabs to navigate their openers through
`window.opener.location`.

This creates a potential phishing risk where a victim with the
"open links in a new window" pref clicks a link submitted by an
attacker. The attacker's page may then navigate the reddit page that
opened it. When the user closes the tab with the attacker's submitted
content, they'll be greeted with an attacker controlled page, and
they would be less likely to notice since the tab previously contained
a page served by reddit.

IMO this is really a flaw in same-origin policy, but the behaviour is
present in a number of browsers.
2014-12-17 19:48:49 -04:00
Neil Williams
ee2ae1ed3a zookeeper: Gracefully close connection when app is shutting down.
This should help reduce logspam on the zookeeper ensemble.

The `on_app_shutdown` function is intended for use in gunicorn's
`worker_exit` hook.
2014-12-17 13:50:49 -08:00
Chad Birch
224cce72c7 Welcome message: handle default_sr not existing 2014-12-17 14:40:14 -07:00
xiongchiamiov
a275597fac Reports: fix in modmail
When a user reports a message, we've been checking to make sure it's actually
sent to them.  However, when a message is sent to a subreddit's moderation
team, any member of the mod team should be able to report the message, despite
it not being sent to *them*, directly.

We now extend the check to also check for moderator status if necessary.

[Reported][0] by /u/psdtwk.

[0]: https://www.reddit.com/r/bugs/comments/2p6m56/i/cmuw61w
2014-12-17 11:56:04 -08:00
xiongchiamiov
3a1d0ddfe4 Consistencize account text, part 2
While looking at reddit/reddit#1043, I was reminded that the work in
reddit/reddit@d2e2cef was incomplete, so I did a bit of `ack`ing and came up
with this set of changes.  This should be a pretty good set of changing login,
logged in, log out, logged out, etc. to the "sign out" equivalents, and
"register an account" and friends to "create an account".

There are a bunch of variable names and endpoints around that I didn't touch,
because that would break all sorts of things.  This *should* be only including
text directly shown to users (usually passed through `_()`) or indirectly shown
via the API docs.
2014-12-17 10:36:32 -08:00