Ejemplo n.º 1
0
def display_story():
    """ displays current story template with inputs from user """

    # retreive current story title from session
    selected_story_title = session['selected_story_title']

    # find index of story matching current story title
    target_story_index = -1
    for story in story_options:
        if selected_story_title == story.get("title"):
            target_story_index = story_options.index(story)
            break

    # defines instance of story type
    story = Story(story_options[target_story_index]["words"],
                  story_options[target_story_index]["template"])

    # word template list of current story
    template_words = story_options[target_story_index]["words"]

    # dictionary comp - create the answers for our story
    answer = {word: request.args.get(word) for word in template_words}

    # create story string from story generate method
    story_string = story.generate(answer)

    # render template with our story display html
    return render_template(
        "displaystory.html", complete_story_string=story_string)
Ejemplo n.º 2
0
def story_page():
    """Page that displays completed Madlib Story!
    """
    story_dictionary = create_dictionary()

    answer1 = request.args["input-1"]
    answer2 = request.args["input-2"]
    answer3 = request.args["input-3"]
    answer4 = request.args["input-4"]
    answer5 = request.args["input-5"]
    theme = request.args["story-theme"]

    s_obj = {
        "1": answer1,
        "2": answer2,
        "3": answer3,
        "4": answer4,
        "5": answer5
    }

    story = Story(["1", "2", "3", "4", "5"], story_dictionary.get(theme))

    response = story.generate(s_obj)

    return render_template("story.html", madlib=response)
Ejemplo n.º 3
0
def create_story():
    place = request.args.get('place')
    noun = request.args.get('noun')
    verb = request.args.get('verb')
    adjective = request.args.get('adjective')
    plural_noun = request.args.get('plural_noun')

    if request.args.get("stories") == "story1":
        story = Story(["place", "noun", "verb", "adjective", "plural_noun"],
                      """Once upon a time in {place}, there lived a
        large {adjective} {noun}. It loved to {verb} {plural_noun}.""")

    elif request.args.get("stories") == "story2":
        story = Story(
            ["place", "noun", "verb", "adjective", "plural_noun"],
            """{place}, a {adjective} place to {verb}, full of {noun},
        and a ton of {plural_noun}.""")

    ans = {
        "place": place,
        "noun": noun,
        "verb": verb,
        "adjective": adjective,
        "plural_noun": plural_noun
    }

    result = story.generate(ans)

    return render_template('story.html', story=result)
Ejemplo n.º 4
0
def story_saving():
    Story.create(story_title=request.form["story_title"],
                 user_story=request.form["user_story"],
                 acceptance_criteria=request.form["acceptance_criteria"],
                 business_value=request.form["business_value"],
                 estimation=request.form["estimation"],
                 status=request.form["status"])
    return redirect(url_for("story_listing"))
Ejemplo n.º 5
0
Archivo: app.py Proyecto: demohack/yute
def offer_greeting():
    """Show story."""

    story = Story(story_prompts, story_text)

    ans = {
        "place": request.args["place"],
        "noun": request.args["noun"],
        "verb": request.args["verb"],
        "adjective": request.args["adjective"],
        "plural_noun": request.args["plural_noun"]
    }

    return render_template("story.html", text=story.generate(ans))
Ejemplo n.º 6
0
def story():
    try:
        args_form = {key: request.args[key] for key in request.args.keys()}

        story_text = "".join(stories[int(args_form['index'])])
        del args_form['index']

        story_obj = Story(args_form, story_text)
        story = story_obj.generate(args_form)

        return render_template("story.html", nav_bar=nav_bar, story=story)
    except:
        return render_template("story.html",
                               nav_bar=nav_bar,
                               story="There is no a story here")
Ejemplo n.º 7
0
def final_story():
    """Show final madlib"""
    global s
    global story
    ans = request.form.to_dict()  # grab input from form
    words = list()  # create list to store values from form
    text = ""  # Move words global variable "story" into a string
    for word in story:
        text += word + " "
    for key, val in ans.items(
    ):  # get the keys to generate story with descriptors
        words.append(key)
    final = Story(words, text)  # add story info
    fs = final.generate(ans)  # generate story with user input
    return render_template("final_story.html",
                           final_story=fs,
                           original_story=s)
Ejemplo n.º 8
0
def load_data():
    tales = []
    with open("stories_db.json") as json_file:
        data = json.load(json_file)

    for key in data.keys():
        tales.append(Story(key, data[key]["prompts"], data[key]["template"]))

    return tales
Ejemplo n.º 9
0
def story_editing(story_id):
    story = Story.get(Story.id == story_id)
    story.story_title = request.form["story_title"]
    story.user_story = request.form["user_story"]
    story.acceptance_criteria = request.form["acceptance_criteria"]
    story.business_value = request.form["business_value"]
    story.estimation = request.form["estimation"]
    story.status = request.form["status"]
    story.save()
    return redirect(url_for("story_listing"))
