diff --git a/files/assets/css/main.css b/files/assets/css/main.css index f1b0ca277..cd1e5277f 100644 --- a/files/assets/css/main.css +++ b/files/assets/css/main.css @@ -3637,7 +3637,7 @@ small, .small { color: var(--muted); font-weight: 600; font-size: 12px; - z-index: 3; + z-index: 100; } .dropdown-actions .fa, .dropdown-actions .fas, .dropdown-actions .far { font-size: 12px; @@ -6239,4 +6239,15 @@ div.custom-control:last-of-type { div.custom-control:last-of-type { margin-bottom: 7px; } -} \ No newline at end of file +} + +.dropdown-menu button.searchparam { + color: var(--gray-100); + text-decoration: none; + text-transform: none; + background-color: transparent; + border: 2px solid gray; + border-radius: 3px; + padding: 6px; + width: 150px; +} diff --git a/files/assets/images/rDrama/sidebar/730.webp b/files/assets/images/rDrama/sidebar/730.webp new file mode 100644 index 000000000..04e799644 Binary files /dev/null and b/files/assets/images/rDrama/sidebar/730.webp differ diff --git a/files/assets/images/rDrama/sidebar/731.webp b/files/assets/images/rDrama/sidebar/731.webp new file mode 100644 index 000000000..3dd3f6f19 Binary files /dev/null and b/files/assets/images/rDrama/sidebar/731.webp differ diff --git a/files/assets/js/search.js b/files/assets/js/search.js new file mode 100644 index 000000000..2c3e73fa3 --- /dev/null +++ b/files/assets/js/search.js @@ -0,0 +1,8 @@ +function addParam(e) { + e = e || window.event; + let paramExample = e.target.innerText; + let param = paramExample.split(":")[0]; + let searchInput = document.querySelector("#large_searchbar input"); + searchInput.value = `${searchInput.value} ${param}:`; + searchInput.focus(); +} diff --git a/files/classes/user.py b/files/classes/user.py index ff7371c59..239ccbf14 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -626,9 +626,6 @@ class User(Base): if self.is_cakeday: return 'cakeday-1' - elif SITE_NAME == 'rDrama': # temporary branch for flowercrown event - flowercrowns = ['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15'] - return 'flowercrown-' + random.choice(flowercrowns) return '' @property diff --git a/files/routes/search.py b/files/routes/search.py index 80982b436..e3d32ae3c 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -17,6 +17,8 @@ valid_params = [ "post", "before", "after", + "title", + "exact", search_operator_hole, ] @@ -30,6 +32,7 @@ def searchparse(text): text = text.strip() if text: + criteria['full_text'] = text criteria['q'] = [] for m in search_token_regex.finditer(text): token = m[1] if m[1] else m[2] @@ -88,8 +91,19 @@ def searchposts(v): ) else: posts = posts.filter(Submission.author_id == author.id) - if 'q' in criteria: - words = [or_(Submission.title.ilike('%'+x+'%'), Submission.body.ilike('%'+x+'%')) \ + if 'exact' in criteria and 'full_text' in criteria: + regex_str = '[[:<:]]'+criteria['full_text']+'[[:>:]]' # https://docs.oracle.com/cd/E17952_01/mysql-5.5-en/regexp.html "word boundaries" + if 'title' in criteria: + words = [Submission.title.regexp_match(regex_str)] + else: + words = [or_(Submission.title.regexp_match(regex_str), Submission.body.regexp_match(regex_str))] + posts = posts.filter(*words) + elif 'q' in criteria: + if('title' in criteria): + words = [or_(Submission.title.ilike('%'+x+'%')) \ + for x in criteria['q']] + else: + words = [or_(Submission.title.ilike('%'+x+'%'), Submission.body.ilike('%'+x+'%')) \ for x in criteria['q']] posts = posts.filter(*words) @@ -196,8 +210,13 @@ def searchcomments(v): else: comments = comments.filter(Comment.author_id == author.id) - if 'q' in criteria: - words = [Comment.body.ilike('%'+x+'%') for x in criteria['q']] + if 'exact' in criteria and 'full_text' in criteria: + regex_str = '[[:<:]]'+criteria['full_text']+'[[:>:]]' # https://docs.oracle.com/cd/E17952_01/mysql-5.5-en/regexp.html "word boundaries" + words = [Comment.body.regexp_match(regex_str)] + comments = comments.filter(*words) + elif 'q' in criteria: + words = [or_(Comment.body.ilike('%'+x+'%')) \ + for x in criteria['q']] comments = comments.filter(*words) if 'over18' in criteria: comments = comments.filter(Comment.over_18 == True) diff --git a/files/templates/search.html b/files/templates/search.html index eec44780b..7a5252e46 100644 --- a/files/templates/search.html +++ b/files/templates/search.html @@ -7,7 +7,7 @@ {% endblock %} {% block PseudoSubmitForm %} -