| from . import db | from . import db | ||||
| import os | import os | ||||
| from sqlalchemy.sql import func | from sqlalchemy.sql import func | ||||
| import markdown | |||||
| book = Blueprint('book', __name__) | book = Blueprint('book', __name__) | ||||
| # route for displaying all books in database | # route for displaying all books in database | ||||
| @book.route('/books') | @book.route('/books') | ||||
| def get_books(): | def get_books(): | ||||
| # get introductory paragraph Markdown | |||||
| with open('content/books.md', 'r') as f: | |||||
| intro_text = f.read() | |||||
| intro_text = markdown.markdown(intro_text) | |||||
| view = request.args.get('view') | view = request.args.get('view') | ||||
| resource_type = 'book' | resource_type = 'book' | ||||
| books_query = Resource.query.filter_by(type=resource_type).order_by(func.random()) | books_query = Resource.query.filter_by(type=resource_type).order_by(func.random()) | ||||
| count = len(books) | count = len(books) | ||||
| # reorder books by book name | # reorder books by book name | ||||
| books = sorted(books, key=lambda d: d.__dict__['name'].lower()) | books = sorted(books, key=lambda d: d.__dict__['name'].lower()) | ||||
| # render Markdown as HTML | |||||
| for book in books: | |||||
| book.description = markdown.markdown(book.description) | |||||
| if view != 'list': | if view != 'list': | ||||
| # append relationships to each book | # append relationships to each book | ||||
| append_relationships_multiple(books) | append_relationships_multiple(books) | ||||
| year_filter = get_filter_values('year', resource_type) | year_filter = get_filter_values('year', resource_type) | ||||
| # typology | # typology | ||||
| typology_filter = get_filter_values('typology', resource_type) | typology_filter = get_filter_values('typology', resource_type) | ||||
| return render_template('resources.html', resources=books, type=resource_type, practices_filter=practices_filter, year_filter=year_filter, typology_filter=typology_filter, count=count, view=view) | |||||
| return render_template('resources.html', resources=books, type=resource_type, practices_filter=practices_filter, year_filter=year_filter, typology_filter=typology_filter, count=count, view=view, intro_text=intro_text) | |||||
| # route for displaying a single book based on the ID in the database | # route for displaying a single book based on the ID in the database | ||||
| @book.route('/books/<int:book_id>') | @book.route('/books/<int:book_id>') | ||||
| def show_book(book_id): | def show_book(book_id): | ||||
| book = get_full_resource(book_id) | book = get_full_resource(book_id) | ||||
| # render Markdown as HTML | |||||
| book.description = markdown.markdown(book.description) | |||||
| return render_template('book.html', resource=book) | return render_template('book.html', resource=book) | ||||
| # route for editing a single book based on the ID in the database | # route for editing a single book based on the ID in the database |
| resource_ids = tool_ids + practice_ids + book_ids | resource_ids = tool_ids + practice_ids + book_ids | ||||
| # get data for curated resources | # get data for curated resources | ||||
| curated = get_curated_resources(resource_ids) | curated = get_curated_resources(resource_ids) | ||||
| # render Markdown as HTML | |||||
| for resource in curated: | |||||
| resource.description = markdown.markdown(resource.description) | |||||
| with open('content/home.md', 'r') as f: | with open('content/home.md', 'r') as f: | ||||
| text = f.read() | text = f.read() | ||||
| text = markdown.markdown(text) | text = markdown.markdown(text) |
| # route for displaying all practices in database | # route for displaying all practices in database | ||||
| @practice.route('/practices') | @practice.route('/practices') | ||||
| def get_practices(): | def get_practices(): | ||||
| # get introductory paragraph Markdown | |||||
| with open('content/practices.md', 'r') as f: | |||||
| intro_text = f.read() | |||||
| intro_text = markdown.markdown(intro_text) | |||||
| view = request.args.get('view') | view = request.args.get('view') | ||||
| practices = Resource.query.filter_by(type='practice').order_by(func.random()).all() | practices = Resource.query.filter_by(type='practice').order_by(func.random()).all() | ||||
| # get number of practices | # get number of practices | ||||
| if view != 'list': | if view != 'list': | ||||
| # append relationships to each practice | # append relationships to each practice | ||||
| append_relationships_multiple(practices) | append_relationships_multiple(practices) | ||||
| return render_template('resources.html', resources=practices, type='practice', count=count, view=view) | |||||
| return render_template('resources.html', resources=practices, type='practice', count=count, view=view, intro_text=intro_text) | |||||
| # route for displaying a single practice based on the ID in the database | # route for displaying a single practice based on the ID in the database | ||||
| @practice.route('/practices/<int:practice_id>') | @practice.route('/practices/<int:practice_id>') |
| {% endif %} | {% endif %} | ||||
| <div class="{% if size==1 %} big-text {% else %} small-text {% endif %} mb-[1em]"> | <div class="{% if size==1 %} big-text {% else %} small-text {% endif %} mb-[1em]"> | ||||
| {{ resource['description'] | truncate(150) }} | |||||
| {{ resource['description'] | truncate(150) | safe }} | |||||
| </div> | </div> | ||||
| </a> | </a> |
| Experimental aspects: | Experimental aspects: | ||||
| </h3> | </h3> | ||||
| <div> | <div> | ||||
| {{ resource['description'] }} | |||||
| {{ resource['description']|safe }} | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| {% endif %} | {% endif %} |
| <div class="border-b-2 border-black grid lg:grid-cols-[52rem,30rem] content-start"> | <div class="border-b-2 border-black grid lg:grid-cols-[52rem,30rem] content-start"> | ||||
| <div class="mx-2 lg:ml-[13rem] text my-8 meta lg:max-w-[30rem]"> | <div class="mx-2 lg:ml-[13rem] text my-8 meta lg:max-w-[30rem]"> | ||||
| Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam ultricies egestas felis at dignissim. Morbi ut bibendum | |||||
| nisl. Integer ac sollicitudin risus. Vivamus et est est. Ut vitae lacus nec justo tincidunt interdum. Fusce sapien odio, | |||||
| commodo nec est et, interdum varius risus. Curabitur vehicula consequat auctor. | |||||
| {{ intro_text|safe }} | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| from . import db | from . import db | ||||
| import os | import os | ||||
| from sqlalchemy.sql import func | from sqlalchemy.sql import func | ||||
| import markdown | |||||
| tool = Blueprint('tool', __name__) | tool = Blueprint('tool', __name__) | ||||
| # route for displaying all tools in database | # route for displaying all tools in database | ||||
| @tool.route('/tools') | @tool.route('/tools') | ||||
| def get_tools(): | def get_tools(): | ||||
| # get introductory paragraph Markdown | |||||
| with open('content/tools.md', 'r') as f: | |||||
| intro_text = f.read() | |||||
| intro_text = markdown.markdown(intro_text) | |||||
| view = request.args.get('view') | view = request.args.get('view') | ||||
| resource_type = 'tool' | resource_type = 'tool' | ||||
| tools_query = Resource.query.filter_by(type=resource_type).order_by(func.random()) | tools_query = Resource.query.filter_by(type=resource_type).order_by(func.random()) | ||||
| languages_filter = get_filter_values('scriptingLanguage', resource_type) | languages_filter = get_filter_values('scriptingLanguage', resource_type) | ||||
| # status | # status | ||||
| status_filter = get_filter_values('status', resource_type) | status_filter = get_filter_values('status', resource_type) | ||||
| return render_template('resources.html', resources=tools, type=resource_type, practices_filter=practices_filter, licenses_filter=licenses_filter, languages_filter=languages_filter, status_filter=status_filter, count=count, view=view) | |||||
| return render_template('resources.html', resources=tools, type=resource_type, practices_filter=practices_filter, licenses_filter=licenses_filter, languages_filter=languages_filter, status_filter=status_filter, count=count, view=view, intro_text=intro_text) | |||||
| # route for displaying a single tool based on the ID in the database | # route for displaying a single tool based on the ID in the database | ||||
| @tool.route('/tools/<int:tool_id>') | @tool.route('/tools/<int:tool_id>') |
| Experimental books undo, critique, reinvent, and expand the processes and norms of scholarly publishing. |
| Sorting the compendium by practice (annotating, collaborative writing, forking, remixing, reviewing, translating, versioning) provides inspiration on how-to make experimental books. |
| Open source software tools and platforms enable experimentation with scholarly books: changing how people, collate, write, assemble, review, publish, share, reuse, and read long-form texts. |