Ejemplo n.º 10
0
Archivo: app.py Proyecto: gmzi/notes
def story_page():
    """shows story"""
    place = request.args['place']
    noun = request.args['noun']
    verb = request.args['verb']
    adjective = request.args['adjective']
    plural_noun = request.args['plural_noun']

    new_story = Story(["place", "noun", "verb", "adjective", "plural_noun"],
                      """Once upon a time in a long-ago {place}, there lived a
       large {adjective} {noun}. It loved to {verb} {plural_noun}.""")
    answers = {
        'place': place,
        'noun': noun,
        'verb': verb,
        'adjective': adjective,
        'plural_noun': plural_noun
    }

    text = new_story.generate(answers)
    return render_template('story.html', text=text)
Ejemplo n.º 11
0
def create_template():
    """ Creates a new story template and adds to dictionary of stories """

    story_name = request.form["story_name"]
    word1 = request.form["word_type_1"]
    word2 = request.form["word_type_2"]
    text1 = request.form["text_1"]
    text2 = request.form["text_2"]

    prompts = [word1, word2]
    template = text1 + " {" + word1 + '} ' + text2 + " {" + word2 + "} "

    stories[f"{story_name}"] = Story(prompts, template)
    return redirect("/")
Ejemplo n.º 12
0
def story_del(story_id):
    story_to_be_deleted = Story.get(Story.id == story_id)
    story_to_be_deleted.delete_instance()
    return redirect(url_for("story_listing"))
Ejemplo n.º 13
0
def madlib(Id):
    """Generates madlib from preset story and user input"""
    ans = request.form.to_dict()
    madlib = Story(words, stories[int(Id) - 1])
    return render_template("madlib.html", madlib=madlib.generate(ans))
Ejemplo n.º 14
0
from flask import Flask, request, render_template
from flask_debugtoolbar import DebugToolbarExtension
from stories import Story

app = Flask(__name__)
app.config['SECRET_KEY'] = "string"
debug = DebugToolbarExtension(app)

story = Story(["place", "noun", "verb", "adjective", "plural_noun"],
    "Once upon a time in a long-ago {place}, there lived a large {adjective} {noun}. It loved to {verb} {plural_noun}.","story1")

#Uncomment to unlock the story selection option
story2 = Story(["adjective","noun","verb_past_tense","adverb","adjective2",
"noun2","noun3","adjective3","verb2","adverb2"],
"""Today I went to the zoo. I saw a(n) {adjective}
{noun} jumping up and down in its tree. He {verb_past_tense} {adverb}
through the large tunnel that led to its {adjective2} {noun2}. 
I got some peanuts and passed them through the cage to a gigantic gray {noun3}
towering above my head. Feeding that animal made me hungry. 
I went to get a {adjective3} scoop of ice cream. It filled my stomach. 
Afterwards I had to {verb2} {adverb2} to catch our bus.""", "story2")

stories = [story,story2]
@app.route("/")
def homepage():
    
    return render_template("base.html",stories=stories)

@app.route("/inputs")
def storyPrompts():
    story_choice = request.args["Story"]
Ejemplo n.º 15
0
from flask import Flask, request, render_template
from stories import Story
# from flask_debugtoolbar import DebugToolbarExtension

app = Flask(__name__)

# app.config['SECRET_KEY'] = "madlib"
# debug = DebugToolbarExtension(app)

story = Story(["place", "adjective", "noun", "verb", "plural_noun"],
              """Once upon a time in a long-ago {place}, there lived a
       large {adjective} {noun}. It loved to {verb} {plural_noun}.""")


@app.route('/')
def home_page():
    word_types = story.prompts
    return render_template('home.html', word_types=word_types)


@app.route('/madlib')
def create_madlib():

    text = story.generate(request.args)

    return render_template("madlib.html", text=text)


# username = request.args["username"]
Ejemplo n.º 16
0
from flask import Flask, request, render_template
from flask_debugtoolbar import DebugToolbarExtension
from stories import Story
app = Flask(__name__)

story1 = Story(["place", "noun", "verb", "adjective", "plural_noun"],
               """Once upon a time in a long-ago {place}, there lived a
       large {adjective} {noun}. It loved to {verb} {plural_noun}.""")

story2 = Story(["noun", "verb", "place", "plural_noun"],
               """I used to care a lot about my {noun}, but since I {verb}
       to {place}. I stopped worrying about all the {plural_noun}.""")

story3 = Story([
    "place", "adjective", "noun"
], """It all seemed so easier back in {place}. The only thing I cared about was my {adjective} {noun}."""
               )

all_stories = {"story1": story1, "story2": story2, "story3": story3}


@app.route('/')
def home_page():
    """Shows home page"""

    return render_template('home.html', prompts=story.prompts)


