-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: handle routing for starfyre #67
Conversation
from the app_directory/pages, we generate in the generated dist folder, another folder called 'pages' where we all our generated routes will stored
Hey @sansyrox , I hope you are well So far, I have been able to generate routes defined in the pages directory of the Am I on the right track? Also, Few questions:
PS: I will remove the unwanted print statements as we progress |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @DeleMike 👋
Great work! 😄 🔥
I have left a few comments. Do let me know if you require any more information from my end 😄
Yess Few questions:
Let us create them in
Not the contents, but the rendered output. i.e. the components should be resolved like they are being resolved in the |
I will adjust the folder structure then. Thanks I need more clarification on the last bit :
What do you mean, please? When we are generating the new routes, the file contents needs to be parsed before it is written to this route? |
e.g. Similary, the Did this make sense? 😅 What I am trying to say is don't copy just the contents but actually resolve the imports like we do in the init file |
Oh definitely makes sense now, thanks for clarifying! I will look into it. |
Hello @sansyrox , thanks for your feedback. I have made some progress. I added the ability for Starfyre to generate the python files for every fyre file in the pages directory. The way Starfyre handles it is, during compilation, we check if there are some fyre files in the so my next issue is how I go about generating the HTML file. As a start, I see that generation of the My issue is I need the output of As you said The is there another angle I should be looking at? |
Hell @DeleMike 👋 So, if you have a look at the Now, this file's contents are generated through the I hope this helps. We can have a call tomorrow otherwise 😄 |
Okay, sounds great! What function are you referring to here? |
@DeleMike i am talking about the 'python_transpiled_string' function |
Thanks, @sansyrox for clarifying. what do you suggest now? Do we want to stop calling that function from the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @DeleMike 👋
Thank you for the PR! I have some suggestions.
Do let me know if you require any more information from my end 😄
Hey @DeleMike 👋 I have left a few comments. Let me know if you require any more information from me 😄 |
Thanks for the feedback. Please, I need more clarification. What file are you referring to that I keep the imports like the Can you explain more about how the absence of imports affects this issue? |
Yes.
The file is unable to resolve the |
Hello @sansyrox, thanks for the clarification earlier. I have another update. I have been able to tackle the issue where the parser could not resolve the custom components. e.g from .parent import parent
from .store import store I used the Python debugger to peek deeply into the codebase and I saw that our parser was able to resolve the imports. The issue was with how we compiled the code. The parser would read the contents of each imported file but it could not resolve if it was a To resolve this issue and ensure that I resorted to this in the python_transpiled_string function: def python_transpiled_string(
pyml_lines, css_lines, js_lines, client_side_python, file_name
):
file_name = file_name.replace(".py", "").split("/")[-1]
pyml_lines = "".join(pyml_lines)
css_lines = "".join(css_lines)
js_lines = "".join(js_lines)
client_side_python = "".join(client_side_python)
root_name = None
if "__init__" in file_name:
root_name = "app"
else:
root_name = file_name
if root_name == "app":
return f'''
from starfyre import create_component, render_root
def fx_{root_name}():
# not nesting the code to preserve the frames
component = create_component("""
{pyml_lines}
""", css="""
{css_lines}
""", js="""
{js_lines}
""", client_side_python="""
{client_side_python}
""",
component_name="""{root_name}"""
)
return render_root(component)
{root_name}=fx_{root_name}()
'''
else:
return f'''
from starfyre import create_component, render_root
def fx_{root_name}():
component = create_component("""
{pyml_lines}
""", css="""
{css_lines}
""", js="""
{js_lines}
""", client_side_python="""
{client_side_python}
""",
component_name="""{root_name}"""
)
return component
{root_name}=fx_{root_name}()
rendered_{root_name} = render_root({root_name}) # see the change here
''' So now, we ensure every custom-defined is classified as a With this, we make each page a root component and ensure that the parser can resolve the components properly. |
Hey @sansyrox, thanks for your feedback! In this latest update, I have answered the questions you asked and I have reduced the |
Hey @DeleMike 👋 The |
starfyre/main_template.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we give this file a more specific name please? main_template
is a bit too generic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DeleMike this too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
starfyre/main_template.py
Outdated
@@ -0,0 +1,76 @@ | |||
def get_main_template(user_routes, path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for this function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These comments need to be addressed too 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Hey @DeleMike 👋 Thank you for your updates. I have some suggestions. Please do let me know if you have any questions 😄 |
Hello @sansyrox , thanks for the feedback, I have applied them. The most notable will be ensuring that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM , @DeleMike 🔥
Great work. I just want to do a final local test and will merge it afterwards
Thanks for the feedback @sansyrox. Fingers crossed! 🤞🏾 |
All LGTM. Great work @DeleMike 🔥 |
from the
test_application/pages
where we define some routes we want to have, we generate the corresponding routes in the generateddist/pages
folder.So if we have:
The corresponding generated route will be:
closes #28