def test_subexample_sub(self): assert endpoint_for('http://sub.example.com/sub') == ( 'subdomained', { 'subdomain': 'sub' }, )
def oembed(url): """ Endpoint to support oEmbed (see https://oembed.com/). Example request:: https://hasjob.co/api/1/oembed?url=https://hasjob.co/ Required for services like embed.ly, which need a registered oEmbed API handler. """ endpoint, view_args = endpoint_for(url) if endpoint not in embed_index_views: return jsonify({}) board = Board.get(view_args.get('subdomain', 'www')) iframeid = 'hasjob-iframe-' + str(uuid4()) parsed_url = urlsplit(url) embed_url = SplitResult( parsed_url.scheme, parsed_url.netloc, parsed_url.path, parsed_url.query + ('&' if parsed_url.query else '') + 'embed=1&iframeid=' + iframeid, parsed_url.fragment, ).geturl() return jsonify({ 'provider_url': url_for('index', subdomain=None, _external=True), 'provider_name': app.config['SITE_TITLE'], 'thumbnail_width': 200, 'thumbnail_height': 200, 'thumbnail_url': url_for('static', filename='img/hasjob-logo-200x200.png', _external=True), 'author_name': board.title if board else app.config['SITE_TITLE'], 'author_url': board.url_for(_external=True) if board else url_for('index', subdomain=None, _external=True), 'title': ' | '.join([board.title, board.caption]) if board else app.config['SITE_TITLE'], 'html': ('<iframe id="{iframeid}" src="{url}" ' 'width="100%" height="724" frameborder="0" scrolling="no">'.format( url=embed_url, iframeid=iframeid)), 'version': '1.0', 'type': 'rich', }) return jsonify({})
def oembed(url): """ Endpoint to support oEmbed (see https://oembed.com/). Example request:: https://hasjob.co/api/1/oembed?url=https://hasjob.co/ Required for services like embed.ly, which need a registered oEmbed API handler. """ endpoint, view_args = endpoint_for(url) if endpoint not in embed_index_views: return jsonify({}) board = Board.get(view_args.get('subdomain', u'www')) iframeid = 'hasjob-iframe-' + unicode(uuid4()) parsed_url = urlsplit(url) embed_url = SplitResult( parsed_url.scheme, parsed_url.netloc, parsed_url.path, parsed_url.query + ('&' if parsed_url.query else '') + 'embed=1&iframeid=' + iframeid, parsed_url.fragment ).geturl() return jsonify({ 'provider_url': url_for('index', subdomain=None, _external=True), 'provider_name': app.config['SITE_TITLE'], 'thumbnail_width': 200, 'thumbnail_height': 200, 'thumbnail_url': url_for('static', filename='img/hasjob-logo-200x200.png', _external=True), 'author_name': board.title if board else app.config['SITE_TITLE'], 'author_url': board.url_for(_external=True) if board else url_for('index', subdomain=None, _external=True), 'title': ' | '.join([board.title, board.caption]) if board else app.config['SITE_TITLE'], 'html': ('<iframe id="{iframeid}" src="{url}" ' 'width="100%" height="724" frameborder="0" scrolling="no">'.format( url=embed_url, iframeid=iframeid)), 'version': '1.0', 'type': 'rich' }) return jsonify({})
def test_localhost_sub(self): assert endpoint_for('http://localhost/sub') == (None, {})
def test_subexample_slashed(self): assert endpoint_for('http://sub.example.com/slashed/') == (None, {})
def test_subexample_unslashed_noredirect(self): assert endpoint_for('http://sub.example.com/slashed', follow_redirects=False) == (None, {})
def test_localhost_sub(self): assert endpoint_for('http://localhost/sub') == ('un_subdomained', {})
def test_example_slashed(self): assert endpoint_for('http://example.com/slashed/') == ('slashed', {})
def test_subexample_index(self): assert endpoint_for('http://sub.example.com/') == ('index', {})
def test_localhost_unslashed_noredirect(self): assert endpoint_for('http://localhost/slashed', follow_redirects=False) == (None, {})
def test_localhost_unslashed_noredirect(self): assert endpoint_for('http://localhost/slashed', follow_redirects=False) == ( None, {}, )
def test_localhost_index(self): assert endpoint_for('http://localhost/') == (None, {})
def test_localhost_unslashed(self): assert endpoint_for('http://localhost/slashed') == (None, {})
def test_subexample_sub(self): assert endpoint_for('http://sub.example.com/sub') == ('un_subdomained', {})
def test_subexample_unslashed_noredirect(self): assert endpoint_for('http://sub.example.com/slashed', follow_redirects=False) == (None, {})
def test_subexample_unslashed(self): assert endpoint_for('http://sub.example.com/slashed') == ('slashed', {})
def test_subexample_slashed(self): assert endpoint_for('http://sub.example.com/slashed/') == (None, {})
def test_localhost_sub(self): assert endpoint_for('http://localhost/sub') == (None, {})
def test_localhost_unslashed(self): assert endpoint_for('http://localhost/slashed') == ('slashed', {})
def test_example_index(self): assert endpoint_for('http://example.com/') == ('index', {})
def test_localhost_sub(self): assert endpoint_for('http://localhost/sub') == ('un_subdomained', {})
def test_example_slashed(self): assert endpoint_for('http://example.com/slashed/') == ('slashed', {})
def test_example_sub(self): assert endpoint_for('http://example.com/sub') == ('un_subdomained', {})
def test_subexample_index(self): assert endpoint_for('http://sub.example.com/') == (None, {})
def test_subexample_unslashed(self): assert endpoint_for('http://sub.example.com/slashed') == ('slashed', {})
def test_localhost_slashed(self): assert endpoint_for('http://localhost/slashed/') == (None, {})
def test_localhost_index(self): assert endpoint_for('http://localhost/') == (None, {})
def test_localhost_slashed(self): assert endpoint_for('http://localhost/slashed/') == ('slashed', {})