ibnuda / dactyl-keyboard

Web generator for dactyl keyboards.
https://dactyl.siskam.link
GNU Affero General Public License v3.0
199 stars 51 forks source link

Fix parsing of connector.type in manuform api body #87

Closed yejianfengblue closed 3 years ago

yejianfengblue commented 3 years ago

Connector type is type of string, which should be parsed in form of (keyword (get connector :type "none")) rather than (get connector :type :none).

ibnuda commented 3 years ago

thanks.

yejianfengblue commented 3 years ago

@ibnuda Sorry my bad. I'm not good at clojure. The motivation of this pull request is that I found the parameter connector type of manuform api doesn't work. The case is always generated as connector type is none. So I modify the line

:configuration-connector-type              (get connector :type :none)

to

:configuration-connector-type              (keyword (get connector :type "none"))

following the code example

                        :configuration-thumb-count                 (keyword (get keys :thumb-count "six"))
                        :configuration-last-row-count              (keyword (get keys :last-row "two"))
                        :configuration-switch-type                 (keyword (get keys :switch-type "box"))
                        :configuration-inner-column                (keyword (get keys :inner-column "normie"))

I'm afraid only that line of code change is not enough. I got NullPointerException. Maybe a translation from string "none" to enum value :none is required, as well as "trrs" to :trrs and "rj9" to :rj9.

The sample manuform.json https://github.com/ibnuda/dactyl-keyboard/blob/refaktor/resources/public/manuform.json

<html>

<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <title>Error 500 java.lang.NullPointerException</title>
</head>

<body>
    <h2>HTTP ERROR 500 java.lang.NullPointerException</h2>
    <table>
        <tr>
            <th>URI:</th>
            <td>/api/manuform</td>
        </tr>
        <tr>
            <th>STATUS:</th>
            <td>500</td>
        </tr>
        <tr>
            <th>MESSAGE:</th>
            <td>java.lang.NullPointerException</td>
        </tr>
        <tr>
            <th>SERVLET:</th>
            <td>-</td>
        </tr>
        <tr>
            <th>CAUSED BY:</th>
            <td>java.lang.NullPointerException</td>
        </tr>
    </table>
    <pre>java.lang.NullPointerException
</pre>
    <hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.22.v20191022</a>
    <hr />

</body>

</html>
ibnuda commented 3 years ago

copy the default json files and then try again. i tested the three values and all of them were successfully generated.

the problem was not caused by your change. there are some new variables.