@app.route('/fillin')
def fillin_page():
    """Shows page in which responses are filled in"""
Ejemplo n.º 17
0
from flask import Flask, request, render_template, session
from flask_debugtoolbar import DebugToolbarExtension
from stories import Story

app = Flask(__name__)

app.config['SECRET_KEY'] = "key"
debug = DebugToolbarExtension(app)

story1 = Story(
    ["place", "noun", "verb", "adjective", "plural_noun"],
    """Once upon a time in a long-ago {place}, there lived a
       large {adjective} {noun}. It loved to {verb} {plural_noun}."""
)

story2 = Story(
    ["noun", "verb", "adjective1", "adjective2"],
    """There once was a {noun} that really loved to {verb}. It was {adjective1} and {adjective2}."""
)

story3 = Story(
    ["verb", "number", "place", "noun"],
    """My favorite thing to do is to {verb}. I do this {number} times each day. 
    I even do ths in the {place} with a {noun}."""
)

stories = {"story1": story1, "story2": story2, "story3": story3}

# story = stories["story1"]

@app.route('/')
Ejemplo n.º 18
0
from flask import Flask, request, render_template
from stories import Story

app = Flask(__name__)

story = Story(["place", "noun", "verb", "adjective", "plural_noun"], """
    Once upon a time in 18th century {place}, there lived a {adjective} {noun}. 
    It loved to {verb} with {plural_noun}. The people of {place} did not like this.
    You won't believe what happened next.
    """)


@app.route('/')
def show_root():
    """Landing page for users"""
    return render_template('home.html', prompts=story.prompts)


@app.route('/story')
def show_story():
    """Show madlib story given user inputs"""
    user_story = story.generate(dict(request.args))
    return f"""
    <h1>Your story</h1>
    <p>{user_story}</p>
    """
Ejemplo n.º 19
0
from flask import Flask, request, render_template
from stories import Story
from flask_debugtoolbar import DebugToolbarExtension

app = Flask(__name__)
app.config['SECRET_KEY'] = "secretkey"
debug = DebugToolbarExtension(app)

newStory = Story([
    "noun", "place", "verb", "adjective"
], """Once upon a time long ago, there was a {adjective} {noun} that lived in a {place}. It loved to {verb}."""
                 )


@app.route('/')
def home():
    prompts = newStory.prompts
    return render_template("madlib-form.html", prompts=prompts)


@app.route('/madlib-answer')
def answer():
    text = newStory.generate(request.args)
    return render_template("madlib-answer.html", text=text)
Ejemplo n.º 20
0
from flask import Flask, request, render_template
from flask_debugtoolbar import DebugToolbarExtension
from stories import Story
import re

app = Flask(__name__)
app.config['SECRET_KEY'] = "secret"
debug = DebugToolbarExtension(app)

once_upon_a_time = Story(
    ["place", "noun", "verb", "adjective", "plural_noun"],
    """Once upon a time in a long-ago {place}, there lived a
        large {adjective} {noun}. It loved to {verb} {plural_noun}.""",
    "Once upon a time")

party_invitation = Story([
    "name", "theme", "place", "day_of_the_week", "time", "verb", "animal",
    "body_part", "contact_information"
], """{name} is having a {theme} party! It's going to be at {place}
            on {day_of_the_week}. Please make sure to show up at
            {time} or else you will be required to {verb} a/an 
            {animal} with your {body_part}""", "Party Invitation")

excused = Story([
    "name", "adjective", "noun"
], """Please excuse {name}, who is far too {adjective} to attend {noun} class.""",
                "Excuse Hall Pass")

vacation = Story([
    "adjective", "adjective_2", "noun", "noun_2", "plural_noun", "game",
    "plural_noun_2", "verb_ending_in_ing", "verb_ending_in_ing_2",
Ejemplo n.º 21
0
def story_listing():
    stories = Story.select()
    return render_template('list.html', stories=stories)
Ejemplo n.º 22
0
def story_view(story_id):
    story = Story.get(Story.id == story_id)
    return render_template('form.html', status='edit', data=story)
Ejemplo n.º 23
0
from flask import Flask, request, render_template
from random import randint, choice, sample
from stories import Story

app = Flask(__name__)

#Story instance to use to show the forms are not hardcoded and can be used with different prompts
myStory = Story([
    "animal", "noun", "verb", "adjective", "plural_noun"
], """One {adjective} day, a little {animal} and his {plural_noun} went to the {noun} to {verb}."""
                )


@app.route('/')
def show_home():
    return render_template('base.html')


@app.route('/form')
def show_form():
    story_words = myStory.prompts
    return render_template('form.html', story_words=story_words)


@app.route('/story')
def show_story():
    text = myStory.generate(request.args)
    return render_template('story.html', text=text)


# Did the entire thing except for line 24, but do NOT understand how to set something like this up for myself