Esempio n. 1
0
def search_publisher( publ_id ):
    """Search for a publisher."""
    publ = Publisher.query.get( publ_id )
    if not publ:
        return jsonify( [] )
    results = [ get_publisher_vals( publ, True, True ) ]
    pubs = sorted( publ.publications, key=get_publication_sort_key, reverse=True )
    for pub in pubs:
        results.append( get_publication_vals( pub, True, True ) )
    return jsonify( results )
Esempio n. 2
0
def search_article( article_id ):
    """Search for an article."""
    article = Article.query.get( article_id )
    if not article:
        return jsonify( [] )
    vals = get_article_vals( article, True )
    _create_aslrb_links( vals )
    results = [ vals ]
    if article.parent_pub:
        results.append( get_publication_vals( article.parent_pub, True, True ) )
    if article.parent_publ:
        results.append( get_publisher_vals( article.parent_publ, True, True ) )
    return jsonify( results )
Esempio n. 3
0
def search_publishers():
    """Return all publishers."""
    publs = sorted(Publisher.query.all(), key=lambda p: p.publ_name.lower())
    results = [get_publisher_vals(p, True) for p in publs]
    return jsonify(results)
Esempio n. 4
0
from asl_articles.utils import AppConfigParser, decode_tags, to_bool, squash_spaces

_search_index_path = None
_search_aliases = {}
_search_weights = {}
_author_aliases = {}
_logger = logging.getLogger("search")

_SQLITE_FTS_SPECIAL_CHARS = "+-#':/.@$"

# NOTE: The column order defined here is important, since we have to access row results by column index.
_SEARCHABLE_COL_NAMES = [
    "name", "name2", "description", "authors", "scenarios", "tags"
]

_get_publisher_vals = lambda p: get_publisher_vals(p, True)
_get_publication_vals = lambda p: get_publication_vals(p, True, True)
_get_article_vals = lambda a: get_article_vals(a, True)

_PASSTHROUGH_REGEXES = set([
    re.compile(r"\bAND\b"),
    re.compile(r"\bOR\b"),
    re.compile(r"\bNOT\b"),
    re.compile(r"\((?![Rr]\))"),
])

# NOTE: The following are special search terms used by the test suite.
SEARCH_ALL = "<!all!>"
SEARCH_ALL_PUBLISHERS = "<!publishers!>"
SEARCH_ALL_PUBLICATIONS = "<!publications!>"
SEARCH_ALL_ARTICLES = "<!articles!>"